google_youtubeanalytics2/
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 *YouTube Analytics* crate version *1.0.8+20181010*, where *20181010* is the exact revision of the *youtubeAnalytics:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v1.0.8*.
6//! 
7//! Everything else about the *YouTube Analytics* *v2* API can be found at the
8//! [official documentation site](https://developers.google.com/youtube/analytics).
9//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/youtubeanalytics2).
10//! # Features
11//! 
12//! Handle the following *Resources* with ease from the central [hub](struct.YouTubeAnalytics.html) ... 
13//! 
14//! * [group items](struct.GroupItem.html)
15//!  * [*delete*](struct.GroupItemDeleteCall.html), [*insert*](struct.GroupItemInsertCall.html) and [*list*](struct.GroupItemListCall.html)
16//! * [groups](struct.Group.html)
17//!  * [*delete*](struct.GroupDeleteCall.html), [*insert*](struct.GroupInsertCall.html), [*list*](struct.GroupListCall.html) and [*update*](struct.GroupUpdateCall.html)
18//! * reports
19//!  * [*query*](struct.ReportQueryCall.html)
20//! 
21//! 
22//! 
23//! 
24//! Not what you are looking for ? Find all other Google APIs in their Rust [documentation index](http://byron.github.io/google-apis-rs).
25//! 
26//! # Structure of this Library
27//! 
28//! The API is structured into the following primary items:
29//! 
30//! * **[Hub](struct.YouTubeAnalytics.html)**
31//!     * a central object to maintain state and allow accessing all *Activities*
32//!     * creates [*Method Builders*](trait.MethodsBuilder.html) which in turn
33//!       allow access to individual [*Call Builders*](trait.CallBuilder.html)
34//! * **[Resources](trait.Resource.html)**
35//!     * primary types that you can apply *Activities* to
36//!     * a collection of properties and *Parts*
37//!     * **[Parts](trait.Part.html)**
38//!         * a collection of properties
39//!         * never directly used in *Activities*
40//! * **[Activities](trait.CallBuilder.html)**
41//!     * operations to apply to *Resources*
42//! 
43//! All *structures* are marked with applicable traits to further categorize them and ease browsing.
44//! 
45//! Generally speaking, you can invoke *Activities* like this:
46//! 
47//! ```Rust,ignore
48//! let r = hub.resource().activity(...).doit()
49//! ```
50//! 
51//! Or specifically ...
52//! 
53//! ```ignore
54//! let r = hub.groups().list(...).doit()
55//! let r = hub.groups().update(...).doit()
56//! let r = hub.groups().insert(...).doit()
57//! let r = hub.groups().delete(...).doit()
58//! ```
59//! 
60//! The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` 
61//! supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be 
62//! specified right away (i.e. `(...)`), whereas all optional ones can be [build up][builder-pattern] as desired.
63//! The `doit()` method performs the actual communication with the server and returns the respective result.
64//! 
65//! # Usage
66//! 
67//! ## Setting up your Project
68//! 
69//! To use this library, you would put the following lines into your `Cargo.toml` file:
70//! 
71//! ```toml
72//! [dependencies]
73//! google-youtubeanalytics2 = "*"
74//! # This project intentionally uses an old version of Hyper. See
75//! # https://github.com/Byron/google-apis-rs/issues/173 for more
76//! # information.
77//! hyper = "^0.10"
78//! hyper-rustls = "^0.6"
79//! serde = "^1.0"
80//! serde_json = "^1.0"
81//! yup-oauth2 = "^1.0"
82//! ```
83//! 
84//! ## A complete example
85//! 
86//! ```test_harness,no_run
87//! extern crate hyper;
88//! extern crate hyper_rustls;
89//! extern crate yup_oauth2 as oauth2;
90//! extern crate google_youtubeanalytics2 as youtubeanalytics2;
91//! use youtubeanalytics2::{Result, Error};
92//! # #[test] fn egal() {
93//! use std::default::Default;
94//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
95//! use youtubeanalytics2::YouTubeAnalytics;
96//! 
97//! // Get an ApplicationSecret instance by some means. It contains the `client_id` and 
98//! // `client_secret`, among other things.
99//! let secret: ApplicationSecret = Default::default();
100//! // Instantiate the authenticator. It will choose a suitable authentication flow for you, 
101//! // unless you replace  `None` with the desired Flow.
102//! // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about 
103//! // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
104//! // retrieve them from storage.
105//! let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
106//!                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
107//!                               <MemoryStorage as Default>::default(), None);
108//! let mut hub = YouTubeAnalytics::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
109//! // You can configure optional parameters by calling the respective setters at will, and
110//! // execute the final call using `doit()`.
111//! // Values shown here are possibly random and not representative !
112//! let result = hub.groups().list()
113//!              .page_token("et")
114//!              .on_behalf_of_content_owner("dolores")
115//!              .mine(false)
116//!              .id("accusam")
117//!              .doit();
118//! 
119//! match result {
120//!     Err(e) => match e {
121//!         // The Error enum provides details about what exactly happened.
122//!         // You can also just use its `Debug`, `Display` or `Error` traits
123//!          Error::HttpError(_)
124//!         |Error::MissingAPIKey
125//!         |Error::MissingToken(_)
126//!         |Error::Cancelled
127//!         |Error::UploadSizeLimitExceeded(_, _)
128//!         |Error::Failure(_)
129//!         |Error::BadRequest(_)
130//!         |Error::FieldClash(_)
131//!         |Error::JsonDecodeError(_, _) => println!("{}", e),
132//!     },
133//!     Ok(res) => println!("Success: {:?}", res),
134//! }
135//! # }
136//! ```
137//! ## Handling Errors
138//! 
139//! All errors produced by the system are provided either as [Result](enum.Result.html) enumeration as return value of 
140//! the doit() methods, or handed as possibly intermediate results to either the 
141//! [Hub Delegate](trait.Delegate.html), or the [Authenticator Delegate](https://docs.rs/yup-oauth2/*/yup_oauth2/trait.AuthenticatorDelegate.html).
142//! 
143//! When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This 
144//! makes the system potentially resilient to all kinds of errors.
145//! 
146//! ## Uploads and Downloads
147//! If a method supports downloads, the response body, which is part of the [Result](enum.Result.html), should be
148//! read by you to obtain the media.
149//! If such a method also supports a [Response Result](trait.ResponseResult.html), it will return that by default.
150//! 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
151//! this call: `.param("alt", "media")`.
152//! 
153//! Methods supporting uploads can do so using up to 2 different protocols: 
154//! *simple* and *resumable*. The distinctiveness of each is represented by customized 
155//! `doit(...)` methods, which are then named `upload(...)` and `upload_resumable(...)` respectively.
156//! 
157//! ## Customization and Callbacks
158//! 
159//! You may alter the way an `doit()` method is called by providing a [delegate](trait.Delegate.html) to the 
160//! [Method Builder](trait.CallBuilder.html) before making the final `doit()` call. 
161//! Respective methods will be called to provide progress information, as well as determine whether the system should 
162//! retry on failure.
163//! 
164//! The [delegate trait](trait.Delegate.html) is default-implemented, allowing you to customize it with minimal effort.
165//! 
166//! ## Optional Parts in Server-Requests
167//! 
168//! All structures provided by this library are made to be [enocodable](trait.RequestValue.html) and 
169//! [decodable](trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses 
170//! are valid.
171//! Most optionals are are considered [Parts](trait.Part.html) which are identifiable by name, which will be sent to 
172//! the server to indicate either the set parts of the request or the desired parts in the response.
173//! 
174//! ## Builder Arguments
175//! 
176//! Using [method builders](trait.CallBuilder.html), you are able to prepare an action call by repeatedly calling it's methods.
177//! These will always take a single argument, for which the following statements are true.
178//! 
179//! * [PODs][wiki-pod] are handed by copy
180//! * strings are passed as `&str`
181//! * [request values](trait.RequestValue.html) are moved
182//! 
183//! Arguments will always be copied or cloned into the builder, to make them independent of their original life times.
184//! 
185//! [wiki-pod]: http://en.wikipedia.org/wiki/Plain_old_data_structure
186//! [builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern
187//! [google-go-api]: https://github.com/google/google-api-go-client
188//! 
189//! 
190
191// Unused attributes happen thanks to defined, but unused structures
192// We don't warn about this, as depending on the API, some data structures or facilities are never used.
193// Instead of pre-determining this, we just disable the lint. It's manually tuned to not have any
194// unused imports in fully featured APIs. Same with unused_mut ... .
195#![allow(unused_imports, unused_mut, dead_code)]
196
197// DO NOT EDIT !
198// This file was generated automatically from 'src/mako/api/lib.rs.mako'
199// DO NOT EDIT !
200
201#[macro_use]
202extern crate serde_derive;
203
204extern crate hyper;
205extern crate serde;
206extern crate serde_json;
207extern crate yup_oauth2 as oauth2;
208extern crate mime;
209extern crate url;
210
211mod cmn;
212
213use std::collections::HashMap;
214use std::cell::RefCell;
215use std::borrow::BorrowMut;
216use std::default::Default;
217use std::collections::BTreeMap;
218use serde_json as json;
219use std::io;
220use std::fs;
221use std::mem;
222use std::thread::sleep;
223use std::time::Duration;
224
225pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part,
226              ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder,
227              Resource, ErrorResponse, remove_json_null_values};
228
229
230// ##############
231// UTILITIES ###
232// ############
233
234/// Identifies the an OAuth2 authorization scope.
235/// A scope is needed when requesting an
236/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
237#[derive(PartialEq, Eq, Hash)]
238pub enum Scope {
239    /// View your YouTube account
240    YoutubeReadonly,
241
242    /// View YouTube Analytics reports for your YouTube content
243    YtAnalyticReadonly,
244
245    /// Manage your YouTube account
246    Youtube,
247
248    /// View and manage your assets and associated content on YouTube
249    Youtubepartner,
250
251    /// View monetary and non-monetary YouTube Analytics reports for your YouTube content
252    YtAnalyticMonetaryReadonly,
253}
254
255impl AsRef<str> for Scope {
256    fn as_ref(&self) -> &str {
257        match *self {
258            Scope::YoutubeReadonly => "https://www.googleapis.com/auth/youtube.readonly",
259            Scope::YtAnalyticReadonly => "https://www.googleapis.com/auth/yt-analytics.readonly",
260            Scope::Youtube => "https://www.googleapis.com/auth/youtube",
261            Scope::Youtubepartner => "https://www.googleapis.com/auth/youtubepartner",
262            Scope::YtAnalyticMonetaryReadonly => "https://www.googleapis.com/auth/yt-analytics-monetary.readonly",
263        }
264    }
265}
266
267impl Default for Scope {
268    fn default() -> Scope {
269        Scope::YoutubeReadonly
270    }
271}
272
273
274
275// ########
276// HUB ###
277// ######
278
279/// Central instance to access all YouTubeAnalytics related resource activities
280///
281/// # Examples
282///
283/// Instantiate a new hub
284///
285/// ```test_harness,no_run
286/// extern crate hyper;
287/// extern crate hyper_rustls;
288/// extern crate yup_oauth2 as oauth2;
289/// extern crate google_youtubeanalytics2 as youtubeanalytics2;
290/// use youtubeanalytics2::{Result, Error};
291/// # #[test] fn egal() {
292/// use std::default::Default;
293/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
294/// use youtubeanalytics2::YouTubeAnalytics;
295/// 
296/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and 
297/// // `client_secret`, among other things.
298/// let secret: ApplicationSecret = Default::default();
299/// // Instantiate the authenticator. It will choose a suitable authentication flow for you, 
300/// // unless you replace  `None` with the desired Flow.
301/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about 
302/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
303/// // retrieve them from storage.
304/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
305///                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
306///                               <MemoryStorage as Default>::default(), None);
307/// let mut hub = YouTubeAnalytics::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
308/// // You can configure optional parameters by calling the respective setters at will, and
309/// // execute the final call using `doit()`.
310/// // Values shown here are possibly random and not representative !
311/// let result = hub.groups().list()
312///              .page_token("takimata")
313///              .on_behalf_of_content_owner("justo")
314///              .mine(true)
315///              .id("erat")
316///              .doit();
317/// 
318/// match result {
319///     Err(e) => match e {
320///         // The Error enum provides details about what exactly happened.
321///         // You can also just use its `Debug`, `Display` or `Error` traits
322///          Error::HttpError(_)
323///         |Error::MissingAPIKey
324///         |Error::MissingToken(_)
325///         |Error::Cancelled
326///         |Error::UploadSizeLimitExceeded(_, _)
327///         |Error::Failure(_)
328///         |Error::BadRequest(_)
329///         |Error::FieldClash(_)
330///         |Error::JsonDecodeError(_, _) => println!("{}", e),
331///     },
332///     Ok(res) => println!("Success: {:?}", res),
333/// }
334/// # }
335/// ```
336pub struct YouTubeAnalytics<C, A> {
337    client: RefCell<C>,
338    auth: RefCell<A>,
339    _user_agent: String,
340    _base_url: String,
341    _root_url: String,
342}
343
344impl<'a, C, A> Hub for YouTubeAnalytics<C, A> {}
345
346impl<'a, C, A> YouTubeAnalytics<C, A>
347    where  C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
348
349    pub fn new(client: C, authenticator: A) -> YouTubeAnalytics<C, A> {
350        YouTubeAnalytics {
351            client: RefCell::new(client),
352            auth: RefCell::new(authenticator),
353            _user_agent: "google-api-rust-client/1.0.8".to_string(),
354            _base_url: "https://youtubeanalytics.googleapis.com/".to_string(),
355            _root_url: "https://youtubeanalytics.googleapis.com/".to_string(),
356        }
357    }
358
359    pub fn group_items(&'a self) -> GroupItemMethods<'a, C, A> {
360        GroupItemMethods { hub: &self }
361    }
362    pub fn groups(&'a self) -> GroupMethods<'a, C, A> {
363        GroupMethods { hub: &self }
364    }
365    pub fn reports(&'a self) -> ReportMethods<'a, C, A> {
366        ReportMethods { hub: &self }
367    }
368
369    /// Set the user-agent header field to use in all requests to the server.
370    /// It defaults to `google-api-rust-client/1.0.8`.
371    ///
372    /// Returns the previously set user-agent.
373    pub fn user_agent(&mut self, agent_name: String) -> String {
374        mem::replace(&mut self._user_agent, agent_name)
375    }
376
377    /// Set the base url to use in all requests to the server.
378    /// It defaults to `https://youtubeanalytics.googleapis.com/`.
379    ///
380    /// Returns the previously set base url.
381    pub fn base_url(&mut self, new_base_url: String) -> String {
382        mem::replace(&mut self._base_url, new_base_url)
383    }
384
385    /// Set the root url to use in all requests to the server.
386    /// It defaults to `https://youtubeanalytics.googleapis.com/`.
387    ///
388    /// Returns the previously set root url.
389    pub fn root_url(&mut self, new_root_url: String) -> String {
390        mem::replace(&mut self._root_url, new_root_url)
391    }
392}
393
394
395// ############
396// SCHEMAS ###
397// ##########
398/// The description of a column of the result table.
399/// 
400/// This type is not used in any activity, and only used as *part* of another schema.
401/// 
402#[derive(Default, Clone, Debug, Serialize, Deserialize)]
403pub struct ResultTableColumnHeader {
404    /// The type of the data in the column (`STRING`, `INTEGER`, `FLOAT`, etc.).
405    #[serde(rename="dataType")]
406    pub data_type: Option<String>,
407    /// The type of the column (`DIMENSION` or `METRIC`).
408    #[serde(rename="columnType")]
409    pub column_type: Option<String>,
410    /// The name of the dimension or metric.
411    pub name: Option<String>,
412}
413
414impl Part for ResultTableColumnHeader {}
415
416
417/// A group.
418/// 
419/// # Activities
420/// 
421/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
422/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
423/// 
424/// * [list groups](struct.GroupListCall.html) (none)
425/// * [update groups](struct.GroupUpdateCall.html) (request|response)
426/// * [insert groups](struct.GroupInsertCall.html) (request|response)
427/// * [delete groups](struct.GroupDeleteCall.html) (none)
428/// 
429#[derive(Default, Clone, Debug, Serialize, Deserialize)]
430pub struct Group {
431    /// The `snippet` object contains basic information about the group, including
432    /// its creation date and name.
433    pub snippet: Option<GroupSnippet>,
434    /// Identifies the API resource's type. The value will be `youtube#group`.
435    pub kind: Option<String>,
436    /// Apiary error details
437    pub errors: Option<Errors>,
438    /// The Etag of this resource.
439    pub etag: Option<String>,
440    /// The `contentDetails` object contains additional information about the
441    /// group, such as the number and type of items that it contains.
442    #[serde(rename="contentDetails")]
443    pub content_details: Option<GroupContentDetails>,
444    /// The ID that YouTube uses to uniquely identify the group.
445    pub id: Option<String>,
446}
447
448impl RequestValue for Group {}
449impl Resource for Group {}
450impl ResponseResult for Group {}
451
452
453/// A group's content details.
454/// 
455/// This type is not used in any activity, and only used as *part* of another schema.
456/// 
457#[derive(Default, Clone, Debug, Serialize, Deserialize)]
458pub struct GroupContentDetails {
459    /// The number of items in the group.
460    #[serde(rename="itemCount")]
461    pub item_count: Option<i64>,
462    /// The type of resources that the group contains.
463    /// 
464    /// Valid values for this property are:
465    ///  * `youtube#channel`
466    ///  * `youtube#playlist`
467    ///  * `youtube#video`
468    ///  * `youtubePartner#asset`
469    #[serde(rename="itemType")]
470    pub item_type: Option<String>,
471}
472
473impl Part for GroupContentDetails {}
474
475
476/// Empty response.
477/// 
478/// # Activities
479/// 
480/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
481/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
482/// 
483/// * [delete groups](struct.GroupDeleteCall.html) (response)
484/// * [delete group items](struct.GroupItemDeleteCall.html) (response)
485/// 
486#[derive(Default, Clone, Debug, Serialize, Deserialize)]
487pub struct EmptyResponse {
488    /// Apiary error details
489    pub errors: Option<Errors>,
490}
491
492impl ResponseResult for EmptyResponse {}
493
494
495/// Describes one specific error.
496/// 
497/// This type is not used in any activity, and only used as *part* of another schema.
498/// 
499#[derive(Default, Clone, Debug, Serialize, Deserialize)]
500pub struct ErrorProto {
501    /// Error domain. RoSy services can define their own
502    /// domain and error codes. This should normally be
503    /// the name of an enum type, such as: gdata.CoreErrorDomain
504    pub domain: Option<String>,
505    /// Error code in the error domain. This should correspond to
506    /// a value of the enum type whose name is in domain. See
507    /// the core error domain in error_domain.proto.
508    pub code: Option<String>,
509    /// Location of the error, as specified by the location type.
510    /// 
511    /// If location_type is PATH, this should be a path to a field that's
512    /// relative to the request, using FieldPath notation
513    /// (net/proto2/util/public/field_path.h).
514    /// 
515    /// Examples:
516    ///   authenticated_user.gaia_id
517    ///   resource.address[2].country
518    pub location: Option<String>,
519    /// A short explanation for the error, which can be shared outside Google.
520    /// 
521    /// Please set domain, code and arguments whenever possible instead of this
522    /// error message so that external APIs can build safe error messages
523    /// themselves.
524    /// 
525    /// External messages built in a RoSy interface will most likely refer to
526    /// information and concepts that are not available externally and should not
527    /// be exposed. It is safer if external APIs can understand the errors and
528    /// decide what the error message should look like.
529    #[serde(rename="externalErrorMessage")]
530    pub external_error_message: Option<String>,
531    /// Debugging information, which should not be
532    /// shared externally.
533    #[serde(rename="debugInfo")]
534    pub debug_info: Option<String>,
535    /// no description provided
536    #[serde(rename="locationType")]
537    pub location_type: Option<String>,
538    /// Error arguments, to be used when building user-friendly error messages
539    /// given the error domain and code.  Different error codes require different
540    /// arguments.
541    pub argument: Option<Vec<String>>,
542}
543
544impl Part for ErrorProto {}
545
546
547/// Response message for GroupsService.ListGroups.
548/// 
549/// # Activities
550/// 
551/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
552/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
553/// 
554/// * [list groups](struct.GroupListCall.html) (response)
555/// 
556#[derive(Default, Clone, Debug, Serialize, Deserialize)]
557pub struct ListGroupsResponse {
558    /// The token that can be used as the value of the `pageToken` parameter to
559    /// retrieve the next page in the result set.
560    #[serde(rename="nextPageToken")]
561    pub next_page_token: Option<String>,
562    /// A list of groups that match the API request parameters. Each item in the
563    /// list represents a `group` resource.
564    pub items: Option<Vec<Group>>,
565    /// Identifies the API resource's type. The value will be
566    /// `youtube#groupListResponse`.
567    pub kind: Option<String>,
568    /// The Etag of this resource.
569    pub etag: Option<String>,
570    /// Apiary error details
571    pub errors: Option<Errors>,
572}
573
574impl ResponseResult for ListGroupsResponse {}
575
576
577/// Request Error information.
578/// 
579/// The presence of an error field signals that the operation
580/// has failed.
581/// 
582/// This type is not used in any activity, and only used as *part* of another schema.
583/// 
584#[derive(Default, Clone, Debug, Serialize, Deserialize)]
585pub struct Errors {
586    /// Global error code. Deprecated and ignored.
587    /// Set custom error codes in ErrorProto.domain and ErrorProto.code
588    /// instead.
589    pub code: Option<String>,
590    /// Request identifier generated by the service, which can be
591    /// used to identify the error in the logs
592    #[serde(rename="requestId")]
593    pub request_id: Option<String>,
594    /// Specific error description and codes
595    pub error: Option<Vec<ErrorProto>>,
596}
597
598impl Part for Errors {}
599
600
601/// A group snippet.
602/// 
603/// This type is not used in any activity, and only used as *part* of another schema.
604/// 
605#[derive(Default, Clone, Debug, Serialize, Deserialize)]
606pub struct GroupSnippet {
607    /// The date and time that the group was created. The value is specified in
608    /// ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format.
609    #[serde(rename="publishedAt")]
610    pub published_at: Option<String>,
611    /// The group name. The value must be a non-empty string.
612    pub title: Option<String>,
613}
614
615impl Part for GroupSnippet {}
616
617
618/// A group item.
619/// 
620/// # Activities
621/// 
622/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
623/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
624/// 
625/// * [list group items](struct.GroupItemListCall.html) (none)
626/// * [delete group items](struct.GroupItemDeleteCall.html) (none)
627/// * [insert group items](struct.GroupItemInsertCall.html) (request|response)
628/// 
629#[derive(Default, Clone, Debug, Serialize, Deserialize)]
630pub struct GroupItem {
631    /// Identifies the API resource's type. The value will be `youtube#groupItem`.
632    pub kind: Option<String>,
633    /// Apiary error details
634    pub errors: Option<Errors>,
635    /// The `resource` object contains information that identifies the item being
636    /// added to the group.
637    pub resource: Option<GroupItemResource>,
638    /// The Etag of this resource.
639    pub etag: Option<String>,
640    /// The ID that YouTube uses to uniquely identify the group that contains the
641    /// item.
642    #[serde(rename="groupId")]
643    pub group_id: Option<String>,
644    /// The ID that YouTube uses to uniquely identify the `channel`, `video`,
645    /// `playlist`, or `asset` resource that is included in the group. Note that
646    /// this ID refers specifically to the inclusion of that resource in a
647    /// particular group and is different than the channel ID, video ID,
648    /// playlist ID, or asset ID that uniquely identifies the resource itself.
649    /// The `resource.id` property's value specifies the unique channel, video,
650    /// playlist, or asset ID.
651    pub id: Option<String>,
652}
653
654impl RequestValue for GroupItem {}
655impl Resource for GroupItem {}
656impl ResponseResult for GroupItem {}
657
658
659/// There is no detailed description.
660/// 
661/// This type is not used in any activity, and only used as *part* of another schema.
662/// 
663#[derive(Default, Clone, Debug, Serialize, Deserialize)]
664pub struct GroupItemResource {
665    /// Identifies the type of resource being added to the group.
666    /// 
667    /// Valid values for this property are:
668    ///  * `youtube#channel`
669    ///  * `youtube#playlist`
670    ///  * `youtube#video`
671    ///  * `youtubePartner#asset`
672    pub kind: Option<String>,
673    /// The channel, video, playlist, or asset ID that YouTube uses to uniquely
674    /// identify the item that is being added to the group.
675    pub id: Option<String>,
676}
677
678impl Part for GroupItemResource {}
679
680
681/// Response message for TargetedQueriesService.Query.
682/// 
683/// # Activities
684/// 
685/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
686/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
687/// 
688/// * [query reports](struct.ReportQueryCall.html) (response)
689/// 
690#[derive(Default, Clone, Debug, Serialize, Deserialize)]
691pub struct QueryResponse {
692    /// This value specifies the type of data included in the API response.
693    /// For the query method, the kind property value will be
694    /// `youtubeAnalytics#resultTable`.
695    pub kind: Option<String>,
696    /// The list contains all rows of the result table. Each item in the list is
697    /// an array that contains comma-delimited data corresponding to a single row
698    /// of data. The order of the comma-delimited data fields will match the
699    /// order of the columns listed in the `columnHeaders` field.
700    /// 
701    /// If no data is available for the given query, the `rows` element will be
702    /// omitted from the response.
703    /// 
704    /// The response for a query with the `day` dimension will not contain rows for
705    /// the most recent days.
706    pub rows: Option<Vec<Vec<String>>>,
707    /// When set, indicates that the operation failed.
708    pub errors: Option<Errors>,
709    /// This value specifies information about the data returned in the `rows`
710    /// fields. Each item in the `columnHeaders` list identifies a field returned
711    /// in the `rows` value, which contains a list of comma-delimited data. The
712    /// `columnHeaders` list will begin with the dimensions specified in the API
713    /// request, which will be followed by the metrics specified in the API
714    /// request. The order of both dimensions and metrics will match the ordering
715    /// in the API request. For example, if the API request contains the parameters
716    /// `dimensions=ageGroup,gender&metrics=viewerPercentage`, the API response
717    /// will return columns in this order: `ageGroup`, `gender`,
718    /// `viewerPercentage`.
719    #[serde(rename="columnHeaders")]
720    pub column_headers: Option<Vec<ResultTableColumnHeader>>,
721}
722
723impl ResponseResult for QueryResponse {}
724
725
726/// Response message for GroupsService.ListGroupItems.
727/// 
728/// # Activities
729/// 
730/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
731/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
732/// 
733/// * [list group items](struct.GroupItemListCall.html) (response)
734/// 
735#[derive(Default, Clone, Debug, Serialize, Deserialize)]
736pub struct ListGroupItemsResponse {
737    /// A list of groups that match the API request parameters. Each item in the
738    /// list represents a `groupItem` resource.
739    pub items: Option<Vec<GroupItem>>,
740    /// Identifies the API resource's type. The value will be
741    /// `youtube#groupItemListResponse`.
742    pub kind: Option<String>,
743    /// The Etag of this resource.
744    pub etag: Option<String>,
745    /// Apiary error details
746    pub errors: Option<Errors>,
747}
748
749impl ResponseResult for ListGroupItemsResponse {}
750
751
752
753// ###################
754// MethodBuilders ###
755// #################
756
757/// A builder providing access to all methods supported on *report* resources.
758/// It is not used directly, but through the `YouTubeAnalytics` hub.
759///
760/// # Example
761///
762/// Instantiate a resource builder
763///
764/// ```test_harness,no_run
765/// extern crate hyper;
766/// extern crate hyper_rustls;
767/// extern crate yup_oauth2 as oauth2;
768/// extern crate google_youtubeanalytics2 as youtubeanalytics2;
769/// 
770/// # #[test] fn egal() {
771/// use std::default::Default;
772/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
773/// use youtubeanalytics2::YouTubeAnalytics;
774/// 
775/// let secret: ApplicationSecret = Default::default();
776/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
777///                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
778///                               <MemoryStorage as Default>::default(), None);
779/// let mut hub = YouTubeAnalytics::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
780/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
781/// // like `query(...)`
782/// // to build up your call.
783/// let rb = hub.reports();
784/// # }
785/// ```
786pub struct ReportMethods<'a, C, A>
787    where C: 'a, A: 'a {
788
789    hub: &'a YouTubeAnalytics<C, A>,
790}
791
792impl<'a, C, A> MethodsBuilder for ReportMethods<'a, C, A> {}
793
794impl<'a, C, A> ReportMethods<'a, C, A> {
795    
796    /// Create a builder to help you perform the following task:
797    ///
798    /// Retrieve your YouTube Analytics reports.
799    pub fn query(&self) -> ReportQueryCall<'a, C, A> {
800        ReportQueryCall {
801            hub: self.hub,
802            _start_index: Default::default(),
803            _start_date: Default::default(),
804            _sort: Default::default(),
805            _metrics: Default::default(),
806            _max_results: Default::default(),
807            _include_historical_channel_data: Default::default(),
808            _ids: Default::default(),
809            _filters: Default::default(),
810            _end_date: Default::default(),
811            _dimensions: Default::default(),
812            _currency: Default::default(),
813            _delegate: Default::default(),
814            _scopes: Default::default(),
815            _additional_params: Default::default(),
816        }
817    }
818}
819
820
821
822/// A builder providing access to all methods supported on *groupItem* resources.
823/// It is not used directly, but through the `YouTubeAnalytics` hub.
824///
825/// # Example
826///
827/// Instantiate a resource builder
828///
829/// ```test_harness,no_run
830/// extern crate hyper;
831/// extern crate hyper_rustls;
832/// extern crate yup_oauth2 as oauth2;
833/// extern crate google_youtubeanalytics2 as youtubeanalytics2;
834/// 
835/// # #[test] fn egal() {
836/// use std::default::Default;
837/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
838/// use youtubeanalytics2::YouTubeAnalytics;
839/// 
840/// let secret: ApplicationSecret = Default::default();
841/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
842///                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
843///                               <MemoryStorage as Default>::default(), None);
844/// let mut hub = YouTubeAnalytics::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
845/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
846/// // like `delete(...)`, `insert(...)` and `list(...)`
847/// // to build up your call.
848/// let rb = hub.group_items();
849/// # }
850/// ```
851pub struct GroupItemMethods<'a, C, A>
852    where C: 'a, A: 'a {
853
854    hub: &'a YouTubeAnalytics<C, A>,
855}
856
857impl<'a, C, A> MethodsBuilder for GroupItemMethods<'a, C, A> {}
858
859impl<'a, C, A> GroupItemMethods<'a, C, A> {
860    
861    /// Create a builder to help you perform the following task:
862    ///
863    /// Creates a group item.
864    /// 
865    /// # Arguments
866    ///
867    /// * `request` - No description provided.
868    pub fn insert(&self, request: GroupItem) -> GroupItemInsertCall<'a, C, A> {
869        GroupItemInsertCall {
870            hub: self.hub,
871            _request: request,
872            _on_behalf_of_content_owner: Default::default(),
873            _delegate: Default::default(),
874            _scopes: Default::default(),
875            _additional_params: Default::default(),
876        }
877    }
878    
879    /// Create a builder to help you perform the following task:
880    ///
881    /// Returns a collection of group items that match the API request parameters.
882    pub fn list(&self) -> GroupItemListCall<'a, C, A> {
883        GroupItemListCall {
884            hub: self.hub,
885            _on_behalf_of_content_owner: Default::default(),
886            _group_id: Default::default(),
887            _delegate: Default::default(),
888            _scopes: Default::default(),
889            _additional_params: Default::default(),
890        }
891    }
892    
893    /// Create a builder to help you perform the following task:
894    ///
895    /// Removes an item from a group.
896    pub fn delete(&self) -> GroupItemDeleteCall<'a, C, A> {
897        GroupItemDeleteCall {
898            hub: self.hub,
899            _on_behalf_of_content_owner: Default::default(),
900            _id: Default::default(),
901            _delegate: Default::default(),
902            _scopes: Default::default(),
903            _additional_params: Default::default(),
904        }
905    }
906}
907
908
909
910/// A builder providing access to all methods supported on *group* resources.
911/// It is not used directly, but through the `YouTubeAnalytics` hub.
912///
913/// # Example
914///
915/// Instantiate a resource builder
916///
917/// ```test_harness,no_run
918/// extern crate hyper;
919/// extern crate hyper_rustls;
920/// extern crate yup_oauth2 as oauth2;
921/// extern crate google_youtubeanalytics2 as youtubeanalytics2;
922/// 
923/// # #[test] fn egal() {
924/// use std::default::Default;
925/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
926/// use youtubeanalytics2::YouTubeAnalytics;
927/// 
928/// let secret: ApplicationSecret = Default::default();
929/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
930///                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
931///                               <MemoryStorage as Default>::default(), None);
932/// let mut hub = YouTubeAnalytics::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
933/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
934/// // like `delete(...)`, `insert(...)`, `list(...)` and `update(...)`
935/// // to build up your call.
936/// let rb = hub.groups();
937/// # }
938/// ```
939pub struct GroupMethods<'a, C, A>
940    where C: 'a, A: 'a {
941
942    hub: &'a YouTubeAnalytics<C, A>,
943}
944
945impl<'a, C, A> MethodsBuilder for GroupMethods<'a, C, A> {}
946
947impl<'a, C, A> GroupMethods<'a, C, A> {
948    
949    /// Create a builder to help you perform the following task:
950    ///
951    /// Deletes a group.
952    pub fn delete(&self) -> GroupDeleteCall<'a, C, A> {
953        GroupDeleteCall {
954            hub: self.hub,
955            _on_behalf_of_content_owner: Default::default(),
956            _id: Default::default(),
957            _delegate: Default::default(),
958            _scopes: Default::default(),
959            _additional_params: Default::default(),
960        }
961    }
962    
963    /// Create a builder to help you perform the following task:
964    ///
965    /// Creates a group.
966    /// 
967    /// # Arguments
968    ///
969    /// * `request` - No description provided.
970    pub fn insert(&self, request: Group) -> GroupInsertCall<'a, C, A> {
971        GroupInsertCall {
972            hub: self.hub,
973            _request: request,
974            _on_behalf_of_content_owner: Default::default(),
975            _delegate: Default::default(),
976            _scopes: Default::default(),
977            _additional_params: Default::default(),
978        }
979    }
980    
981    /// Create a builder to help you perform the following task:
982    ///
983    /// Returns a collection of groups that match the API request parameters. For
984    /// example, you can retrieve all groups that the authenticated user owns,
985    /// or you can retrieve one or more groups by their unique IDs.
986    pub fn list(&self) -> GroupListCall<'a, C, A> {
987        GroupListCall {
988            hub: self.hub,
989            _page_token: Default::default(),
990            _on_behalf_of_content_owner: Default::default(),
991            _mine: Default::default(),
992            _id: Default::default(),
993            _delegate: Default::default(),
994            _scopes: Default::default(),
995            _additional_params: Default::default(),
996        }
997    }
998    
999    /// Create a builder to help you perform the following task:
1000    ///
1001    /// Modifies a group. For example, you could change a group's title.
1002    /// 
1003    /// # Arguments
1004    ///
1005    /// * `request` - No description provided.
1006    pub fn update(&self, request: Group) -> GroupUpdateCall<'a, C, A> {
1007        GroupUpdateCall {
1008            hub: self.hub,
1009            _request: request,
1010            _on_behalf_of_content_owner: Default::default(),
1011            _delegate: Default::default(),
1012            _scopes: Default::default(),
1013            _additional_params: Default::default(),
1014        }
1015    }
1016}
1017
1018
1019
1020
1021
1022// ###################
1023// CallBuilders   ###
1024// #################
1025
1026/// Retrieve your YouTube Analytics reports.
1027///
1028/// A builder for the *query* method supported by a *report* resource.
1029/// It is not used directly, but through a `ReportMethods` instance.
1030///
1031/// # Example
1032///
1033/// Instantiate a resource method builder
1034///
1035/// ```test_harness,no_run
1036/// # extern crate hyper;
1037/// # extern crate hyper_rustls;
1038/// # extern crate yup_oauth2 as oauth2;
1039/// # extern crate google_youtubeanalytics2 as youtubeanalytics2;
1040/// # #[test] fn egal() {
1041/// # use std::default::Default;
1042/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
1043/// # use youtubeanalytics2::YouTubeAnalytics;
1044/// 
1045/// # let secret: ApplicationSecret = Default::default();
1046/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
1047/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
1048/// #                               <MemoryStorage as Default>::default(), None);
1049/// # let mut hub = YouTubeAnalytics::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
1050/// // You can configure optional parameters by calling the respective setters at will, and
1051/// // execute the final call using `doit()`.
1052/// // Values shown here are possibly random and not representative !
1053/// let result = hub.reports().query()
1054///              .start_index(-35)
1055///              .start_date("sea")
1056///              .sort("nonumy")
1057///              .metrics("dolores")
1058///              .max_results(-61)
1059///              .include_historical_channel_data(false)
1060///              .ids("aliquyam")
1061///              .filters("ea")
1062///              .end_date("no")
1063///              .dimensions("justo")
1064///              .currency("justo")
1065///              .doit();
1066/// # }
1067/// ```
1068pub struct ReportQueryCall<'a, C, A>
1069    where C: 'a, A: 'a {
1070
1071    hub: &'a YouTubeAnalytics<C, A>,
1072    _start_index: Option<i32>,
1073    _start_date: Option<String>,
1074    _sort: Option<String>,
1075    _metrics: Option<String>,
1076    _max_results: Option<i32>,
1077    _include_historical_channel_data: Option<bool>,
1078    _ids: Option<String>,
1079    _filters: Option<String>,
1080    _end_date: Option<String>,
1081    _dimensions: Option<String>,
1082    _currency: Option<String>,
1083    _delegate: Option<&'a mut Delegate>,
1084    _additional_params: HashMap<String, String>,
1085    _scopes: BTreeMap<String, ()>
1086}
1087
1088impl<'a, C, A> CallBuilder for ReportQueryCall<'a, C, A> {}
1089
1090impl<'a, C, A> ReportQueryCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
1091
1092
1093    /// Perform the operation you have build so far.
1094    pub fn doit(mut self) -> Result<(hyper::client::Response, QueryResponse)> {
1095        use std::io::{Read, Seek};
1096        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
1097        let mut dd = DefaultDelegate;
1098        let mut dlg: &mut Delegate = match self._delegate {
1099            Some(d) => d,
1100            None => &mut dd
1101        };
1102        dlg.begin(MethodInfo { id: "youtubeAnalytics.reports.query",
1103                               http_method: hyper::method::Method::Get });
1104        let mut params: Vec<(&str, String)> = Vec::with_capacity(13 + self._additional_params.len());
1105        if let Some(value) = self._start_index {
1106            params.push(("startIndex", value.to_string()));
1107        }
1108        if let Some(value) = self._start_date {
1109            params.push(("startDate", value.to_string()));
1110        }
1111        if let Some(value) = self._sort {
1112            params.push(("sort", value.to_string()));
1113        }
1114        if let Some(value) = self._metrics {
1115            params.push(("metrics", value.to_string()));
1116        }
1117        if let Some(value) = self._max_results {
1118            params.push(("maxResults", value.to_string()));
1119        }
1120        if let Some(value) = self._include_historical_channel_data {
1121            params.push(("includeHistoricalChannelData", value.to_string()));
1122        }
1123        if let Some(value) = self._ids {
1124            params.push(("ids", value.to_string()));
1125        }
1126        if let Some(value) = self._filters {
1127            params.push(("filters", value.to_string()));
1128        }
1129        if let Some(value) = self._end_date {
1130            params.push(("endDate", value.to_string()));
1131        }
1132        if let Some(value) = self._dimensions {
1133            params.push(("dimensions", value.to_string()));
1134        }
1135        if let Some(value) = self._currency {
1136            params.push(("currency", value.to_string()));
1137        }
1138        for &field in ["alt", "startIndex", "startDate", "sort", "metrics", "maxResults", "includeHistoricalChannelData", "ids", "filters", "endDate", "dimensions", "currency"].iter() {
1139            if self._additional_params.contains_key(field) {
1140                dlg.finished(false);
1141                return Err(Error::FieldClash(field));
1142            }
1143        }
1144        for (name, value) in self._additional_params.iter() {
1145            params.push((&name, value.clone()));
1146        }
1147
1148        params.push(("alt", "json".to_string()));
1149
1150        let mut url = self.hub._base_url.clone() + "v2/reports";
1151        if self._scopes.len() == 0 {
1152            self._scopes.insert(Scope::YoutubeReadonly.as_ref().to_string(), ());
1153        }
1154
1155
1156        if params.len() > 0 {
1157            url.push('?');
1158            url.push_str(&url::form_urlencoded::serialize(params));
1159        }
1160
1161
1162
1163        loop {
1164            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
1165                Ok(token) => token,
1166                Err(err) => {
1167                    match  dlg.token(&*err) {
1168                        Some(token) => token,
1169                        None => {
1170                            dlg.finished(false);
1171                            return Err(Error::MissingToken(err))
1172                        }
1173                    }
1174                }
1175            };
1176            let auth_header = Authorization(Bearer { token: token.access_token });
1177            let mut req_result = {
1178                let mut client = &mut *self.hub.client.borrow_mut();
1179                let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url)
1180                    .header(UserAgent(self.hub._user_agent.clone()))
1181                    .header(auth_header.clone());
1182
1183                dlg.pre_request();
1184                req.send()
1185            };
1186
1187            match req_result {
1188                Err(err) => {
1189                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
1190                        sleep(d);
1191                        continue;
1192                    }
1193                    dlg.finished(false);
1194                    return Err(Error::HttpError(err))
1195                }
1196                Ok(mut res) => {
1197                    if !res.status.is_success() {
1198                        let mut json_err = String::new();
1199                        res.read_to_string(&mut json_err).unwrap();
1200                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
1201                                                              json::from_str(&json_err).ok(),
1202                                                              json::from_str(&json_err).ok()) {
1203                            sleep(d);
1204                            continue;
1205                        }
1206                        dlg.finished(false);
1207                        return match json::from_str::<ErrorResponse>(&json_err){
1208                            Err(_) => Err(Error::Failure(res)),
1209                            Ok(serr) => Err(Error::BadRequest(serr))
1210                        }
1211                    }
1212                    let result_value = {
1213                        let mut json_response = String::new();
1214                        res.read_to_string(&mut json_response).unwrap();
1215                        match json::from_str(&json_response) {
1216                            Ok(decoded) => (res, decoded),
1217                            Err(err) => {
1218                                dlg.response_json_decode_error(&json_response, &err);
1219                                return Err(Error::JsonDecodeError(json_response, err));
1220                            }
1221                        }
1222                    };
1223
1224                    dlg.finished(true);
1225                    return Ok(result_value)
1226                }
1227            }
1228        }
1229    }
1230
1231
1232    /// An index of the first entity to retrieve. Use this parameter as a
1233    /// pagination mechanism along with the max-results parameter (one-based,
1234    /// inclusive).",
1235    /// minValue: 1
1236    ///
1237    /// Sets the *start index* query property to the given value.
1238    pub fn start_index(mut self, new_value: i32) -> ReportQueryCall<'a, C, A> {
1239        self._start_index = Some(new_value);
1240        self
1241    }
1242    /// The start date for fetching YouTube Analytics data. The value should be in
1243    /// `YYYY-MM-DD` format.
1244    /// required: true, pattern: "[0-9]{4}-[0-9]{2}-[0-9]{2}
1245    ///
1246    /// Sets the *start date* query property to the given value.
1247    pub fn start_date(mut self, new_value: &str) -> ReportQueryCall<'a, C, A> {
1248        self._start_date = Some(new_value.to_string());
1249        self
1250    }
1251    /// A comma-separated list of dimensions or metrics that determine the sort
1252    /// order for YouTube Analytics data. By default the sort order is ascending.
1253    /// The '`-`' prefix causes descending sort order.",
1254    /// pattern: [-0-9a-zA-Z,]+
1255    ///
1256    /// Sets the *sort* query property to the given value.
1257    pub fn sort(mut self, new_value: &str) -> ReportQueryCall<'a, C, A> {
1258        self._sort = Some(new_value.to_string());
1259        self
1260    }
1261    /// A comma-separated list of YouTube Analytics metrics, such as `views` or
1262    /// `likes,dislikes`. See the
1263    /// [Available Reports](/youtube/analytics/v2/available_reports)  document for
1264    /// a list of the reports that you can retrieve and the metrics
1265    /// available in each report, and see the
1266    /// [Metrics](/youtube/analytics/v2/dimsmets/mets) document for definitions of
1267    /// those metrics.
1268    /// required: true, pattern: [0-9a-zA-Z,]+
1269    ///
1270    /// Sets the *metrics* query property to the given value.
1271    pub fn metrics(mut self, new_value: &str) -> ReportQueryCall<'a, C, A> {
1272        self._metrics = Some(new_value.to_string());
1273        self
1274    }
1275    /// The maximum number of rows to include in the response.",
1276    /// minValue: 1
1277    ///
1278    /// Sets the *max results* query property to the given value.
1279    pub fn max_results(mut self, new_value: i32) -> ReportQueryCall<'a, C, A> {
1280        self._max_results = Some(new_value);
1281        self
1282    }
1283    /// If set to true historical data (i.e. channel data from before the linking
1284    /// of the channel to the content owner) will be retrieved.",
1285    ///
1286    /// Sets the *include historical channel data* query property to the given value.
1287    pub fn include_historical_channel_data(mut self, new_value: bool) -> ReportQueryCall<'a, C, A> {
1288        self._include_historical_channel_data = Some(new_value);
1289        self
1290    }
1291    /// Identifies the YouTube channel or content owner for which you are
1292    /// retrieving YouTube Analytics data.
1293    /// 
1294    /// - To request data for a YouTube user, set the `ids` parameter value to
1295    ///   `channel==CHANNEL_ID`, where `CHANNEL_ID` specifies the unique YouTube
1296    ///   channel ID.
1297    /// - To request data for a YouTube CMS content owner, set the `ids` parameter
1298    ///   value to `contentOwner==OWNER_NAME`, where `OWNER_NAME` is the CMS name
1299    ///   of the content owner.
1300    /// required: true, pattern: [a-zA-Z]+==[a-zA-Z0-9_+-]+
1301    ///
1302    /// Sets the *ids* query property to the given value.
1303    pub fn ids(mut self, new_value: &str) -> ReportQueryCall<'a, C, A> {
1304        self._ids = Some(new_value.to_string());
1305        self
1306    }
1307    /// A list of filters that should be applied when retrieving YouTube Analytics
1308    /// data. The [Available Reports](/youtube/analytics/v2/available_reports)
1309    /// document identifies the dimensions that can be used to filter each report,
1310    /// and the [Dimensions](/youtube/analytics/v2/dimsmets/dims)  document defines
1311    /// those dimensions. If a request uses multiple filters, join them together
1312    /// with a semicolon (`;`), and the returned result table will satisfy both
1313    /// filters. For example, a filters parameter value of
1314    /// `video==dMH0bHeiRNg;country==IT` restricts the result set to include data
1315    /// for the given video in Italy.",
1316    ///
1317    /// Sets the *filters* query property to the given value.
1318    pub fn filters(mut self, new_value: &str) -> ReportQueryCall<'a, C, A> {
1319        self._filters = Some(new_value.to_string());
1320        self
1321    }
1322    /// The end date for fetching YouTube Analytics data. The value should be in
1323    /// `YYYY-MM-DD` format.
1324    /// required: true, pattern: [0-9]{4}-[0-9]{2}-[0-9]{2}
1325    ///
1326    /// Sets the *end date* query property to the given value.
1327    pub fn end_date(mut self, new_value: &str) -> ReportQueryCall<'a, C, A> {
1328        self._end_date = Some(new_value.to_string());
1329        self
1330    }
1331    /// A comma-separated list of YouTube Analytics dimensions, such as `views` or
1332    /// `ageGroup,gender`. See the [Available
1333    /// Reports](/youtube/analytics/v2/available_reports) document for a list of
1334    /// the reports that you can retrieve and the dimensions used for those
1335    /// reports. Also see the [Dimensions](/youtube/analytics/v2/dimsmets/dims)
1336    /// document for definitions of those dimensions."
1337    /// pattern: [0-9a-zA-Z,]+
1338    ///
1339    /// Sets the *dimensions* query property to the given value.
1340    pub fn dimensions(mut self, new_value: &str) -> ReportQueryCall<'a, C, A> {
1341        self._dimensions = Some(new_value.to_string());
1342        self
1343    }
1344    /// The currency to which financial metrics should be converted. The default is
1345    /// US Dollar (USD). If the result contains no financial metrics, this flag
1346    /// will be ignored. Responds with an error if the specified currency is not
1347    /// recognized.",
1348    /// pattern: [A-Z]{3}
1349    ///
1350    /// Sets the *currency* query property to the given value.
1351    pub fn currency(mut self, new_value: &str) -> ReportQueryCall<'a, C, A> {
1352        self._currency = Some(new_value.to_string());
1353        self
1354    }
1355    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1356    /// while executing the actual API request.
1357    /// 
1358    /// It should be used to handle progress information, and to implement a certain level of resilience.
1359    ///
1360    /// Sets the *delegate* property to the given value.
1361    pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportQueryCall<'a, C, A> {
1362        self._delegate = Some(new_value);
1363        self
1364    }
1365
1366    /// Set any additional parameter of the query string used in the request.
1367    /// It should be used to set parameters which are not yet available through their own
1368    /// setters.
1369    ///
1370    /// Please note that this method must not be used to set any of the known paramters
1371    /// which have their own setter method. If done anyway, the request will fail.
1372    ///
1373    /// # Additional Parameters
1374    ///
1375    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1376    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1377    /// * *access_token* (query-string) - OAuth access token.
1378    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1379    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
1380    /// * *callback* (query-string) - JSONP
1381    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1382    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1383    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1384    /// * *alt* (query-string) - Data format for response.
1385    /// * *$.xgafv* (query-string) - V1 error format.
1386    pub fn param<T>(mut self, name: T, value: T) -> ReportQueryCall<'a, C, A>
1387                                                        where T: AsRef<str> {
1388        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
1389        self
1390    }
1391
1392    /// Identifies the authorization scope for the method you are building.
1393    ///
1394    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
1395    /// `Scope::YoutubeReadonly`.
1396    ///
1397    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1398    /// tokens for more than one scope.
1399    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
1400    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
1401    /// function for details).
1402    ///
1403    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1404    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1405    /// sufficient, a read-write scope will do as well.
1406    pub fn add_scope<T, S>(mut self, scope: T) -> ReportQueryCall<'a, C, A>
1407                                                        where T: Into<Option<S>>,
1408                                                              S: AsRef<str> {
1409        match scope.into() {
1410          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
1411          None => None,
1412        };
1413        self
1414    }
1415}
1416
1417
1418/// Creates a group item.
1419///
1420/// A builder for the *insert* method supported by a *groupItem* resource.
1421/// It is not used directly, but through a `GroupItemMethods` instance.
1422///
1423/// # Example
1424///
1425/// Instantiate a resource method builder
1426///
1427/// ```test_harness,no_run
1428/// # extern crate hyper;
1429/// # extern crate hyper_rustls;
1430/// # extern crate yup_oauth2 as oauth2;
1431/// # extern crate google_youtubeanalytics2 as youtubeanalytics2;
1432/// use youtubeanalytics2::GroupItem;
1433/// # #[test] fn egal() {
1434/// # use std::default::Default;
1435/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
1436/// # use youtubeanalytics2::YouTubeAnalytics;
1437/// 
1438/// # let secret: ApplicationSecret = Default::default();
1439/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
1440/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
1441/// #                               <MemoryStorage as Default>::default(), None);
1442/// # let mut hub = YouTubeAnalytics::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
1443/// // As the method needs a request, you would usually fill it with the desired information
1444/// // into the respective structure. Some of the parts shown here might not be applicable !
1445/// // Values shown here are possibly random and not representative !
1446/// let mut req = GroupItem::default();
1447/// 
1448/// // You can configure optional parameters by calling the respective setters at will, and
1449/// // execute the final call using `doit()`.
1450/// // Values shown here are possibly random and not representative !
1451/// let result = hub.group_items().insert(req)
1452///              .on_behalf_of_content_owner("et")
1453///              .doit();
1454/// # }
1455/// ```
1456pub struct GroupItemInsertCall<'a, C, A>
1457    where C: 'a, A: 'a {
1458
1459    hub: &'a YouTubeAnalytics<C, A>,
1460    _request: GroupItem,
1461    _on_behalf_of_content_owner: Option<String>,
1462    _delegate: Option<&'a mut Delegate>,
1463    _additional_params: HashMap<String, String>,
1464    _scopes: BTreeMap<String, ()>
1465}
1466
1467impl<'a, C, A> CallBuilder for GroupItemInsertCall<'a, C, A> {}
1468
1469impl<'a, C, A> GroupItemInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
1470
1471
1472    /// Perform the operation you have build so far.
1473    pub fn doit(mut self) -> Result<(hyper::client::Response, GroupItem)> {
1474        use std::io::{Read, Seek};
1475        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
1476        let mut dd = DefaultDelegate;
1477        let mut dlg: &mut Delegate = match self._delegate {
1478            Some(d) => d,
1479            None => &mut dd
1480        };
1481        dlg.begin(MethodInfo { id: "youtubeAnalytics.groupItems.insert",
1482                               http_method: hyper::method::Method::Post });
1483        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
1484        if let Some(value) = self._on_behalf_of_content_owner {
1485            params.push(("onBehalfOfContentOwner", value.to_string()));
1486        }
1487        for &field in ["alt", "onBehalfOfContentOwner"].iter() {
1488            if self._additional_params.contains_key(field) {
1489                dlg.finished(false);
1490                return Err(Error::FieldClash(field));
1491            }
1492        }
1493        for (name, value) in self._additional_params.iter() {
1494            params.push((&name, value.clone()));
1495        }
1496
1497        params.push(("alt", "json".to_string()));
1498
1499        let mut url = self.hub._base_url.clone() + "v2/groupItems";
1500        if self._scopes.len() == 0 {
1501            self._scopes.insert(Scope::Youtube.as_ref().to_string(), ());
1502        }
1503
1504
1505        if params.len() > 0 {
1506            url.push('?');
1507            url.push_str(&url::form_urlencoded::serialize(params));
1508        }
1509
1510        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
1511        let mut request_value_reader =
1512            {
1513                let mut value = json::value::to_value(&self._request).expect("serde to work");
1514                remove_json_null_values(&mut value);
1515                let mut dst = io::Cursor::new(Vec::with_capacity(128));
1516                json::to_writer(&mut dst, &value).unwrap();
1517                dst
1518            };
1519        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
1520        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
1521
1522
1523        loop {
1524            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
1525                Ok(token) => token,
1526                Err(err) => {
1527                    match  dlg.token(&*err) {
1528                        Some(token) => token,
1529                        None => {
1530                            dlg.finished(false);
1531                            return Err(Error::MissingToken(err))
1532                        }
1533                    }
1534                }
1535            };
1536            let auth_header = Authorization(Bearer { token: token.access_token });
1537            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
1538            let mut req_result = {
1539                let mut client = &mut *self.hub.client.borrow_mut();
1540                let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url)
1541                    .header(UserAgent(self.hub._user_agent.clone()))
1542                    .header(auth_header.clone())
1543                    .header(ContentType(json_mime_type.clone()))
1544                    .header(ContentLength(request_size as u64))
1545                    .body(&mut request_value_reader);
1546
1547                dlg.pre_request();
1548                req.send()
1549            };
1550
1551            match req_result {
1552                Err(err) => {
1553                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
1554                        sleep(d);
1555                        continue;
1556                    }
1557                    dlg.finished(false);
1558                    return Err(Error::HttpError(err))
1559                }
1560                Ok(mut res) => {
1561                    if !res.status.is_success() {
1562                        let mut json_err = String::new();
1563                        res.read_to_string(&mut json_err).unwrap();
1564                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
1565                                                              json::from_str(&json_err).ok(),
1566                                                              json::from_str(&json_err).ok()) {
1567                            sleep(d);
1568                            continue;
1569                        }
1570                        dlg.finished(false);
1571                        return match json::from_str::<ErrorResponse>(&json_err){
1572                            Err(_) => Err(Error::Failure(res)),
1573                            Ok(serr) => Err(Error::BadRequest(serr))
1574                        }
1575                    }
1576                    let result_value = {
1577                        let mut json_response = String::new();
1578                        res.read_to_string(&mut json_response).unwrap();
1579                        match json::from_str(&json_response) {
1580                            Ok(decoded) => (res, decoded),
1581                            Err(err) => {
1582                                dlg.response_json_decode_error(&json_response, &err);
1583                                return Err(Error::JsonDecodeError(json_response, err));
1584                            }
1585                        }
1586                    };
1587
1588                    dlg.finished(true);
1589                    return Ok(result_value)
1590                }
1591            }
1592        }
1593    }
1594
1595
1596    ///
1597    /// Sets the *request* property to the given value.
1598    ///
1599    /// Even though the property as already been set when instantiating this call,
1600    /// we provide this method for API completeness.
1601    pub fn request(mut self, new_value: GroupItem) -> GroupItemInsertCall<'a, C, A> {
1602        self._request = new_value;
1603        self
1604    }
1605    /// This parameter can only be used in a properly authorized request. **Note:**
1606    /// This parameter is intended exclusively for YouTube content partners that
1607    /// own and manage many different YouTube channels.
1608    /// 
1609    /// The `onBehalfOfContentOwner` parameter indicates that the request's
1610    /// authorization credentials identify a YouTube user who is acting on behalf
1611    /// of the content owner specified in the parameter value. It allows content
1612    /// owners to authenticate once and get access to all their video and channel
1613    /// data, without having to provide authentication credentials for each
1614    /// individual channel. The account that the user authenticates with must be
1615    /// linked to the specified YouTube content owner.
1616    ///
1617    /// Sets the *on behalf of content owner* query property to the given value.
1618    pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> GroupItemInsertCall<'a, C, A> {
1619        self._on_behalf_of_content_owner = Some(new_value.to_string());
1620        self
1621    }
1622    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1623    /// while executing the actual API request.
1624    /// 
1625    /// It should be used to handle progress information, and to implement a certain level of resilience.
1626    ///
1627    /// Sets the *delegate* property to the given value.
1628    pub fn delegate(mut self, new_value: &'a mut Delegate) -> GroupItemInsertCall<'a, C, A> {
1629        self._delegate = Some(new_value);
1630        self
1631    }
1632
1633    /// Set any additional parameter of the query string used in the request.
1634    /// It should be used to set parameters which are not yet available through their own
1635    /// setters.
1636    ///
1637    /// Please note that this method must not be used to set any of the known paramters
1638    /// which have their own setter method. If done anyway, the request will fail.
1639    ///
1640    /// # Additional Parameters
1641    ///
1642    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1643    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1644    /// * *access_token* (query-string) - OAuth access token.
1645    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1646    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
1647    /// * *callback* (query-string) - JSONP
1648    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1649    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1650    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1651    /// * *alt* (query-string) - Data format for response.
1652    /// * *$.xgafv* (query-string) - V1 error format.
1653    pub fn param<T>(mut self, name: T, value: T) -> GroupItemInsertCall<'a, C, A>
1654                                                        where T: AsRef<str> {
1655        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
1656        self
1657    }
1658
1659    /// Identifies the authorization scope for the method you are building.
1660    ///
1661    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
1662    /// `Scope::Youtube`.
1663    ///
1664    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1665    /// tokens for more than one scope.
1666    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
1667    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
1668    /// function for details).
1669    ///
1670    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1671    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1672    /// sufficient, a read-write scope will do as well.
1673    pub fn add_scope<T, S>(mut self, scope: T) -> GroupItemInsertCall<'a, C, A>
1674                                                        where T: Into<Option<S>>,
1675                                                              S: AsRef<str> {
1676        match scope.into() {
1677          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
1678          None => None,
1679        };
1680        self
1681    }
1682}
1683
1684
1685/// Returns a collection of group items that match the API request parameters.
1686///
1687/// A builder for the *list* method supported by a *groupItem* resource.
1688/// It is not used directly, but through a `GroupItemMethods` instance.
1689///
1690/// # Example
1691///
1692/// Instantiate a resource method builder
1693///
1694/// ```test_harness,no_run
1695/// # extern crate hyper;
1696/// # extern crate hyper_rustls;
1697/// # extern crate yup_oauth2 as oauth2;
1698/// # extern crate google_youtubeanalytics2 as youtubeanalytics2;
1699/// # #[test] fn egal() {
1700/// # use std::default::Default;
1701/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
1702/// # use youtubeanalytics2::YouTubeAnalytics;
1703/// 
1704/// # let secret: ApplicationSecret = Default::default();
1705/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
1706/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
1707/// #                               <MemoryStorage as Default>::default(), None);
1708/// # let mut hub = YouTubeAnalytics::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
1709/// // You can configure optional parameters by calling the respective setters at will, and
1710/// // execute the final call using `doit()`.
1711/// // Values shown here are possibly random and not representative !
1712/// let result = hub.group_items().list()
1713///              .on_behalf_of_content_owner("et")
1714///              .group_id("diam")
1715///              .doit();
1716/// # }
1717/// ```
1718pub struct GroupItemListCall<'a, C, A>
1719    where C: 'a, A: 'a {
1720
1721    hub: &'a YouTubeAnalytics<C, A>,
1722    _on_behalf_of_content_owner: Option<String>,
1723    _group_id: Option<String>,
1724    _delegate: Option<&'a mut Delegate>,
1725    _additional_params: HashMap<String, String>,
1726    _scopes: BTreeMap<String, ()>
1727}
1728
1729impl<'a, C, A> CallBuilder for GroupItemListCall<'a, C, A> {}
1730
1731impl<'a, C, A> GroupItemListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
1732
1733
1734    /// Perform the operation you have build so far.
1735    pub fn doit(mut self) -> Result<(hyper::client::Response, ListGroupItemsResponse)> {
1736        use std::io::{Read, Seek};
1737        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
1738        let mut dd = DefaultDelegate;
1739        let mut dlg: &mut Delegate = match self._delegate {
1740            Some(d) => d,
1741            None => &mut dd
1742        };
1743        dlg.begin(MethodInfo { id: "youtubeAnalytics.groupItems.list",
1744                               http_method: hyper::method::Method::Get });
1745        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
1746        if let Some(value) = self._on_behalf_of_content_owner {
1747            params.push(("onBehalfOfContentOwner", value.to_string()));
1748        }
1749        if let Some(value) = self._group_id {
1750            params.push(("groupId", value.to_string()));
1751        }
1752        for &field in ["alt", "onBehalfOfContentOwner", "groupId"].iter() {
1753            if self._additional_params.contains_key(field) {
1754                dlg.finished(false);
1755                return Err(Error::FieldClash(field));
1756            }
1757        }
1758        for (name, value) in self._additional_params.iter() {
1759            params.push((&name, value.clone()));
1760        }
1761
1762        params.push(("alt", "json".to_string()));
1763
1764        let mut url = self.hub._base_url.clone() + "v2/groupItems";
1765        if self._scopes.len() == 0 {
1766            self._scopes.insert(Scope::YoutubeReadonly.as_ref().to_string(), ());
1767        }
1768
1769
1770        if params.len() > 0 {
1771            url.push('?');
1772            url.push_str(&url::form_urlencoded::serialize(params));
1773        }
1774
1775
1776
1777        loop {
1778            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
1779                Ok(token) => token,
1780                Err(err) => {
1781                    match  dlg.token(&*err) {
1782                        Some(token) => token,
1783                        None => {
1784                            dlg.finished(false);
1785                            return Err(Error::MissingToken(err))
1786                        }
1787                    }
1788                }
1789            };
1790            let auth_header = Authorization(Bearer { token: token.access_token });
1791            let mut req_result = {
1792                let mut client = &mut *self.hub.client.borrow_mut();
1793                let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url)
1794                    .header(UserAgent(self.hub._user_agent.clone()))
1795                    .header(auth_header.clone());
1796
1797                dlg.pre_request();
1798                req.send()
1799            };
1800
1801            match req_result {
1802                Err(err) => {
1803                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
1804                        sleep(d);
1805                        continue;
1806                    }
1807                    dlg.finished(false);
1808                    return Err(Error::HttpError(err))
1809                }
1810                Ok(mut res) => {
1811                    if !res.status.is_success() {
1812                        let mut json_err = String::new();
1813                        res.read_to_string(&mut json_err).unwrap();
1814                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
1815                                                              json::from_str(&json_err).ok(),
1816                                                              json::from_str(&json_err).ok()) {
1817                            sleep(d);
1818                            continue;
1819                        }
1820                        dlg.finished(false);
1821                        return match json::from_str::<ErrorResponse>(&json_err){
1822                            Err(_) => Err(Error::Failure(res)),
1823                            Ok(serr) => Err(Error::BadRequest(serr))
1824                        }
1825                    }
1826                    let result_value = {
1827                        let mut json_response = String::new();
1828                        res.read_to_string(&mut json_response).unwrap();
1829                        match json::from_str(&json_response) {
1830                            Ok(decoded) => (res, decoded),
1831                            Err(err) => {
1832                                dlg.response_json_decode_error(&json_response, &err);
1833                                return Err(Error::JsonDecodeError(json_response, err));
1834                            }
1835                        }
1836                    };
1837
1838                    dlg.finished(true);
1839                    return Ok(result_value)
1840                }
1841            }
1842        }
1843    }
1844
1845
1846    /// This parameter can only be used in a properly authorized request. **Note:**
1847    /// This parameter is intended exclusively for YouTube content partners that
1848    /// own and manage many different YouTube channels.
1849    /// 
1850    /// The `onBehalfOfContentOwner` parameter indicates that the request's
1851    /// authorization credentials identify a YouTube user who is acting on behalf
1852    /// of the content owner specified in the parameter value. It allows content
1853    /// owners to authenticate once and get access to all their video and channel
1854    /// data, without having to provide authentication credentials for each
1855    /// individual channel. The account that the user authenticates with must be
1856    /// linked to the specified YouTube content owner.
1857    ///
1858    /// Sets the *on behalf of content owner* query property to the given value.
1859    pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> GroupItemListCall<'a, C, A> {
1860        self._on_behalf_of_content_owner = Some(new_value.to_string());
1861        self
1862    }
1863    /// The `groupId` parameter specifies the unique ID of the group for which you
1864    /// want to retrieve group items.
1865    ///
1866    /// Sets the *group id* query property to the given value.
1867    pub fn group_id(mut self, new_value: &str) -> GroupItemListCall<'a, C, A> {
1868        self._group_id = Some(new_value.to_string());
1869        self
1870    }
1871    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1872    /// while executing the actual API request.
1873    /// 
1874    /// It should be used to handle progress information, and to implement a certain level of resilience.
1875    ///
1876    /// Sets the *delegate* property to the given value.
1877    pub fn delegate(mut self, new_value: &'a mut Delegate) -> GroupItemListCall<'a, C, A> {
1878        self._delegate = Some(new_value);
1879        self
1880    }
1881
1882    /// Set any additional parameter of the query string used in the request.
1883    /// It should be used to set parameters which are not yet available through their own
1884    /// setters.
1885    ///
1886    /// Please note that this method must not be used to set any of the known paramters
1887    /// which have their own setter method. If done anyway, the request will fail.
1888    ///
1889    /// # Additional Parameters
1890    ///
1891    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1892    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1893    /// * *access_token* (query-string) - OAuth access token.
1894    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1895    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
1896    /// * *callback* (query-string) - JSONP
1897    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1898    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1899    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1900    /// * *alt* (query-string) - Data format for response.
1901    /// * *$.xgafv* (query-string) - V1 error format.
1902    pub fn param<T>(mut self, name: T, value: T) -> GroupItemListCall<'a, C, A>
1903                                                        where T: AsRef<str> {
1904        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
1905        self
1906    }
1907
1908    /// Identifies the authorization scope for the method you are building.
1909    ///
1910    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
1911    /// `Scope::YoutubeReadonly`.
1912    ///
1913    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1914    /// tokens for more than one scope.
1915    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
1916    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
1917    /// function for details).
1918    ///
1919    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1920    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1921    /// sufficient, a read-write scope will do as well.
1922    pub fn add_scope<T, S>(mut self, scope: T) -> GroupItemListCall<'a, C, A>
1923                                                        where T: Into<Option<S>>,
1924                                                              S: AsRef<str> {
1925        match scope.into() {
1926          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
1927          None => None,
1928        };
1929        self
1930    }
1931}
1932
1933
1934/// Removes an item from a group.
1935///
1936/// A builder for the *delete* method supported by a *groupItem* resource.
1937/// It is not used directly, but through a `GroupItemMethods` instance.
1938///
1939/// # Example
1940///
1941/// Instantiate a resource method builder
1942///
1943/// ```test_harness,no_run
1944/// # extern crate hyper;
1945/// # extern crate hyper_rustls;
1946/// # extern crate yup_oauth2 as oauth2;
1947/// # extern crate google_youtubeanalytics2 as youtubeanalytics2;
1948/// # #[test] fn egal() {
1949/// # use std::default::Default;
1950/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
1951/// # use youtubeanalytics2::YouTubeAnalytics;
1952/// 
1953/// # let secret: ApplicationSecret = Default::default();
1954/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
1955/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
1956/// #                               <MemoryStorage as Default>::default(), None);
1957/// # let mut hub = YouTubeAnalytics::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
1958/// // You can configure optional parameters by calling the respective setters at will, and
1959/// // execute the final call using `doit()`.
1960/// // Values shown here are possibly random and not representative !
1961/// let result = hub.group_items().delete()
1962///              .on_behalf_of_content_owner("ipsum")
1963///              .id("Lorem")
1964///              .doit();
1965/// # }
1966/// ```
1967pub struct GroupItemDeleteCall<'a, C, A>
1968    where C: 'a, A: 'a {
1969
1970    hub: &'a YouTubeAnalytics<C, A>,
1971    _on_behalf_of_content_owner: Option<String>,
1972    _id: Option<String>,
1973    _delegate: Option<&'a mut Delegate>,
1974    _additional_params: HashMap<String, String>,
1975    _scopes: BTreeMap<String, ()>
1976}
1977
1978impl<'a, C, A> CallBuilder for GroupItemDeleteCall<'a, C, A> {}
1979
1980impl<'a, C, A> GroupItemDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
1981
1982
1983    /// Perform the operation you have build so far.
1984    pub fn doit(mut self) -> Result<(hyper::client::Response, EmptyResponse)> {
1985        use std::io::{Read, Seek};
1986        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
1987        let mut dd = DefaultDelegate;
1988        let mut dlg: &mut Delegate = match self._delegate {
1989            Some(d) => d,
1990            None => &mut dd
1991        };
1992        dlg.begin(MethodInfo { id: "youtubeAnalytics.groupItems.delete",
1993                               http_method: hyper::method::Method::Delete });
1994        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
1995        if let Some(value) = self._on_behalf_of_content_owner {
1996            params.push(("onBehalfOfContentOwner", value.to_string()));
1997        }
1998        if let Some(value) = self._id {
1999            params.push(("id", value.to_string()));
2000        }
2001        for &field in ["alt", "onBehalfOfContentOwner", "id"].iter() {
2002            if self._additional_params.contains_key(field) {
2003                dlg.finished(false);
2004                return Err(Error::FieldClash(field));
2005            }
2006        }
2007        for (name, value) in self._additional_params.iter() {
2008            params.push((&name, value.clone()));
2009        }
2010
2011        params.push(("alt", "json".to_string()));
2012
2013        let mut url = self.hub._base_url.clone() + "v2/groupItems";
2014        if self._scopes.len() == 0 {
2015            self._scopes.insert(Scope::Youtube.as_ref().to_string(), ());
2016        }
2017
2018
2019        if params.len() > 0 {
2020            url.push('?');
2021            url.push_str(&url::form_urlencoded::serialize(params));
2022        }
2023
2024
2025
2026        loop {
2027            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
2028                Ok(token) => token,
2029                Err(err) => {
2030                    match  dlg.token(&*err) {
2031                        Some(token) => token,
2032                        None => {
2033                            dlg.finished(false);
2034                            return Err(Error::MissingToken(err))
2035                        }
2036                    }
2037                }
2038            };
2039            let auth_header = Authorization(Bearer { token: token.access_token });
2040            let mut req_result = {
2041                let mut client = &mut *self.hub.client.borrow_mut();
2042                let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url)
2043                    .header(UserAgent(self.hub._user_agent.clone()))
2044                    .header(auth_header.clone());
2045
2046                dlg.pre_request();
2047                req.send()
2048            };
2049
2050            match req_result {
2051                Err(err) => {
2052                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
2053                        sleep(d);
2054                        continue;
2055                    }
2056                    dlg.finished(false);
2057                    return Err(Error::HttpError(err))
2058                }
2059                Ok(mut res) => {
2060                    if !res.status.is_success() {
2061                        let mut json_err = String::new();
2062                        res.read_to_string(&mut json_err).unwrap();
2063                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
2064                                                              json::from_str(&json_err).ok(),
2065                                                              json::from_str(&json_err).ok()) {
2066                            sleep(d);
2067                            continue;
2068                        }
2069                        dlg.finished(false);
2070                        return match json::from_str::<ErrorResponse>(&json_err){
2071                            Err(_) => Err(Error::Failure(res)),
2072                            Ok(serr) => Err(Error::BadRequest(serr))
2073                        }
2074                    }
2075                    let result_value = {
2076                        let mut json_response = String::new();
2077                        res.read_to_string(&mut json_response).unwrap();
2078                        match json::from_str(&json_response) {
2079                            Ok(decoded) => (res, decoded),
2080                            Err(err) => {
2081                                dlg.response_json_decode_error(&json_response, &err);
2082                                return Err(Error::JsonDecodeError(json_response, err));
2083                            }
2084                        }
2085                    };
2086
2087                    dlg.finished(true);
2088                    return Ok(result_value)
2089                }
2090            }
2091        }
2092    }
2093
2094
2095    /// This parameter can only be used in a properly authorized request. **Note:**
2096    /// This parameter is intended exclusively for YouTube content partners that
2097    /// own and manage many different YouTube channels.
2098    /// 
2099    /// The `onBehalfOfContentOwner` parameter indicates that the request's
2100    /// authorization credentials identify a YouTube user who is acting on behalf
2101    /// of the content owner specified in the parameter value. It allows content
2102    /// owners to authenticate once and get access to all their video and channel
2103    /// data, without having to provide authentication credentials for each
2104    /// individual channel. The account that the user authenticates with must be
2105    /// linked to the specified YouTube content owner.
2106    ///
2107    /// Sets the *on behalf of content owner* query property to the given value.
2108    pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> GroupItemDeleteCall<'a, C, A> {
2109        self._on_behalf_of_content_owner = Some(new_value.to_string());
2110        self
2111    }
2112    /// The `id` parameter specifies the YouTube group item ID of the group item
2113    /// that is being deleted.
2114    ///
2115    /// Sets the *id* query property to the given value.
2116    pub fn id(mut self, new_value: &str) -> GroupItemDeleteCall<'a, C, A> {
2117        self._id = Some(new_value.to_string());
2118        self
2119    }
2120    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2121    /// while executing the actual API request.
2122    /// 
2123    /// It should be used to handle progress information, and to implement a certain level of resilience.
2124    ///
2125    /// Sets the *delegate* property to the given value.
2126    pub fn delegate(mut self, new_value: &'a mut Delegate) -> GroupItemDeleteCall<'a, C, A> {
2127        self._delegate = Some(new_value);
2128        self
2129    }
2130
2131    /// Set any additional parameter of the query string used in the request.
2132    /// It should be used to set parameters which are not yet available through their own
2133    /// setters.
2134    ///
2135    /// Please note that this method must not be used to set any of the known paramters
2136    /// which have their own setter method. If done anyway, the request will fail.
2137    ///
2138    /// # Additional Parameters
2139    ///
2140    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2141    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2142    /// * *access_token* (query-string) - OAuth access token.
2143    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2144    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2145    /// * *callback* (query-string) - JSONP
2146    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2147    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2148    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2149    /// * *alt* (query-string) - Data format for response.
2150    /// * *$.xgafv* (query-string) - V1 error format.
2151    pub fn param<T>(mut self, name: T, value: T) -> GroupItemDeleteCall<'a, C, A>
2152                                                        where T: AsRef<str> {
2153        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
2154        self
2155    }
2156
2157    /// Identifies the authorization scope for the method you are building.
2158    ///
2159    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
2160    /// `Scope::Youtube`.
2161    ///
2162    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2163    /// tokens for more than one scope.
2164    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
2165    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
2166    /// function for details).
2167    ///
2168    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2169    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2170    /// sufficient, a read-write scope will do as well.
2171    pub fn add_scope<T, S>(mut self, scope: T) -> GroupItemDeleteCall<'a, C, A>
2172                                                        where T: Into<Option<S>>,
2173                                                              S: AsRef<str> {
2174        match scope.into() {
2175          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
2176          None => None,
2177        };
2178        self
2179    }
2180}
2181
2182
2183/// Deletes a group.
2184///
2185/// A builder for the *delete* method supported by a *group* resource.
2186/// It is not used directly, but through a `GroupMethods` instance.
2187///
2188/// # Example
2189///
2190/// Instantiate a resource method builder
2191///
2192/// ```test_harness,no_run
2193/// # extern crate hyper;
2194/// # extern crate hyper_rustls;
2195/// # extern crate yup_oauth2 as oauth2;
2196/// # extern crate google_youtubeanalytics2 as youtubeanalytics2;
2197/// # #[test] fn egal() {
2198/// # use std::default::Default;
2199/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
2200/// # use youtubeanalytics2::YouTubeAnalytics;
2201/// 
2202/// # let secret: ApplicationSecret = Default::default();
2203/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
2204/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
2205/// #                               <MemoryStorage as Default>::default(), None);
2206/// # let mut hub = YouTubeAnalytics::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
2207/// // You can configure optional parameters by calling the respective setters at will, and
2208/// // execute the final call using `doit()`.
2209/// // Values shown here are possibly random and not representative !
2210/// let result = hub.groups().delete()
2211///              .on_behalf_of_content_owner("et")
2212///              .id("duo")
2213///              .doit();
2214/// # }
2215/// ```
2216pub struct GroupDeleteCall<'a, C, A>
2217    where C: 'a, A: 'a {
2218
2219    hub: &'a YouTubeAnalytics<C, A>,
2220    _on_behalf_of_content_owner: Option<String>,
2221    _id: Option<String>,
2222    _delegate: Option<&'a mut Delegate>,
2223    _additional_params: HashMap<String, String>,
2224    _scopes: BTreeMap<String, ()>
2225}
2226
2227impl<'a, C, A> CallBuilder for GroupDeleteCall<'a, C, A> {}
2228
2229impl<'a, C, A> GroupDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
2230
2231
2232    /// Perform the operation you have build so far.
2233    pub fn doit(mut self) -> Result<(hyper::client::Response, EmptyResponse)> {
2234        use std::io::{Read, Seek};
2235        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
2236        let mut dd = DefaultDelegate;
2237        let mut dlg: &mut Delegate = match self._delegate {
2238            Some(d) => d,
2239            None => &mut dd
2240        };
2241        dlg.begin(MethodInfo { id: "youtubeAnalytics.groups.delete",
2242                               http_method: hyper::method::Method::Delete });
2243        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
2244        if let Some(value) = self._on_behalf_of_content_owner {
2245            params.push(("onBehalfOfContentOwner", value.to_string()));
2246        }
2247        if let Some(value) = self._id {
2248            params.push(("id", value.to_string()));
2249        }
2250        for &field in ["alt", "onBehalfOfContentOwner", "id"].iter() {
2251            if self._additional_params.contains_key(field) {
2252                dlg.finished(false);
2253                return Err(Error::FieldClash(field));
2254            }
2255        }
2256        for (name, value) in self._additional_params.iter() {
2257            params.push((&name, value.clone()));
2258        }
2259
2260        params.push(("alt", "json".to_string()));
2261
2262        let mut url = self.hub._base_url.clone() + "v2/groups";
2263        if self._scopes.len() == 0 {
2264            self._scopes.insert(Scope::Youtube.as_ref().to_string(), ());
2265        }
2266
2267
2268        if params.len() > 0 {
2269            url.push('?');
2270            url.push_str(&url::form_urlencoded::serialize(params));
2271        }
2272
2273
2274
2275        loop {
2276            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
2277                Ok(token) => token,
2278                Err(err) => {
2279                    match  dlg.token(&*err) {
2280                        Some(token) => token,
2281                        None => {
2282                            dlg.finished(false);
2283                            return Err(Error::MissingToken(err))
2284                        }
2285                    }
2286                }
2287            };
2288            let auth_header = Authorization(Bearer { token: token.access_token });
2289            let mut req_result = {
2290                let mut client = &mut *self.hub.client.borrow_mut();
2291                let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url)
2292                    .header(UserAgent(self.hub._user_agent.clone()))
2293                    .header(auth_header.clone());
2294
2295                dlg.pre_request();
2296                req.send()
2297            };
2298
2299            match req_result {
2300                Err(err) => {
2301                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
2302                        sleep(d);
2303                        continue;
2304                    }
2305                    dlg.finished(false);
2306                    return Err(Error::HttpError(err))
2307                }
2308                Ok(mut res) => {
2309                    if !res.status.is_success() {
2310                        let mut json_err = String::new();
2311                        res.read_to_string(&mut json_err).unwrap();
2312                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
2313                                                              json::from_str(&json_err).ok(),
2314                                                              json::from_str(&json_err).ok()) {
2315                            sleep(d);
2316                            continue;
2317                        }
2318                        dlg.finished(false);
2319                        return match json::from_str::<ErrorResponse>(&json_err){
2320                            Err(_) => Err(Error::Failure(res)),
2321                            Ok(serr) => Err(Error::BadRequest(serr))
2322                        }
2323                    }
2324                    let result_value = {
2325                        let mut json_response = String::new();
2326                        res.read_to_string(&mut json_response).unwrap();
2327                        match json::from_str(&json_response) {
2328                            Ok(decoded) => (res, decoded),
2329                            Err(err) => {
2330                                dlg.response_json_decode_error(&json_response, &err);
2331                                return Err(Error::JsonDecodeError(json_response, err));
2332                            }
2333                        }
2334                    };
2335
2336                    dlg.finished(true);
2337                    return Ok(result_value)
2338                }
2339            }
2340        }
2341    }
2342
2343
2344    /// This parameter can only be used in a properly authorized request. **Note:**
2345    /// This parameter is intended exclusively for YouTube content partners that
2346    /// own and manage many different YouTube channels.
2347    /// 
2348    /// The `onBehalfOfContentOwner` parameter indicates that the request's
2349    /// authorization credentials identify a YouTube user who is acting on behalf
2350    /// of the content owner specified in the parameter value. It allows content
2351    /// owners to authenticate once and get access to all their video and channel
2352    /// data, without having to provide authentication credentials for each
2353    /// individual channel. The account that the user authenticates with must be
2354    /// linked to the specified YouTube content owner.
2355    ///
2356    /// Sets the *on behalf of content owner* query property to the given value.
2357    pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> GroupDeleteCall<'a, C, A> {
2358        self._on_behalf_of_content_owner = Some(new_value.to_string());
2359        self
2360    }
2361    /// The `id` parameter specifies the YouTube group ID of the group that is
2362    /// being deleted.
2363    ///
2364    /// Sets the *id* query property to the given value.
2365    pub fn id(mut self, new_value: &str) -> GroupDeleteCall<'a, C, A> {
2366        self._id = Some(new_value.to_string());
2367        self
2368    }
2369    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2370    /// while executing the actual API request.
2371    /// 
2372    /// It should be used to handle progress information, and to implement a certain level of resilience.
2373    ///
2374    /// Sets the *delegate* property to the given value.
2375    pub fn delegate(mut self, new_value: &'a mut Delegate) -> GroupDeleteCall<'a, C, A> {
2376        self._delegate = Some(new_value);
2377        self
2378    }
2379
2380    /// Set any additional parameter of the query string used in the request.
2381    /// It should be used to set parameters which are not yet available through their own
2382    /// setters.
2383    ///
2384    /// Please note that this method must not be used to set any of the known paramters
2385    /// which have their own setter method. If done anyway, the request will fail.
2386    ///
2387    /// # Additional Parameters
2388    ///
2389    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2390    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2391    /// * *access_token* (query-string) - OAuth access token.
2392    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2393    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2394    /// * *callback* (query-string) - JSONP
2395    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2396    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2397    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2398    /// * *alt* (query-string) - Data format for response.
2399    /// * *$.xgafv* (query-string) - V1 error format.
2400    pub fn param<T>(mut self, name: T, value: T) -> GroupDeleteCall<'a, C, A>
2401                                                        where T: AsRef<str> {
2402        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
2403        self
2404    }
2405
2406    /// Identifies the authorization scope for the method you are building.
2407    ///
2408    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
2409    /// `Scope::Youtube`.
2410    ///
2411    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2412    /// tokens for more than one scope.
2413    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
2414    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
2415    /// function for details).
2416    ///
2417    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2418    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2419    /// sufficient, a read-write scope will do as well.
2420    pub fn add_scope<T, S>(mut self, scope: T) -> GroupDeleteCall<'a, C, A>
2421                                                        where T: Into<Option<S>>,
2422                                                              S: AsRef<str> {
2423        match scope.into() {
2424          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
2425          None => None,
2426        };
2427        self
2428    }
2429}
2430
2431
2432/// Creates a group.
2433///
2434/// A builder for the *insert* method supported by a *group* resource.
2435/// It is not used directly, but through a `GroupMethods` instance.
2436///
2437/// # Example
2438///
2439/// Instantiate a resource method builder
2440///
2441/// ```test_harness,no_run
2442/// # extern crate hyper;
2443/// # extern crate hyper_rustls;
2444/// # extern crate yup_oauth2 as oauth2;
2445/// # extern crate google_youtubeanalytics2 as youtubeanalytics2;
2446/// use youtubeanalytics2::Group;
2447/// # #[test] fn egal() {
2448/// # use std::default::Default;
2449/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
2450/// # use youtubeanalytics2::YouTubeAnalytics;
2451/// 
2452/// # let secret: ApplicationSecret = Default::default();
2453/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
2454/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
2455/// #                               <MemoryStorage as Default>::default(), None);
2456/// # let mut hub = YouTubeAnalytics::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
2457/// // As the method needs a request, you would usually fill it with the desired information
2458/// // into the respective structure. Some of the parts shown here might not be applicable !
2459/// // Values shown here are possibly random and not representative !
2460/// let mut req = Group::default();
2461/// 
2462/// // You can configure optional parameters by calling the respective setters at will, and
2463/// // execute the final call using `doit()`.
2464/// // Values shown here are possibly random and not representative !
2465/// let result = hub.groups().insert(req)
2466///              .on_behalf_of_content_owner("aliquyam")
2467///              .doit();
2468/// # }
2469/// ```
2470pub struct GroupInsertCall<'a, C, A>
2471    where C: 'a, A: 'a {
2472
2473    hub: &'a YouTubeAnalytics<C, A>,
2474    _request: Group,
2475    _on_behalf_of_content_owner: Option<String>,
2476    _delegate: Option<&'a mut Delegate>,
2477    _additional_params: HashMap<String, String>,
2478    _scopes: BTreeMap<String, ()>
2479}
2480
2481impl<'a, C, A> CallBuilder for GroupInsertCall<'a, C, A> {}
2482
2483impl<'a, C, A> GroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
2484
2485
2486    /// Perform the operation you have build so far.
2487    pub fn doit(mut self) -> Result<(hyper::client::Response, Group)> {
2488        use std::io::{Read, Seek};
2489        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
2490        let mut dd = DefaultDelegate;
2491        let mut dlg: &mut Delegate = match self._delegate {
2492            Some(d) => d,
2493            None => &mut dd
2494        };
2495        dlg.begin(MethodInfo { id: "youtubeAnalytics.groups.insert",
2496                               http_method: hyper::method::Method::Post });
2497        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
2498        if let Some(value) = self._on_behalf_of_content_owner {
2499            params.push(("onBehalfOfContentOwner", value.to_string()));
2500        }
2501        for &field in ["alt", "onBehalfOfContentOwner"].iter() {
2502            if self._additional_params.contains_key(field) {
2503                dlg.finished(false);
2504                return Err(Error::FieldClash(field));
2505            }
2506        }
2507        for (name, value) in self._additional_params.iter() {
2508            params.push((&name, value.clone()));
2509        }
2510
2511        params.push(("alt", "json".to_string()));
2512
2513        let mut url = self.hub._base_url.clone() + "v2/groups";
2514        if self._scopes.len() == 0 {
2515            self._scopes.insert(Scope::Youtube.as_ref().to_string(), ());
2516        }
2517
2518
2519        if params.len() > 0 {
2520            url.push('?');
2521            url.push_str(&url::form_urlencoded::serialize(params));
2522        }
2523
2524        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
2525        let mut request_value_reader =
2526            {
2527                let mut value = json::value::to_value(&self._request).expect("serde to work");
2528                remove_json_null_values(&mut value);
2529                let mut dst = io::Cursor::new(Vec::with_capacity(128));
2530                json::to_writer(&mut dst, &value).unwrap();
2531                dst
2532            };
2533        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
2534        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
2535
2536
2537        loop {
2538            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
2539                Ok(token) => token,
2540                Err(err) => {
2541                    match  dlg.token(&*err) {
2542                        Some(token) => token,
2543                        None => {
2544                            dlg.finished(false);
2545                            return Err(Error::MissingToken(err))
2546                        }
2547                    }
2548                }
2549            };
2550            let auth_header = Authorization(Bearer { token: token.access_token });
2551            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
2552            let mut req_result = {
2553                let mut client = &mut *self.hub.client.borrow_mut();
2554                let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url)
2555                    .header(UserAgent(self.hub._user_agent.clone()))
2556                    .header(auth_header.clone())
2557                    .header(ContentType(json_mime_type.clone()))
2558                    .header(ContentLength(request_size as u64))
2559                    .body(&mut request_value_reader);
2560
2561                dlg.pre_request();
2562                req.send()
2563            };
2564
2565            match req_result {
2566                Err(err) => {
2567                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
2568                        sleep(d);
2569                        continue;
2570                    }
2571                    dlg.finished(false);
2572                    return Err(Error::HttpError(err))
2573                }
2574                Ok(mut res) => {
2575                    if !res.status.is_success() {
2576                        let mut json_err = String::new();
2577                        res.read_to_string(&mut json_err).unwrap();
2578                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
2579                                                              json::from_str(&json_err).ok(),
2580                                                              json::from_str(&json_err).ok()) {
2581                            sleep(d);
2582                            continue;
2583                        }
2584                        dlg.finished(false);
2585                        return match json::from_str::<ErrorResponse>(&json_err){
2586                            Err(_) => Err(Error::Failure(res)),
2587                            Ok(serr) => Err(Error::BadRequest(serr))
2588                        }
2589                    }
2590                    let result_value = {
2591                        let mut json_response = String::new();
2592                        res.read_to_string(&mut json_response).unwrap();
2593                        match json::from_str(&json_response) {
2594                            Ok(decoded) => (res, decoded),
2595                            Err(err) => {
2596                                dlg.response_json_decode_error(&json_response, &err);
2597                                return Err(Error::JsonDecodeError(json_response, err));
2598                            }
2599                        }
2600                    };
2601
2602                    dlg.finished(true);
2603                    return Ok(result_value)
2604                }
2605            }
2606        }
2607    }
2608
2609
2610    ///
2611    /// Sets the *request* property to the given value.
2612    ///
2613    /// Even though the property as already been set when instantiating this call,
2614    /// we provide this method for API completeness.
2615    pub fn request(mut self, new_value: Group) -> GroupInsertCall<'a, C, A> {
2616        self._request = new_value;
2617        self
2618    }
2619    /// This parameter can only be used in a properly authorized request. **Note:**
2620    /// This parameter is intended exclusively for YouTube content partners that
2621    /// own and manage many different YouTube channels.
2622    /// 
2623    /// The `onBehalfOfContentOwner` parameter indicates that the request's
2624    /// authorization credentials identify a YouTube user who is acting on behalf
2625    /// of the content owner specified in the parameter value. It allows content
2626    /// owners to authenticate once and get access to all their video and channel
2627    /// data, without having to provide authentication credentials for each
2628    /// individual channel. The account that the user authenticates with must be
2629    /// linked to the specified YouTube content owner.
2630    ///
2631    /// Sets the *on behalf of content owner* query property to the given value.
2632    pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> GroupInsertCall<'a, C, A> {
2633        self._on_behalf_of_content_owner = Some(new_value.to_string());
2634        self
2635    }
2636    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2637    /// while executing the actual API request.
2638    /// 
2639    /// It should be used to handle progress information, and to implement a certain level of resilience.
2640    ///
2641    /// Sets the *delegate* property to the given value.
2642    pub fn delegate(mut self, new_value: &'a mut Delegate) -> GroupInsertCall<'a, C, A> {
2643        self._delegate = Some(new_value);
2644        self
2645    }
2646
2647    /// Set any additional parameter of the query string used in the request.
2648    /// It should be used to set parameters which are not yet available through their own
2649    /// setters.
2650    ///
2651    /// Please note that this method must not be used to set any of the known paramters
2652    /// which have their own setter method. If done anyway, the request will fail.
2653    ///
2654    /// # Additional Parameters
2655    ///
2656    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2657    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2658    /// * *access_token* (query-string) - OAuth access token.
2659    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2660    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2661    /// * *callback* (query-string) - JSONP
2662    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2663    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2664    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2665    /// * *alt* (query-string) - Data format for response.
2666    /// * *$.xgafv* (query-string) - V1 error format.
2667    pub fn param<T>(mut self, name: T, value: T) -> GroupInsertCall<'a, C, A>
2668                                                        where T: AsRef<str> {
2669        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
2670        self
2671    }
2672
2673    /// Identifies the authorization scope for the method you are building.
2674    ///
2675    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
2676    /// `Scope::Youtube`.
2677    ///
2678    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2679    /// tokens for more than one scope.
2680    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
2681    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
2682    /// function for details).
2683    ///
2684    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2685    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2686    /// sufficient, a read-write scope will do as well.
2687    pub fn add_scope<T, S>(mut self, scope: T) -> GroupInsertCall<'a, C, A>
2688                                                        where T: Into<Option<S>>,
2689                                                              S: AsRef<str> {
2690        match scope.into() {
2691          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
2692          None => None,
2693        };
2694        self
2695    }
2696}
2697
2698
2699/// Returns a collection of groups that match the API request parameters. For
2700/// example, you can retrieve all groups that the authenticated user owns,
2701/// or you can retrieve one or more groups by their unique IDs.
2702///
2703/// A builder for the *list* method supported by a *group* resource.
2704/// It is not used directly, but through a `GroupMethods` instance.
2705///
2706/// # Example
2707///
2708/// Instantiate a resource method builder
2709///
2710/// ```test_harness,no_run
2711/// # extern crate hyper;
2712/// # extern crate hyper_rustls;
2713/// # extern crate yup_oauth2 as oauth2;
2714/// # extern crate google_youtubeanalytics2 as youtubeanalytics2;
2715/// # #[test] fn egal() {
2716/// # use std::default::Default;
2717/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
2718/// # use youtubeanalytics2::YouTubeAnalytics;
2719/// 
2720/// # let secret: ApplicationSecret = Default::default();
2721/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
2722/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
2723/// #                               <MemoryStorage as Default>::default(), None);
2724/// # let mut hub = YouTubeAnalytics::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
2725/// // You can configure optional parameters by calling the respective setters at will, and
2726/// // execute the final call using `doit()`.
2727/// // Values shown here are possibly random and not representative !
2728/// let result = hub.groups().list()
2729///              .page_token("sea")
2730///              .on_behalf_of_content_owner("Lorem")
2731///              .mine(false)
2732///              .id("erat")
2733///              .doit();
2734/// # }
2735/// ```
2736pub struct GroupListCall<'a, C, A>
2737    where C: 'a, A: 'a {
2738
2739    hub: &'a YouTubeAnalytics<C, A>,
2740    _page_token: Option<String>,
2741    _on_behalf_of_content_owner: Option<String>,
2742    _mine: Option<bool>,
2743    _id: Option<String>,
2744    _delegate: Option<&'a mut Delegate>,
2745    _additional_params: HashMap<String, String>,
2746    _scopes: BTreeMap<String, ()>
2747}
2748
2749impl<'a, C, A> CallBuilder for GroupListCall<'a, C, A> {}
2750
2751impl<'a, C, A> GroupListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
2752
2753
2754    /// Perform the operation you have build so far.
2755    pub fn doit(mut self) -> Result<(hyper::client::Response, ListGroupsResponse)> {
2756        use std::io::{Read, Seek};
2757        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
2758        let mut dd = DefaultDelegate;
2759        let mut dlg: &mut Delegate = match self._delegate {
2760            Some(d) => d,
2761            None => &mut dd
2762        };
2763        dlg.begin(MethodInfo { id: "youtubeAnalytics.groups.list",
2764                               http_method: hyper::method::Method::Get });
2765        let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len());
2766        if let Some(value) = self._page_token {
2767            params.push(("pageToken", value.to_string()));
2768        }
2769        if let Some(value) = self._on_behalf_of_content_owner {
2770            params.push(("onBehalfOfContentOwner", value.to_string()));
2771        }
2772        if let Some(value) = self._mine {
2773            params.push(("mine", value.to_string()));
2774        }
2775        if let Some(value) = self._id {
2776            params.push(("id", value.to_string()));
2777        }
2778        for &field in ["alt", "pageToken", "onBehalfOfContentOwner", "mine", "id"].iter() {
2779            if self._additional_params.contains_key(field) {
2780                dlg.finished(false);
2781                return Err(Error::FieldClash(field));
2782            }
2783        }
2784        for (name, value) in self._additional_params.iter() {
2785            params.push((&name, value.clone()));
2786        }
2787
2788        params.push(("alt", "json".to_string()));
2789
2790        let mut url = self.hub._base_url.clone() + "v2/groups";
2791        if self._scopes.len() == 0 {
2792            self._scopes.insert(Scope::YoutubeReadonly.as_ref().to_string(), ());
2793        }
2794
2795
2796        if params.len() > 0 {
2797            url.push('?');
2798            url.push_str(&url::form_urlencoded::serialize(params));
2799        }
2800
2801
2802
2803        loop {
2804            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
2805                Ok(token) => token,
2806                Err(err) => {
2807                    match  dlg.token(&*err) {
2808                        Some(token) => token,
2809                        None => {
2810                            dlg.finished(false);
2811                            return Err(Error::MissingToken(err))
2812                        }
2813                    }
2814                }
2815            };
2816            let auth_header = Authorization(Bearer { token: token.access_token });
2817            let mut req_result = {
2818                let mut client = &mut *self.hub.client.borrow_mut();
2819                let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url)
2820                    .header(UserAgent(self.hub._user_agent.clone()))
2821                    .header(auth_header.clone());
2822
2823                dlg.pre_request();
2824                req.send()
2825            };
2826
2827            match req_result {
2828                Err(err) => {
2829                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
2830                        sleep(d);
2831                        continue;
2832                    }
2833                    dlg.finished(false);
2834                    return Err(Error::HttpError(err))
2835                }
2836                Ok(mut res) => {
2837                    if !res.status.is_success() {
2838                        let mut json_err = String::new();
2839                        res.read_to_string(&mut json_err).unwrap();
2840                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
2841                                                              json::from_str(&json_err).ok(),
2842                                                              json::from_str(&json_err).ok()) {
2843                            sleep(d);
2844                            continue;
2845                        }
2846                        dlg.finished(false);
2847                        return match json::from_str::<ErrorResponse>(&json_err){
2848                            Err(_) => Err(Error::Failure(res)),
2849                            Ok(serr) => Err(Error::BadRequest(serr))
2850                        }
2851                    }
2852                    let result_value = {
2853                        let mut json_response = String::new();
2854                        res.read_to_string(&mut json_response).unwrap();
2855                        match json::from_str(&json_response) {
2856                            Ok(decoded) => (res, decoded),
2857                            Err(err) => {
2858                                dlg.response_json_decode_error(&json_response, &err);
2859                                return Err(Error::JsonDecodeError(json_response, err));
2860                            }
2861                        }
2862                    };
2863
2864                    dlg.finished(true);
2865                    return Ok(result_value)
2866                }
2867            }
2868        }
2869    }
2870
2871
2872    /// The `pageToken` parameter identifies a specific page in the result set that
2873    /// should be returned. In an API response, the `nextPageToken` property
2874    /// identifies the next page that can be retrieved.
2875    ///
2876    /// Sets the *page token* query property to the given value.
2877    pub fn page_token(mut self, new_value: &str) -> GroupListCall<'a, C, A> {
2878        self._page_token = Some(new_value.to_string());
2879        self
2880    }
2881    /// This parameter can only be used in a properly authorized request. **Note:**
2882    /// This parameter is intended exclusively for YouTube content partners that
2883    /// own and manage many different YouTube channels.
2884    /// 
2885    /// The `onBehalfOfContentOwner` parameter indicates that the request's
2886    /// authorization credentials identify a YouTube user who is acting on behalf
2887    /// of the content owner specified in the parameter value. It allows content
2888    /// owners to authenticate once and get access to all their video and channel
2889    /// data, without having to provide authentication credentials for each
2890    /// individual channel. The account that the user authenticates with must be
2891    /// linked to the specified YouTube content owner.
2892    ///
2893    /// Sets the *on behalf of content owner* query property to the given value.
2894    pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> GroupListCall<'a, C, A> {
2895        self._on_behalf_of_content_owner = Some(new_value.to_string());
2896        self
2897    }
2898    /// This parameter can only be used in a properly authorized request. Set this
2899    /// parameter's value to true to retrieve all groups owned by the authenticated
2900    /// user.
2901    ///
2902    /// Sets the *mine* query property to the given value.
2903    pub fn mine(mut self, new_value: bool) -> GroupListCall<'a, C, A> {
2904        self._mine = Some(new_value);
2905        self
2906    }
2907    /// The `id` parameter specifies a comma-separated list of the YouTube group
2908    /// ID(s) for the resource(s) that are being retrieved. Each group must be
2909    /// owned by the authenticated user. In a `group` resource, the `id` property
2910    /// specifies the group's YouTube group ID.
2911    /// 
2912    /// Note that if you do not specify a value for the `id` parameter, then you
2913    /// must set the `mine` parameter to `true`.
2914    ///
2915    /// Sets the *id* query property to the given value.
2916    pub fn id(mut self, new_value: &str) -> GroupListCall<'a, C, A> {
2917        self._id = Some(new_value.to_string());
2918        self
2919    }
2920    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2921    /// while executing the actual API request.
2922    /// 
2923    /// It should be used to handle progress information, and to implement a certain level of resilience.
2924    ///
2925    /// Sets the *delegate* property to the given value.
2926    pub fn delegate(mut self, new_value: &'a mut Delegate) -> GroupListCall<'a, C, A> {
2927        self._delegate = Some(new_value);
2928        self
2929    }
2930
2931    /// Set any additional parameter of the query string used in the request.
2932    /// It should be used to set parameters which are not yet available through their own
2933    /// setters.
2934    ///
2935    /// Please note that this method must not be used to set any of the known paramters
2936    /// which have their own setter method. If done anyway, the request will fail.
2937    ///
2938    /// # Additional Parameters
2939    ///
2940    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2941    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2942    /// * *access_token* (query-string) - OAuth access token.
2943    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2944    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2945    /// * *callback* (query-string) - JSONP
2946    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2947    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2948    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2949    /// * *alt* (query-string) - Data format for response.
2950    /// * *$.xgafv* (query-string) - V1 error format.
2951    pub fn param<T>(mut self, name: T, value: T) -> GroupListCall<'a, C, A>
2952                                                        where T: AsRef<str> {
2953        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
2954        self
2955    }
2956
2957    /// Identifies the authorization scope for the method you are building.
2958    ///
2959    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
2960    /// `Scope::YoutubeReadonly`.
2961    ///
2962    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2963    /// tokens for more than one scope.
2964    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
2965    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
2966    /// function for details).
2967    ///
2968    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2969    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2970    /// sufficient, a read-write scope will do as well.
2971    pub fn add_scope<T, S>(mut self, scope: T) -> GroupListCall<'a, C, A>
2972                                                        where T: Into<Option<S>>,
2973                                                              S: AsRef<str> {
2974        match scope.into() {
2975          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
2976          None => None,
2977        };
2978        self
2979    }
2980}
2981
2982
2983/// Modifies a group. For example, you could change a group's title.
2984///
2985/// A builder for the *update* method supported by a *group* resource.
2986/// It is not used directly, but through a `GroupMethods` instance.
2987///
2988/// # Example
2989///
2990/// Instantiate a resource method builder
2991///
2992/// ```test_harness,no_run
2993/// # extern crate hyper;
2994/// # extern crate hyper_rustls;
2995/// # extern crate yup_oauth2 as oauth2;
2996/// # extern crate google_youtubeanalytics2 as youtubeanalytics2;
2997/// use youtubeanalytics2::Group;
2998/// # #[test] fn egal() {
2999/// # use std::default::Default;
3000/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
3001/// # use youtubeanalytics2::YouTubeAnalytics;
3002/// 
3003/// # let secret: ApplicationSecret = Default::default();
3004/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
3005/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
3006/// #                               <MemoryStorage as Default>::default(), None);
3007/// # let mut hub = YouTubeAnalytics::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
3008/// // As the method needs a request, you would usually fill it with the desired information
3009/// // into the respective structure. Some of the parts shown here might not be applicable !
3010/// // Values shown here are possibly random and not representative !
3011/// let mut req = Group::default();
3012/// 
3013/// // You can configure optional parameters by calling the respective setters at will, and
3014/// // execute the final call using `doit()`.
3015/// // Values shown here are possibly random and not representative !
3016/// let result = hub.groups().update(req)
3017///              .on_behalf_of_content_owner("sadipscing")
3018///              .doit();
3019/// # }
3020/// ```
3021pub struct GroupUpdateCall<'a, C, A>
3022    where C: 'a, A: 'a {
3023
3024    hub: &'a YouTubeAnalytics<C, A>,
3025    _request: Group,
3026    _on_behalf_of_content_owner: Option<String>,
3027    _delegate: Option<&'a mut Delegate>,
3028    _additional_params: HashMap<String, String>,
3029    _scopes: BTreeMap<String, ()>
3030}
3031
3032impl<'a, C, A> CallBuilder for GroupUpdateCall<'a, C, A> {}
3033
3034impl<'a, C, A> GroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
3035
3036
3037    /// Perform the operation you have build so far.
3038    pub fn doit(mut self) -> Result<(hyper::client::Response, Group)> {
3039        use std::io::{Read, Seek};
3040        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
3041        let mut dd = DefaultDelegate;
3042        let mut dlg: &mut Delegate = match self._delegate {
3043            Some(d) => d,
3044            None => &mut dd
3045        };
3046        dlg.begin(MethodInfo { id: "youtubeAnalytics.groups.update",
3047                               http_method: hyper::method::Method::Put });
3048        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
3049        if let Some(value) = self._on_behalf_of_content_owner {
3050            params.push(("onBehalfOfContentOwner", value.to_string()));
3051        }
3052        for &field in ["alt", "onBehalfOfContentOwner"].iter() {
3053            if self._additional_params.contains_key(field) {
3054                dlg.finished(false);
3055                return Err(Error::FieldClash(field));
3056            }
3057        }
3058        for (name, value) in self._additional_params.iter() {
3059            params.push((&name, value.clone()));
3060        }
3061
3062        params.push(("alt", "json".to_string()));
3063
3064        let mut url = self.hub._base_url.clone() + "v2/groups";
3065        if self._scopes.len() == 0 {
3066            self._scopes.insert(Scope::Youtube.as_ref().to_string(), ());
3067        }
3068
3069
3070        if params.len() > 0 {
3071            url.push('?');
3072            url.push_str(&url::form_urlencoded::serialize(params));
3073        }
3074
3075        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
3076        let mut request_value_reader =
3077            {
3078                let mut value = json::value::to_value(&self._request).expect("serde to work");
3079                remove_json_null_values(&mut value);
3080                let mut dst = io::Cursor::new(Vec::with_capacity(128));
3081                json::to_writer(&mut dst, &value).unwrap();
3082                dst
3083            };
3084        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
3085        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
3086
3087
3088        loop {
3089            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
3090                Ok(token) => token,
3091                Err(err) => {
3092                    match  dlg.token(&*err) {
3093                        Some(token) => token,
3094                        None => {
3095                            dlg.finished(false);
3096                            return Err(Error::MissingToken(err))
3097                        }
3098                    }
3099                }
3100            };
3101            let auth_header = Authorization(Bearer { token: token.access_token });
3102            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
3103            let mut req_result = {
3104                let mut client = &mut *self.hub.client.borrow_mut();
3105                let mut req = client.borrow_mut().request(hyper::method::Method::Put, &url)
3106                    .header(UserAgent(self.hub._user_agent.clone()))
3107                    .header(auth_header.clone())
3108                    .header(ContentType(json_mime_type.clone()))
3109                    .header(ContentLength(request_size as u64))
3110                    .body(&mut request_value_reader);
3111
3112                dlg.pre_request();
3113                req.send()
3114            };
3115
3116            match req_result {
3117                Err(err) => {
3118                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
3119                        sleep(d);
3120                        continue;
3121                    }
3122                    dlg.finished(false);
3123                    return Err(Error::HttpError(err))
3124                }
3125                Ok(mut res) => {
3126                    if !res.status.is_success() {
3127                        let mut json_err = String::new();
3128                        res.read_to_string(&mut json_err).unwrap();
3129                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
3130                                                              json::from_str(&json_err).ok(),
3131                                                              json::from_str(&json_err).ok()) {
3132                            sleep(d);
3133                            continue;
3134                        }
3135                        dlg.finished(false);
3136                        return match json::from_str::<ErrorResponse>(&json_err){
3137                            Err(_) => Err(Error::Failure(res)),
3138                            Ok(serr) => Err(Error::BadRequest(serr))
3139                        }
3140                    }
3141                    let result_value = {
3142                        let mut json_response = String::new();
3143                        res.read_to_string(&mut json_response).unwrap();
3144                        match json::from_str(&json_response) {
3145                            Ok(decoded) => (res, decoded),
3146                            Err(err) => {
3147                                dlg.response_json_decode_error(&json_response, &err);
3148                                return Err(Error::JsonDecodeError(json_response, err));
3149                            }
3150                        }
3151                    };
3152
3153                    dlg.finished(true);
3154                    return Ok(result_value)
3155                }
3156            }
3157        }
3158    }
3159
3160
3161    ///
3162    /// Sets the *request* property to the given value.
3163    ///
3164    /// Even though the property as already been set when instantiating this call,
3165    /// we provide this method for API completeness.
3166    pub fn request(mut self, new_value: Group) -> GroupUpdateCall<'a, C, A> {
3167        self._request = new_value;
3168        self
3169    }
3170    /// This parameter can only be used in a properly authorized request. **Note:**
3171    /// This parameter is intended exclusively for YouTube content partners that
3172    /// own and manage many different YouTube channels.
3173    /// 
3174    /// The `onBehalfOfContentOwner` parameter indicates that the request's
3175    /// authorization credentials identify a YouTube user who is acting on behalf
3176    /// of the content owner specified in the parameter value. It allows content
3177    /// owners to authenticate once and get access to all their video and channel
3178    /// data, without having to provide authentication credentials for each
3179    /// individual channel. The account that the user authenticates with must be
3180    /// linked to the specified YouTube content owner.
3181    ///
3182    /// Sets the *on behalf of content owner* query property to the given value.
3183    pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> GroupUpdateCall<'a, C, A> {
3184        self._on_behalf_of_content_owner = Some(new_value.to_string());
3185        self
3186    }
3187    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3188    /// while executing the actual API request.
3189    /// 
3190    /// It should be used to handle progress information, and to implement a certain level of resilience.
3191    ///
3192    /// Sets the *delegate* property to the given value.
3193    pub fn delegate(mut self, new_value: &'a mut Delegate) -> GroupUpdateCall<'a, C, A> {
3194        self._delegate = Some(new_value);
3195        self
3196    }
3197
3198    /// Set any additional parameter of the query string used in the request.
3199    /// It should be used to set parameters which are not yet available through their own
3200    /// setters.
3201    ///
3202    /// Please note that this method must not be used to set any of the known paramters
3203    /// which have their own setter method. If done anyway, the request will fail.
3204    ///
3205    /// # Additional Parameters
3206    ///
3207    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3208    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3209    /// * *access_token* (query-string) - OAuth access token.
3210    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3211    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3212    /// * *callback* (query-string) - JSONP
3213    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3214    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3215    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3216    /// * *alt* (query-string) - Data format for response.
3217    /// * *$.xgafv* (query-string) - V1 error format.
3218    pub fn param<T>(mut self, name: T, value: T) -> GroupUpdateCall<'a, C, A>
3219                                                        where T: AsRef<str> {
3220        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
3221        self
3222    }
3223
3224    /// Identifies the authorization scope for the method you are building.
3225    ///
3226    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
3227    /// `Scope::Youtube`.
3228    ///
3229    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3230    /// tokens for more than one scope.
3231    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
3232    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
3233    /// function for details).
3234    ///
3235    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3236    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3237    /// sufficient, a read-write scope will do as well.
3238    pub fn add_scope<T, S>(mut self, scope: T) -> GroupUpdateCall<'a, C, A>
3239                                                        where T: Into<Option<S>>,
3240                                                              S: AsRef<str> {
3241        match scope.into() {
3242          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
3243          None => None,
3244        };
3245        self
3246    }
3247}
3248
3249