diff --git a/gen/youtube3/src/cmn.rs b/gen/youtube3/src/cmn.rs index e01b37058d6..aacb052ea5b 100644 --- a/gen/youtube3/src/cmn.rs +++ b/gen/youtube3/src/cmn.rs @@ -42,7 +42,7 @@ impl ReadSeek for T {} /// A utility type which can decode a server response that indicates error #[derive(RustcDecodable)] -struct JsonServerError { +pub struct JsonServerError { error: String, error_description: Option } @@ -68,6 +68,22 @@ pub trait Delegate { fn api_key(&mut self) -> Option { None } + + /// Called whenever the Authenticator didn't yield a token. The delegate + /// may attempt to provide one, or just take is a general information about the + /// pending impending failure + fn token(&mut self) -> Option { + None + } + + /// Called whenever the http request returns with a non-success status code. + /// This can involve authentication issues, or anything else that very much + /// depends on the used API method. + /// The delegate should check the status, header and decoded json error to decide + /// whether to retry or not. In the latter case, the underlying call will fail. + fn http_failure(&mut self, _: &hyper::client::Response, JsonServerError) -> oauth2::Retry { + oauth2::Retry::Abort + } } #[derive(Default)] @@ -91,6 +107,9 @@ pub enum Result { /// An additional, free form field clashed with one of the built-in optional ones FieldClash(&'static str), + /// Indicates an HTTP repsonse with a non-success status code + Failure(hyper::client::Response), + /// It worked ! Success(T), } diff --git a/gen/youtube3/src/lib.rs b/gen/youtube3/src/lib.rs index beed0b093f4..fa00cdd9528 100644 --- a/gen/youtube3/src/lib.rs +++ b/gen/youtube3/src/lib.rs @@ -187,6 +187,7 @@ use std::borrow::BorrowMut; use std::default::Default; use std::collections::BTreeMap; use std::marker::PhantomData; +use rustc_serialize::json; use std::io; use std::fs; use std::old_io::timer::sleep; @@ -6660,12 +6661,8 @@ impl<'a, C, NC, A> I18nLanguageListMethodBuilder<'a, C, NC, A> where NC: hyper:: /// Perform the operation you have build so far. - pub fn doit(mut self) -> cmn::Result { - use hyper::method::Method; - use hyper::header::UserAgent; - use hyper::header::ContentType; - use mime::{Mime, TopLevel, SubLevel}; - use rustc_serialize::json; + pub fn doit(mut self) -> cmn::Result<(hyper::client::Response, I18nLanguageListResponse)> { + use std::io::Read; let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("part", self._part.to_string())); if self._hl.is_some() { @@ -6690,13 +6687,16 @@ impl<'a, C, NC, A> I18nLanguageListMethodBuilder<'a, C, NC, A> where NC: hyper:: url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice())))); loop { - let token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + if token.is_none() && self._delegate.is_some() { + token = self._delegate.as_mut().unwrap().token(); + } if token.is_none() { return cmn::Result::MissingToken } let auth_header = hyper::header::Authorization(token.unwrap().access_token); - match (*self.hub.client.borrow_mut()).borrow_mut().request(Method::Extension("GET".to_string()), url.as_slice()) - .header(UserAgent("google-api-rust-client/0.0.1".to_string())) + match (*self.hub.client.borrow_mut()).borrow_mut().request(hyper::method::Method::Extension("GET".to_string()), url.as_slice()) + .header(hyper::header::UserAgent("google-api-rust-client/0.0.1".to_string())) .header(auth_header) .send() { Err(err) => { @@ -6713,15 +6713,25 @@ impl<'a, C, NC, A> I18nLanguageListMethodBuilder<'a, C, NC, A> where NC: hyper:: } } Ok(mut res) => { - - break; + if !res.status.is_success() { + if self._delegate.is_some() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).ok(); + let error_info: cmn::JsonServerError = json::decode(&json_err).unwrap(); + if let oauth2::Retry::After(d) = self._delegate.as_mut().unwrap().http_failure(&res, error_info) { + sleep(d); + continue; + } + } + return cmn::Result::Failure(res) + } + let mut json_response = String::new(); + res.read_to_string(&mut json_response).ok(); + let result_value = (res, json::decode(&json_response).unwrap()); + return cmn::Result::Success(result_value) } } } - - let response: I18nLanguageListResponse = Default::default(); - - cmn::Result::Success(response) } @@ -6861,12 +6871,8 @@ impl<'a, C, NC, A> ChannelBannerInsertMethodBuilder<'a, C, NC, A> where NC: hype /// Perform the operation you have build so far. - fn doit(mut self, stream: Option<(R, u64, mime::Mime)>, resumeable_stream: Option<(RS, u64, mime::Mime)>) -> cmn::Result where R: io::Read, RS: ReadSeek { - use hyper::method::Method; - use hyper::header::UserAgent; - use hyper::header::ContentType; - use mime::{Mime, TopLevel, SubLevel}; - use rustc_serialize::json; + fn doit(mut self, stream: Option<(R, u64, mime::Mime)>, resumeable_stream: Option<(RS, u64, mime::Mime)>) -> cmn::Result<(hyper::client::Response, ChannelBannerResource)> where R: io::Read, RS: ReadSeek { + use std::io::Read; let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); if self._on_behalf_of_content_owner.is_some() { params.push(("onBehalfOfContentOwner", self._on_behalf_of_content_owner.unwrap().to_string())); @@ -6889,22 +6895,25 @@ impl<'a, C, NC, A> ChannelBannerInsertMethodBuilder<'a, C, NC, A> where NC: hype }; if self._scopes.len() == 0 { - self._scopes.insert(Scope::PartnerChannelAudit.as_slice().to_string(), ()); + self._scopes.insert(Scope::Full.as_slice().to_string(), ()); } url.push('?'); url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice())))); loop { - let token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + if token.is_none() && self._delegate.is_some() { + token = self._delegate.as_mut().unwrap().token(); + } if token.is_none() { return cmn::Result::MissingToken } let auth_header = hyper::header::Authorization(token.unwrap().access_token); - match (*self.hub.client.borrow_mut()).borrow_mut().request(Method::Extension("POST".to_string()), url.as_slice()) - .header(UserAgent("google-api-rust-client/0.0.1".to_string())) + match (*self.hub.client.borrow_mut()).borrow_mut().request(hyper::method::Method::Extension("POST".to_string()), url.as_slice()) + .header(hyper::header::UserAgent("google-api-rust-client/0.0.1".to_string())) .header(auth_header) - .header(ContentType(Mime(TopLevel::Application, SubLevel::Json, Default::default()))) + .header(hyper::header::ContentType(mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()))) .body(json::encode(&self._request).unwrap().as_slice()) .send() { Err(err) => { @@ -6921,15 +6930,25 @@ impl<'a, C, NC, A> ChannelBannerInsertMethodBuilder<'a, C, NC, A> where NC: hype } } Ok(mut res) => { - - break; + if !res.status.is_success() { + if self._delegate.is_some() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).ok(); + let error_info: cmn::JsonServerError = json::decode(&json_err).unwrap(); + if let oauth2::Retry::After(d) = self._delegate.as_mut().unwrap().http_failure(&res, error_info) { + sleep(d); + continue; + } + } + return cmn::Result::Failure(res) + } + let mut json_response = String::new(); + res.read_to_string(&mut json_response).ok(); + let result_value = (res, json::decode(&json_response).unwrap()); + return cmn::Result::Success(result_value) } } } - - let response: ChannelBannerResource = Default::default(); - - cmn::Result::Success(response) } /// Upload media all at once. @@ -6938,7 +6957,7 @@ impl<'a, C, NC, A> ChannelBannerInsertMethodBuilder<'a, C, NC, A> where NC: hype /// * *max size*: 6MB /// * *multipart*: yes /// * *valid mime types*: 'application/octet-stream', 'image/jpeg' and 'image/png' - pub fn upload(self, stream: R, size: u64, mime_type: mime::Mime) -> cmn::Result + pub fn upload(self, stream: R, size: u64, mime_type: mime::Mime) -> cmn::Result<(hyper::client::Response, ChannelBannerResource)> where R: io::Read { self.doit(Some((stream, size, mime_type)), None::<(fs::File, u64, mime::Mime)>, ) } @@ -6951,7 +6970,7 @@ impl<'a, C, NC, A> ChannelBannerInsertMethodBuilder<'a, C, NC, A> where NC: hype /// * *max size*: 6MB /// * *multipart*: yes /// * *valid mime types*: 'application/octet-stream', 'image/jpeg' and 'image/png' - pub fn upload_resumable(self, resumeable_stream: RS, size: u64, mime_type: mime::Mime) -> cmn::Result + pub fn upload_resumable(self, resumeable_stream: RS, size: u64, mime_type: mime::Mime) -> cmn::Result<(hyper::client::Response, ChannelBannerResource)> where RS: ReadSeek { self.doit(None::<(fs::File, u64, mime::Mime)>, Some((resumeable_stream, size, mime_type)), ) } @@ -7098,12 +7117,8 @@ impl<'a, C, NC, A> ChannelSectionListMethodBuilder<'a, C, NC, A> where NC: hyper /// Perform the operation you have build so far. - pub fn doit(mut self) -> cmn::Result { - use hyper::method::Method; - use hyper::header::UserAgent; - use hyper::header::ContentType; - use mime::{Mime, TopLevel, SubLevel}; - use rustc_serialize::json; + pub fn doit(mut self) -> cmn::Result<(hyper::client::Response, ChannelSectionListResponse)> { + use std::io::Read; let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len()); params.push(("part", self._part.to_string())); if self._on_behalf_of_content_owner.is_some() { @@ -7137,13 +7152,16 @@ impl<'a, C, NC, A> ChannelSectionListMethodBuilder<'a, C, NC, A> where NC: hyper url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice())))); loop { - let token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + if token.is_none() && self._delegate.is_some() { + token = self._delegate.as_mut().unwrap().token(); + } if token.is_none() { return cmn::Result::MissingToken } let auth_header = hyper::header::Authorization(token.unwrap().access_token); - match (*self.hub.client.borrow_mut()).borrow_mut().request(Method::Extension("GET".to_string()), url.as_slice()) - .header(UserAgent("google-api-rust-client/0.0.1".to_string())) + match (*self.hub.client.borrow_mut()).borrow_mut().request(hyper::method::Method::Extension("GET".to_string()), url.as_slice()) + .header(hyper::header::UserAgent("google-api-rust-client/0.0.1".to_string())) .header(auth_header) .send() { Err(err) => { @@ -7160,15 +7178,25 @@ impl<'a, C, NC, A> ChannelSectionListMethodBuilder<'a, C, NC, A> where NC: hyper } } Ok(mut res) => { - - break; + if !res.status.is_success() { + if self._delegate.is_some() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).ok(); + let error_info: cmn::JsonServerError = json::decode(&json_err).unwrap(); + if let oauth2::Retry::After(d) = self._delegate.as_mut().unwrap().http_failure(&res, error_info) { + sleep(d); + continue; + } + } + return cmn::Result::Failure(res) + } + let mut json_response = String::new(); + res.read_to_string(&mut json_response).ok(); + let result_value = (res, json::decode(&json_response).unwrap()); + return cmn::Result::Success(result_value) } } } - - let response: ChannelSectionListResponse = Default::default(); - - cmn::Result::Success(response) } @@ -7350,12 +7378,8 @@ impl<'a, C, NC, A> ChannelSectionInsertMethodBuilder<'a, C, NC, A> where NC: hyp /// Perform the operation you have build so far. - pub fn doit(mut self) -> cmn::Result { - use hyper::method::Method; - use hyper::header::UserAgent; - use hyper::header::ContentType; - use mime::{Mime, TopLevel, SubLevel}; - use rustc_serialize::json; + pub fn doit(mut self) -> cmn::Result<(hyper::client::Response, ChannelSection)> { + use std::io::Read; let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); if self._part.len() == 0 { self._part = self._request.to_parts(); @@ -7379,22 +7403,25 @@ impl<'a, C, NC, A> ChannelSectionInsertMethodBuilder<'a, C, NC, A> where NC: hyp let mut url = "https://www.googleapis.com/youtube/v3/channelSections".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::PartnerChannelAudit.as_slice().to_string(), ()); + self._scopes.insert(Scope::Full.as_slice().to_string(), ()); } url.push('?'); url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice())))); loop { - let token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + if token.is_none() && self._delegate.is_some() { + token = self._delegate.as_mut().unwrap().token(); + } if token.is_none() { return cmn::Result::MissingToken } let auth_header = hyper::header::Authorization(token.unwrap().access_token); - match (*self.hub.client.borrow_mut()).borrow_mut().request(Method::Extension("POST".to_string()), url.as_slice()) - .header(UserAgent("google-api-rust-client/0.0.1".to_string())) + match (*self.hub.client.borrow_mut()).borrow_mut().request(hyper::method::Method::Extension("POST".to_string()), url.as_slice()) + .header(hyper::header::UserAgent("google-api-rust-client/0.0.1".to_string())) .header(auth_header) - .header(ContentType(Mime(TopLevel::Application, SubLevel::Json, Default::default()))) + .header(hyper::header::ContentType(mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()))) .body(json::encode(&self._request).unwrap().as_slice()) .send() { Err(err) => { @@ -7411,15 +7438,25 @@ impl<'a, C, NC, A> ChannelSectionInsertMethodBuilder<'a, C, NC, A> where NC: hyp } } Ok(mut res) => { - - break; + if !res.status.is_success() { + if self._delegate.is_some() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).ok(); + let error_info: cmn::JsonServerError = json::decode(&json_err).unwrap(); + if let oauth2::Retry::After(d) = self._delegate.as_mut().unwrap().http_failure(&res, error_info) { + sleep(d); + continue; + } + } + return cmn::Result::Failure(res) + } + let mut json_response = String::new(); + res.read_to_string(&mut json_response).ok(); + let result_value = (res, json::decode(&json_response).unwrap()); + return cmn::Result::Success(result_value) } } } - - let response: ChannelSection = Default::default(); - - cmn::Result::Success(response) } @@ -7581,9 +7618,8 @@ impl<'a, C, NC, A> ChannelSectionDeleteMethodBuilder<'a, C, NC, A> where NC: hyp /// Perform the operation you have build so far. - pub fn doit(mut self) -> cmn::Result<()> { - use hyper::method::Method; - use hyper::header::UserAgent; + pub fn doit(mut self) -> cmn::Result { + use std::io::Read; let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("id", self._id.to_string())); if self._on_behalf_of_content_owner.is_some() { @@ -7601,20 +7637,23 @@ impl<'a, C, NC, A> ChannelSectionDeleteMethodBuilder<'a, C, NC, A> where NC: hyp let mut url = "https://www.googleapis.com/youtube/v3/channelSections".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::PartnerChannelAudit.as_slice().to_string(), ()); + self._scopes.insert(Scope::Full.as_slice().to_string(), ()); } url.push('?'); url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice())))); loop { - let token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + if token.is_none() && self._delegate.is_some() { + token = self._delegate.as_mut().unwrap().token(); + } if token.is_none() { return cmn::Result::MissingToken } let auth_header = hyper::header::Authorization(token.unwrap().access_token); - match (*self.hub.client.borrow_mut()).borrow_mut().request(Method::Extension("DELETE".to_string()), url.as_slice()) - .header(UserAgent("google-api-rust-client/0.0.1".to_string())) + match (*self.hub.client.borrow_mut()).borrow_mut().request(hyper::method::Method::Extension("DELETE".to_string()), url.as_slice()) + .header(hyper::header::UserAgent("google-api-rust-client/0.0.1".to_string())) .header(auth_header) .send() { Err(err) => { @@ -7631,15 +7670,23 @@ impl<'a, C, NC, A> ChannelSectionDeleteMethodBuilder<'a, C, NC, A> where NC: hyp } } Ok(mut res) => { - - break; + if !res.status.is_success() { + if self._delegate.is_some() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).ok(); + let error_info: cmn::JsonServerError = json::decode(&json_err).unwrap(); + if let oauth2::Retry::After(d) = self._delegate.as_mut().unwrap().http_failure(&res, error_info) { + sleep(d); + continue; + } + } + return cmn::Result::Failure(res) + } + let result_value = res; + return cmn::Result::Success(result_value) } } } - - let response = (); - - cmn::Result::Success(response) } @@ -7787,12 +7834,8 @@ impl<'a, C, NC, A> ChannelSectionUpdateMethodBuilder<'a, C, NC, A> where NC: hyp /// Perform the operation you have build so far. - pub fn doit(mut self) -> cmn::Result { - use hyper::method::Method; - use hyper::header::UserAgent; - use hyper::header::ContentType; - use mime::{Mime, TopLevel, SubLevel}; - use rustc_serialize::json; + pub fn doit(mut self) -> cmn::Result<(hyper::client::Response, ChannelSection)> { + use std::io::Read; let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); if self._part.len() == 0 { self._part = self._request.to_parts(); @@ -7813,22 +7856,25 @@ impl<'a, C, NC, A> ChannelSectionUpdateMethodBuilder<'a, C, NC, A> where NC: hyp let mut url = "https://www.googleapis.com/youtube/v3/channelSections".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::PartnerChannelAudit.as_slice().to_string(), ()); + self._scopes.insert(Scope::Full.as_slice().to_string(), ()); } url.push('?'); url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice())))); loop { - let token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + if token.is_none() && self._delegate.is_some() { + token = self._delegate.as_mut().unwrap().token(); + } if token.is_none() { return cmn::Result::MissingToken } let auth_header = hyper::header::Authorization(token.unwrap().access_token); - match (*self.hub.client.borrow_mut()).borrow_mut().request(Method::Extension("PUT".to_string()), url.as_slice()) - .header(UserAgent("google-api-rust-client/0.0.1".to_string())) + match (*self.hub.client.borrow_mut()).borrow_mut().request(hyper::method::Method::Extension("PUT".to_string()), url.as_slice()) + .header(hyper::header::UserAgent("google-api-rust-client/0.0.1".to_string())) .header(auth_header) - .header(ContentType(Mime(TopLevel::Application, SubLevel::Json, Default::default()))) + .header(hyper::header::ContentType(mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()))) .body(json::encode(&self._request).unwrap().as_slice()) .send() { Err(err) => { @@ -7845,15 +7891,25 @@ impl<'a, C, NC, A> ChannelSectionUpdateMethodBuilder<'a, C, NC, A> where NC: hyp } } Ok(mut res) => { - - break; + if !res.status.is_success() { + if self._delegate.is_some() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).ok(); + let error_info: cmn::JsonServerError = json::decode(&json_err).unwrap(); + if let oauth2::Retry::After(d) = self._delegate.as_mut().unwrap().http_failure(&res, error_info) { + sleep(d); + continue; + } + } + return cmn::Result::Failure(res) + } + let mut json_response = String::new(); + res.read_to_string(&mut json_response).ok(); + let result_value = (res, json::decode(&json_response).unwrap()); + return cmn::Result::Success(result_value) } } } - - let response: ChannelSection = Default::default(); - - cmn::Result::Success(response) } @@ -8021,12 +8077,8 @@ impl<'a, C, NC, A> GuideCategoryListMethodBuilder<'a, C, NC, A> where NC: hyper: /// Perform the operation you have build so far. - pub fn doit(mut self) -> cmn::Result { - use hyper::method::Method; - use hyper::header::UserAgent; - use hyper::header::ContentType; - use mime::{Mime, TopLevel, SubLevel}; - use rustc_serialize::json; + pub fn doit(mut self) -> cmn::Result<(hyper::client::Response, GuideCategoryListResponse)> { + use std::io::Read; let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("part", self._part.to_string())); if self._region_code.is_some() { @@ -8057,13 +8109,16 @@ impl<'a, C, NC, A> GuideCategoryListMethodBuilder<'a, C, NC, A> where NC: hyper: url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice())))); loop { - let token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + if token.is_none() && self._delegate.is_some() { + token = self._delegate.as_mut().unwrap().token(); + } if token.is_none() { return cmn::Result::MissingToken } let auth_header = hyper::header::Authorization(token.unwrap().access_token); - match (*self.hub.client.borrow_mut()).borrow_mut().request(Method::Extension("GET".to_string()), url.as_slice()) - .header(UserAgent("google-api-rust-client/0.0.1".to_string())) + match (*self.hub.client.borrow_mut()).borrow_mut().request(hyper::method::Method::Extension("GET".to_string()), url.as_slice()) + .header(hyper::header::UserAgent("google-api-rust-client/0.0.1".to_string())) .header(auth_header) .send() { Err(err) => { @@ -8080,15 +8135,25 @@ impl<'a, C, NC, A> GuideCategoryListMethodBuilder<'a, C, NC, A> where NC: hyper: } } Ok(mut res) => { - - break; + if !res.status.is_success() { + if self._delegate.is_some() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).ok(); + let error_info: cmn::JsonServerError = json::decode(&json_err).unwrap(); + if let oauth2::Retry::After(d) = self._delegate.as_mut().unwrap().http_failure(&res, error_info) { + sleep(d); + continue; + } + } + return cmn::Result::Failure(res) + } + let mut json_response = String::new(); + res.read_to_string(&mut json_response).ok(); + let result_value = (res, json::decode(&json_response).unwrap()); + return cmn::Result::Success(result_value) } } } - - let response: GuideCategoryListResponse = Default::default(); - - cmn::Result::Success(response) } @@ -8259,12 +8324,8 @@ impl<'a, C, NC, A> PlaylistInsertMethodBuilder<'a, C, NC, A> where NC: hyper::ne /// Perform the operation you have build so far. - pub fn doit(mut self) -> cmn::Result { - use hyper::method::Method; - use hyper::header::UserAgent; - use hyper::header::ContentType; - use mime::{Mime, TopLevel, SubLevel}; - use rustc_serialize::json; + pub fn doit(mut self) -> cmn::Result<(hyper::client::Response, Playlist)> { + use std::io::Read; let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); if self._part.len() == 0 { self._part = self._request.to_parts(); @@ -8288,22 +8349,25 @@ impl<'a, C, NC, A> PlaylistInsertMethodBuilder<'a, C, NC, A> where NC: hyper::ne let mut url = "https://www.googleapis.com/youtube/v3/playlists".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::PartnerChannelAudit.as_slice().to_string(), ()); + self._scopes.insert(Scope::Full.as_slice().to_string(), ()); } url.push('?'); url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice())))); loop { - let token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + if token.is_none() && self._delegate.is_some() { + token = self._delegate.as_mut().unwrap().token(); + } if token.is_none() { return cmn::Result::MissingToken } let auth_header = hyper::header::Authorization(token.unwrap().access_token); - match (*self.hub.client.borrow_mut()).borrow_mut().request(Method::Extension("POST".to_string()), url.as_slice()) - .header(UserAgent("google-api-rust-client/0.0.1".to_string())) + match (*self.hub.client.borrow_mut()).borrow_mut().request(hyper::method::Method::Extension("POST".to_string()), url.as_slice()) + .header(hyper::header::UserAgent("google-api-rust-client/0.0.1".to_string())) .header(auth_header) - .header(ContentType(Mime(TopLevel::Application, SubLevel::Json, Default::default()))) + .header(hyper::header::ContentType(mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()))) .body(json::encode(&self._request).unwrap().as_slice()) .send() { Err(err) => { @@ -8320,15 +8384,25 @@ impl<'a, C, NC, A> PlaylistInsertMethodBuilder<'a, C, NC, A> where NC: hyper::ne } } Ok(mut res) => { - - break; + if !res.status.is_success() { + if self._delegate.is_some() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).ok(); + let error_info: cmn::JsonServerError = json::decode(&json_err).unwrap(); + if let oauth2::Retry::After(d) = self._delegate.as_mut().unwrap().http_failure(&res, error_info) { + sleep(d); + continue; + } + } + return cmn::Result::Failure(res) + } + let mut json_response = String::new(); + res.read_to_string(&mut json_response).ok(); + let result_value = (res, json::decode(&json_response).unwrap()); + return cmn::Result::Success(result_value) } } } - - let response: Playlist = Default::default(); - - cmn::Result::Success(response) } @@ -8518,12 +8592,8 @@ impl<'a, C, NC, A> PlaylistListMethodBuilder<'a, C, NC, A> where NC: hyper::net: /// Perform the operation you have build so far. - pub fn doit(mut self) -> cmn::Result { - use hyper::method::Method; - use hyper::header::UserAgent; - use hyper::header::ContentType; - use mime::{Mime, TopLevel, SubLevel}; - use rustc_serialize::json; + pub fn doit(mut self) -> cmn::Result<(hyper::client::Response, PlaylistListResponse)> { + use std::io::Read; let mut params: Vec<(&str, String)> = Vec::with_capacity(9 + self._additional_params.len()); params.push(("part", self._part.to_string())); if self._page_token.is_some() { @@ -8566,13 +8636,16 @@ impl<'a, C, NC, A> PlaylistListMethodBuilder<'a, C, NC, A> where NC: hyper::net: url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice())))); loop { - let token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + if token.is_none() && self._delegate.is_some() { + token = self._delegate.as_mut().unwrap().token(); + } if token.is_none() { return cmn::Result::MissingToken } let auth_header = hyper::header::Authorization(token.unwrap().access_token); - match (*self.hub.client.borrow_mut()).borrow_mut().request(Method::Extension("GET".to_string()), url.as_slice()) - .header(UserAgent("google-api-rust-client/0.0.1".to_string())) + match (*self.hub.client.borrow_mut()).borrow_mut().request(hyper::method::Method::Extension("GET".to_string()), url.as_slice()) + .header(hyper::header::UserAgent("google-api-rust-client/0.0.1".to_string())) .header(auth_header) .send() { Err(err) => { @@ -8589,15 +8662,25 @@ impl<'a, C, NC, A> PlaylistListMethodBuilder<'a, C, NC, A> where NC: hyper::net: } } Ok(mut res) => { - - break; + if !res.status.is_success() { + if self._delegate.is_some() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).ok(); + let error_info: cmn::JsonServerError = json::decode(&json_err).unwrap(); + if let oauth2::Retry::After(d) = self._delegate.as_mut().unwrap().http_failure(&res, error_info) { + sleep(d); + continue; + } + } + return cmn::Result::Failure(res) + } + let mut json_response = String::new(); + res.read_to_string(&mut json_response).ok(); + let result_value = (res, json::decode(&json_response).unwrap()); + return cmn::Result::Success(result_value) } } } - - let response: PlaylistListResponse = Default::default(); - - cmn::Result::Success(response) } @@ -8784,9 +8867,8 @@ impl<'a, C, NC, A> PlaylistDeleteMethodBuilder<'a, C, NC, A> where NC: hyper::ne /// Perform the operation you have build so far. - pub fn doit(mut self) -> cmn::Result<()> { - use hyper::method::Method; - use hyper::header::UserAgent; + pub fn doit(mut self) -> cmn::Result { + use std::io::Read; let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("id", self._id.to_string())); if self._on_behalf_of_content_owner.is_some() { @@ -8804,20 +8886,23 @@ impl<'a, C, NC, A> PlaylistDeleteMethodBuilder<'a, C, NC, A> where NC: hyper::ne let mut url = "https://www.googleapis.com/youtube/v3/playlists".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::PartnerChannelAudit.as_slice().to_string(), ()); + self._scopes.insert(Scope::Full.as_slice().to_string(), ()); } url.push('?'); url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice())))); loop { - let token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + if token.is_none() && self._delegate.is_some() { + token = self._delegate.as_mut().unwrap().token(); + } if token.is_none() { return cmn::Result::MissingToken } let auth_header = hyper::header::Authorization(token.unwrap().access_token); - match (*self.hub.client.borrow_mut()).borrow_mut().request(Method::Extension("DELETE".to_string()), url.as_slice()) - .header(UserAgent("google-api-rust-client/0.0.1".to_string())) + match (*self.hub.client.borrow_mut()).borrow_mut().request(hyper::method::Method::Extension("DELETE".to_string()), url.as_slice()) + .header(hyper::header::UserAgent("google-api-rust-client/0.0.1".to_string())) .header(auth_header) .send() { Err(err) => { @@ -8834,15 +8919,23 @@ impl<'a, C, NC, A> PlaylistDeleteMethodBuilder<'a, C, NC, A> where NC: hyper::ne } } Ok(mut res) => { - - break; + if !res.status.is_success() { + if self._delegate.is_some() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).ok(); + let error_info: cmn::JsonServerError = json::decode(&json_err).unwrap(); + if let oauth2::Retry::After(d) = self._delegate.as_mut().unwrap().http_failure(&res, error_info) { + sleep(d); + continue; + } + } + return cmn::Result::Failure(res) + } + let result_value = res; + return cmn::Result::Success(result_value) } } } - - let response = (); - - cmn::Result::Success(response) } @@ -8990,12 +9083,8 @@ impl<'a, C, NC, A> PlaylistUpdateMethodBuilder<'a, C, NC, A> where NC: hyper::ne /// Perform the operation you have build so far. - pub fn doit(mut self) -> cmn::Result { - use hyper::method::Method; - use hyper::header::UserAgent; - use hyper::header::ContentType; - use mime::{Mime, TopLevel, SubLevel}; - use rustc_serialize::json; + pub fn doit(mut self) -> cmn::Result<(hyper::client::Response, Playlist)> { + use std::io::Read; let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); if self._part.len() == 0 { self._part = self._request.to_parts(); @@ -9016,22 +9105,25 @@ impl<'a, C, NC, A> PlaylistUpdateMethodBuilder<'a, C, NC, A> where NC: hyper::ne let mut url = "https://www.googleapis.com/youtube/v3/playlists".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::PartnerChannelAudit.as_slice().to_string(), ()); + self._scopes.insert(Scope::Full.as_slice().to_string(), ()); } url.push('?'); url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice())))); loop { - let token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + if token.is_none() && self._delegate.is_some() { + token = self._delegate.as_mut().unwrap().token(); + } if token.is_none() { return cmn::Result::MissingToken } let auth_header = hyper::header::Authorization(token.unwrap().access_token); - match (*self.hub.client.borrow_mut()).borrow_mut().request(Method::Extension("PUT".to_string()), url.as_slice()) - .header(UserAgent("google-api-rust-client/0.0.1".to_string())) + match (*self.hub.client.borrow_mut()).borrow_mut().request(hyper::method::Method::Extension("PUT".to_string()), url.as_slice()) + .header(hyper::header::UserAgent("google-api-rust-client/0.0.1".to_string())) .header(auth_header) - .header(ContentType(Mime(TopLevel::Application, SubLevel::Json, Default::default()))) + .header(hyper::header::ContentType(mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()))) .body(json::encode(&self._request).unwrap().as_slice()) .send() { Err(err) => { @@ -9048,15 +9140,25 @@ impl<'a, C, NC, A> PlaylistUpdateMethodBuilder<'a, C, NC, A> where NC: hyper::ne } } Ok(mut res) => { - - break; + if !res.status.is_success() { + if self._delegate.is_some() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).ok(); + let error_info: cmn::JsonServerError = json::decode(&json_err).unwrap(); + if let oauth2::Retry::After(d) = self._delegate.as_mut().unwrap().http_failure(&res, error_info) { + sleep(d); + continue; + } + } + return cmn::Result::Failure(res) + } + let mut json_response = String::new(); + res.read_to_string(&mut json_response).ok(); + let result_value = (res, json::decode(&json_response).unwrap()); + return cmn::Result::Success(result_value) } } } - - let response: Playlist = Default::default(); - - cmn::Result::Success(response) } @@ -9209,12 +9311,8 @@ impl<'a, C, NC, A> ThumbnailSetMethodBuilder<'a, C, NC, A> where NC: hyper::net: /// Perform the operation you have build so far. - fn doit(mut self, stream: Option<(R, u64, mime::Mime)>, resumeable_stream: Option<(RS, u64, mime::Mime)>) -> cmn::Result where R: io::Read, RS: ReadSeek { - use hyper::method::Method; - use hyper::header::UserAgent; - use hyper::header::ContentType; - use mime::{Mime, TopLevel, SubLevel}; - use rustc_serialize::json; + fn doit(mut self, stream: Option<(R, u64, mime::Mime)>, resumeable_stream: Option<(RS, u64, mime::Mime)>) -> cmn::Result<(hyper::client::Response, ThumbnailSetResponse)> where R: io::Read, RS: ReadSeek { + use std::io::Read; let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("videoId", self._video_id.to_string())); if self._on_behalf_of_content_owner.is_some() { @@ -9238,20 +9336,23 @@ impl<'a, C, NC, A> ThumbnailSetMethodBuilder<'a, C, NC, A> where NC: hyper::net: }; if self._scopes.len() == 0 { - self._scopes.insert(Scope::PartnerChannelAudit.as_slice().to_string(), ()); + self._scopes.insert(Scope::Full.as_slice().to_string(), ()); } url.push('?'); url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice())))); loop { - let token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + if token.is_none() && self._delegate.is_some() { + token = self._delegate.as_mut().unwrap().token(); + } if token.is_none() { return cmn::Result::MissingToken } let auth_header = hyper::header::Authorization(token.unwrap().access_token); - match (*self.hub.client.borrow_mut()).borrow_mut().request(Method::Extension("POST".to_string()), url.as_slice()) - .header(UserAgent("google-api-rust-client/0.0.1".to_string())) + match (*self.hub.client.borrow_mut()).borrow_mut().request(hyper::method::Method::Extension("POST".to_string()), url.as_slice()) + .header(hyper::header::UserAgent("google-api-rust-client/0.0.1".to_string())) .header(auth_header) .send() { Err(err) => { @@ -9268,15 +9369,25 @@ impl<'a, C, NC, A> ThumbnailSetMethodBuilder<'a, C, NC, A> where NC: hyper::net: } } Ok(mut res) => { - - break; + if !res.status.is_success() { + if self._delegate.is_some() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).ok(); + let error_info: cmn::JsonServerError = json::decode(&json_err).unwrap(); + if let oauth2::Retry::After(d) = self._delegate.as_mut().unwrap().http_failure(&res, error_info) { + sleep(d); + continue; + } + } + return cmn::Result::Failure(res) + } + let mut json_response = String::new(); + res.read_to_string(&mut json_response).ok(); + let result_value = (res, json::decode(&json_response).unwrap()); + return cmn::Result::Success(result_value) } } } - - let response: ThumbnailSetResponse = Default::default(); - - cmn::Result::Success(response) } /// Upload media all at once. @@ -9285,7 +9396,7 @@ impl<'a, C, NC, A> ThumbnailSetMethodBuilder<'a, C, NC, A> where NC: hyper::net: /// * *max size*: 2MB /// * *multipart*: yes /// * *valid mime types*: 'application/octet-stream', 'image/jpeg' and 'image/png' - pub fn upload(self, stream: R, size: u64, mime_type: mime::Mime) -> cmn::Result + pub fn upload(self, stream: R, size: u64, mime_type: mime::Mime) -> cmn::Result<(hyper::client::Response, ThumbnailSetResponse)> where R: io::Read { self.doit(Some((stream, size, mime_type)), None::<(fs::File, u64, mime::Mime)>, ) } @@ -9298,7 +9409,7 @@ impl<'a, C, NC, A> ThumbnailSetMethodBuilder<'a, C, NC, A> where NC: hyper::net: /// * *max size*: 2MB /// * *multipart*: yes /// * *valid mime types*: 'application/octet-stream', 'image/jpeg' and 'image/png' - pub fn upload_resumable(self, resumeable_stream: RS, size: u64, mime_type: mime::Mime) -> cmn::Result + pub fn upload_resumable(self, resumeable_stream: RS, size: u64, mime_type: mime::Mime) -> cmn::Result<(hyper::client::Response, ThumbnailSetResponse)> where RS: ReadSeek { self.doit(None::<(fs::File, u64, mime::Mime)>, Some((resumeable_stream, size, mime_type)), ) } @@ -9466,12 +9577,8 @@ impl<'a, C, NC, A> VideoListMethodBuilder<'a, C, NC, A> where NC: hyper::net::Ne /// Perform the operation you have build so far. - pub fn doit(mut self) -> cmn::Result { - use hyper::method::Method; - use hyper::header::UserAgent; - use hyper::header::ContentType; - use mime::{Mime, TopLevel, SubLevel}; - use rustc_serialize::json; + pub fn doit(mut self) -> cmn::Result<(hyper::client::Response, VideoListResponse)> { + use std::io::Read; let mut params: Vec<(&str, String)> = Vec::with_capacity(12 + self._additional_params.len()); params.push(("part", self._part.to_string())); if self._video_category_id.is_some() { @@ -9523,13 +9630,16 @@ impl<'a, C, NC, A> VideoListMethodBuilder<'a, C, NC, A> where NC: hyper::net::Ne url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice())))); loop { - let token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + if token.is_none() && self._delegate.is_some() { + token = self._delegate.as_mut().unwrap().token(); + } if token.is_none() { return cmn::Result::MissingToken } let auth_header = hyper::header::Authorization(token.unwrap().access_token); - match (*self.hub.client.borrow_mut()).borrow_mut().request(Method::Extension("GET".to_string()), url.as_slice()) - .header(UserAgent("google-api-rust-client/0.0.1".to_string())) + match (*self.hub.client.borrow_mut()).borrow_mut().request(hyper::method::Method::Extension("GET".to_string()), url.as_slice()) + .header(hyper::header::UserAgent("google-api-rust-client/0.0.1".to_string())) .header(auth_header) .send() { Err(err) => { @@ -9546,15 +9656,25 @@ impl<'a, C, NC, A> VideoListMethodBuilder<'a, C, NC, A> where NC: hyper::net::Ne } } Ok(mut res) => { - - break; + if !res.status.is_success() { + if self._delegate.is_some() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).ok(); + let error_info: cmn::JsonServerError = json::decode(&json_err).unwrap(); + if let oauth2::Retry::After(d) = self._delegate.as_mut().unwrap().http_failure(&res, error_info) { + sleep(d); + continue; + } + } + return cmn::Result::Failure(res) + } + let mut json_response = String::new(); + res.read_to_string(&mut json_response).ok(); + let result_value = (res, json::decode(&json_response).unwrap()); + return cmn::Result::Success(result_value) } } } - - let response: VideoListResponse = Default::default(); - - cmn::Result::Success(response) } @@ -9775,9 +9895,8 @@ impl<'a, C, NC, A> VideoRateMethodBuilder<'a, C, NC, A> where NC: hyper::net::Ne /// Perform the operation you have build so far. - pub fn doit(mut self) -> cmn::Result<()> { - use hyper::method::Method; - use hyper::header::UserAgent; + pub fn doit(mut self) -> cmn::Result { + use std::io::Read; let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("id", self._id.to_string())); params.push(("rating", self._rating.to_string())); @@ -9796,20 +9915,23 @@ impl<'a, C, NC, A> VideoRateMethodBuilder<'a, C, NC, A> where NC: hyper::net::Ne let mut url = "https://www.googleapis.com/youtube/v3/videos/rate".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::PartnerChannelAudit.as_slice().to_string(), ()); + self._scopes.insert(Scope::Full.as_slice().to_string(), ()); } url.push('?'); url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice())))); loop { - let token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + if token.is_none() && self._delegate.is_some() { + token = self._delegate.as_mut().unwrap().token(); + } if token.is_none() { return cmn::Result::MissingToken } let auth_header = hyper::header::Authorization(token.unwrap().access_token); - match (*self.hub.client.borrow_mut()).borrow_mut().request(Method::Extension("POST".to_string()), url.as_slice()) - .header(UserAgent("google-api-rust-client/0.0.1".to_string())) + match (*self.hub.client.borrow_mut()).borrow_mut().request(hyper::method::Method::Extension("POST".to_string()), url.as_slice()) + .header(hyper::header::UserAgent("google-api-rust-client/0.0.1".to_string())) .header(auth_header) .send() { Err(err) => { @@ -9826,15 +9948,23 @@ impl<'a, C, NC, A> VideoRateMethodBuilder<'a, C, NC, A> where NC: hyper::net::Ne } } Ok(mut res) => { - - break; + if !res.status.is_success() { + if self._delegate.is_some() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).ok(); + let error_info: cmn::JsonServerError = json::decode(&json_err).unwrap(); + if let oauth2::Retry::After(d) = self._delegate.as_mut().unwrap().http_failure(&res, error_info) { + sleep(d); + continue; + } + } + return cmn::Result::Failure(res) + } + let result_value = res; + return cmn::Result::Success(result_value) } } } - - let response = (); - - cmn::Result::Success(response) } @@ -9970,12 +10100,8 @@ impl<'a, C, NC, A> VideoGetRatingMethodBuilder<'a, C, NC, A> where NC: hyper::ne /// Perform the operation you have build so far. - pub fn doit(mut self) -> cmn::Result { - use hyper::method::Method; - use hyper::header::UserAgent; - use hyper::header::ContentType; - use mime::{Mime, TopLevel, SubLevel}; - use rustc_serialize::json; + pub fn doit(mut self) -> cmn::Result<(hyper::client::Response, VideoGetRatingResponse)> { + use std::io::Read; let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("id", self._id.to_string())); if self._on_behalf_of_content_owner.is_some() { @@ -10000,13 +10126,16 @@ impl<'a, C, NC, A> VideoGetRatingMethodBuilder<'a, C, NC, A> where NC: hyper::ne url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice())))); loop { - let token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + if token.is_none() && self._delegate.is_some() { + token = self._delegate.as_mut().unwrap().token(); + } if token.is_none() { return cmn::Result::MissingToken } let auth_header = hyper::header::Authorization(token.unwrap().access_token); - match (*self.hub.client.borrow_mut()).borrow_mut().request(Method::Extension("GET".to_string()), url.as_slice()) - .header(UserAgent("google-api-rust-client/0.0.1".to_string())) + match (*self.hub.client.borrow_mut()).borrow_mut().request(hyper::method::Method::Extension("GET".to_string()), url.as_slice()) + .header(hyper::header::UserAgent("google-api-rust-client/0.0.1".to_string())) .header(auth_header) .send() { Err(err) => { @@ -10023,15 +10152,25 @@ impl<'a, C, NC, A> VideoGetRatingMethodBuilder<'a, C, NC, A> where NC: hyper::ne } } Ok(mut res) => { - - break; + if !res.status.is_success() { + if self._delegate.is_some() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).ok(); + let error_info: cmn::JsonServerError = json::decode(&json_err).unwrap(); + if let oauth2::Retry::After(d) = self._delegate.as_mut().unwrap().http_failure(&res, error_info) { + sleep(d); + continue; + } + } + return cmn::Result::Failure(res) + } + let mut json_response = String::new(); + res.read_to_string(&mut json_response).ok(); + let result_value = (res, json::decode(&json_response).unwrap()); + return cmn::Result::Success(result_value) } } } - - let response: VideoGetRatingResponse = Default::default(); - - cmn::Result::Success(response) } @@ -10157,9 +10296,8 @@ impl<'a, C, NC, A> VideoDeleteMethodBuilder<'a, C, NC, A> where NC: hyper::net:: /// Perform the operation you have build so far. - pub fn doit(mut self) -> cmn::Result<()> { - use hyper::method::Method; - use hyper::header::UserAgent; + pub fn doit(mut self) -> cmn::Result { + use std::io::Read; let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("id", self._id.to_string())); if self._on_behalf_of_content_owner.is_some() { @@ -10177,20 +10315,23 @@ impl<'a, C, NC, A> VideoDeleteMethodBuilder<'a, C, NC, A> where NC: hyper::net:: let mut url = "https://www.googleapis.com/youtube/v3/videos".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::PartnerChannelAudit.as_slice().to_string(), ()); + self._scopes.insert(Scope::Full.as_slice().to_string(), ()); } url.push('?'); url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice())))); loop { - let token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); + if token.is_none() && self._delegate.is_some() { + token = self._delegate.as_mut().unwrap().token(); + } if token.is_none() { return cmn::Result::MissingToken } let auth_header = hyper::header::Authorization(token.unwrap().access_token); - match (*self.hub.client.borrow_mut()).borrow_mut().request(Method::Extension("DELETE".to_string()), url.as_slice()) - .header(UserAgent("google-api-rust-client/0.0.1".to_string())) + match (*self.hub.client.borrow_mut()).borrow_mut().request(hyper::method::Method::Extension("DELETE".to_string()), url.as_slice()) + .header(hyper::header::UserAgent("google-api-rust-client/0.0.1".to_string())) .header(auth_header) .send() { Err(err) => { @@ -10207,15 +10348,23 @@ impl<'a, C, NC, A> VideoDeleteMethodBuilder<'a, C, NC, A> where NC: hyper::net:: } } Ok(mut res) => { - - break; + if !res.status.is_success() { + if self._delegate.is_some() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).ok(); + let error_info: cmn::JsonServerError = json::decode(&json_err).unwrap(); + if let oauth2::Retry::After(d) = self._delegate.as_mut().unwrap().http_failure(&res, error_info) { + sleep(d); + continue; + } + } + return cmn::Result::Failure(res) + } + let result_value = res; + return cmn::Result::Success(result_value) } } } - - let response = (); - - cmn::Result::Success(response) } @@ -10383,12 +10532,8 @@ impl<'a, C, NC, A> VideoUpdateMethodBuilder<'a, C, NC, A> where NC: hyper::net:: /// Perform the operation you have build so far. - pub fn doit(mut self) -> cmn::Result