mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-02-23 15:49:49 +01:00
fix(checkin): latest version of all APIs
Now CLI and API and the same level
This commit is contained in:
@@ -100,16 +100,18 @@ let result = hub.statscollection().updatestats(&req)
|
||||
|
||||
match result {
|
||||
Err(e) => match e {
|
||||
Error::HttpError(err) => println!("HTTPERROR: {:?}", err),
|
||||
Error::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
|
||||
Error::MissingToken => println!("OAuth2: Missing Token"),
|
||||
Error::Cancelled => println!("Operation canceled by user"),
|
||||
Error::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
|
||||
Error::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
|
||||
Error::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
|
||||
Error::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
|
||||
// The Error enum provides details about what exactly happened.
|
||||
// You can also just use its `Debug`, `Display` or `Error` traits
|
||||
Error::HttpError(_)
|
||||
|Error::MissingAPIKey
|
||||
|Error::MissingToken
|
||||
|Error::Cancelled
|
||||
|Error::UploadSizeLimitExceeded(_, _)
|
||||
|Error::Failure(_)
|
||||
|Error::FieldClash(_)
|
||||
|Error::JsonDecodeError(_) => println!("{}", e),
|
||||
},
|
||||
Ok(_) => println!("Success (value doesn't print)"),
|
||||
Ok(res) => println!("Success: {:?}", res),
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
@@ -4,6 +4,7 @@ use std::io::{self, Read, Seek, Cursor, Write, SeekFrom};
|
||||
use std;
|
||||
use std::fmt::{self, Display};
|
||||
use std::str::FromStr;
|
||||
use std::error;
|
||||
use std::thread::sleep_ms;
|
||||
|
||||
use mime::{Mime, TopLevel, SubLevel, Attr, Value};
|
||||
@@ -217,7 +218,7 @@ pub struct DefaultDelegate;
|
||||
impl Delegate for DefaultDelegate {}
|
||||
|
||||
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
/// The http connection failed
|
||||
HttpError(hyper::HttpError),
|
||||
@@ -247,6 +248,49 @@ pub enum Error {
|
||||
Failure(hyper::client::Response),
|
||||
}
|
||||
|
||||
|
||||
impl Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
Error::HttpError(ref err) => err.fmt(f),
|
||||
Error::UploadSizeLimitExceeded(ref resource_size, ref max_size) =>
|
||||
writeln!(f, "The media size {} exceeds the maximum allowed upload size of {}"
|
||||
, resource_size, max_size),
|
||||
Error::MissingAPIKey => {
|
||||
writeln!(f, "The application's API key was not found in the configuration").ok();
|
||||
writeln!(f, "It is used as there are no Scopes defined for this method.")
|
||||
},
|
||||
Error::MissingToken =>
|
||||
writeln!(f, "Didn't obtain authentication token from authenticator"),
|
||||
Error::Cancelled =>
|
||||
writeln!(f, "Operation cancelled by delegate"),
|
||||
Error::FieldClash(field) =>
|
||||
writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field),
|
||||
Error::JsonDecodeError(ref err) => err.fmt(f),
|
||||
Error::Failure(ref response) =>
|
||||
writeln!(f, "Http status indicates failure: {:?}", response),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl error::Error for Error {
|
||||
fn description(&self) -> &str {
|
||||
match *self {
|
||||
Error::HttpError(ref err) => err.description(),
|
||||
Error::JsonDecodeError(ref err) => err.description(),
|
||||
_ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead"
|
||||
}
|
||||
}
|
||||
|
||||
fn cause(&self) -> Option<&error::Error> {
|
||||
match *self {
|
||||
Error::HttpError(ref err) => err.cause(),
|
||||
Error::JsonDecodeError(ref err) => err.cause(),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A universal result type used as return for all calls.
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
|
||||
@@ -101,16 +101,18 @@
|
||||
//!
|
||||
//! match result {
|
||||
//! Err(e) => match e {
|
||||
//! Error::HttpError(err) => println!("HTTPERROR: {:?}", err),
|
||||
//! Error::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
|
||||
//! Error::MissingToken => println!("OAuth2: Missing Token"),
|
||||
//! Error::Cancelled => println!("Operation canceled by user"),
|
||||
//! Error::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
|
||||
//! Error::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
|
||||
//! Error::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
|
||||
//! Error::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
|
||||
//! // The Error enum provides details about what exactly happened.
|
||||
//! // You can also just use its `Debug`, `Display` or `Error` traits
|
||||
//! Error::HttpError(_)
|
||||
//! |Error::MissingAPIKey
|
||||
//! |Error::MissingToken
|
||||
//! |Error::Cancelled
|
||||
//! |Error::UploadSizeLimitExceeded(_, _)
|
||||
//! |Error::Failure(_)
|
||||
//! |Error::FieldClash(_)
|
||||
//! |Error::JsonDecodeError(_) => println!("{}", e),
|
||||
//! },
|
||||
//! Ok(_) => println!("Success (value doesn't print)"),
|
||||
//! Ok(res) => println!("Success: {:?}", res),
|
||||
//! }
|
||||
//! # }
|
||||
//! ```
|
||||
@@ -274,16 +276,18 @@ impl Default for Scope {
|
||||
///
|
||||
/// match result {
|
||||
/// Err(e) => match e {
|
||||
/// Error::HttpError(err) => println!("HTTPERROR: {:?}", err),
|
||||
/// Error::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
|
||||
/// Error::MissingToken => println!("OAuth2: Missing Token"),
|
||||
/// Error::Cancelled => println!("Operation canceled by user"),
|
||||
/// Error::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
|
||||
/// Error::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
|
||||
/// Error::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
|
||||
/// Error::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
|
||||
/// // The Error enum provides details about what exactly happened.
|
||||
/// // You can also just use its `Debug`, `Display` or `Error` traits
|
||||
/// Error::HttpError(_)
|
||||
/// |Error::MissingAPIKey
|
||||
/// |Error::MissingToken
|
||||
/// |Error::Cancelled
|
||||
/// |Error::UploadSizeLimitExceeded(_, _)
|
||||
/// |Error::Failure(_)
|
||||
/// |Error::FieldClash(_)
|
||||
/// |Error::JsonDecodeError(_) => println!("{}", e),
|
||||
/// },
|
||||
/// Ok(_) => println!("Success (value doesn't print)"),
|
||||
/// Ok(res) => println!("Success: {:?}", res),
|
||||
/// }
|
||||
/// # }
|
||||
/// ```
|
||||
@@ -409,7 +413,7 @@ impl RequestValue for AggregatedStats {}
|
||||
///
|
||||
/// * [updateaggregatedstats statscollection](struct.StatscollectionUpdateaggregatedstatCall.html) (response)
|
||||
///
|
||||
#[derive(Default, Clone, Debug, Deserialize)]
|
||||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct AggregatedStatsReply {
|
||||
/// no description provided
|
||||
#[serde(rename="testValue")]
|
||||
@@ -443,7 +447,7 @@ impl Part for DoubleValue {}
|
||||
///
|
||||
/// * [updatestats statscollection](struct.StatscollectionUpdatestatCall.html) (response)
|
||||
///
|
||||
#[derive(Default, Clone, Debug, Deserialize)]
|
||||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct StatsReply {
|
||||
/// no description provided
|
||||
#[serde(rename="testValue")]
|
||||
@@ -696,22 +700,21 @@ impl<'a, C, A> StatscollectionUpdateaggregatedstatCall<'a, C, A> where C: Borrow
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Sets the *request* property to the given value.
|
||||
///
|
||||
/// Even though the property as already been set when instantiating this call,
|
||||
/// we provide this method for API completeness.
|
||||
///
|
||||
pub fn request(mut self, new_value: &AggregatedStats) -> StatscollectionUpdateaggregatedstatCall<'a, C, A> {
|
||||
self._request = new_value.clone();
|
||||
self
|
||||
}
|
||||
/// Sets the *delegate* property to the given value.
|
||||
///
|
||||
///
|
||||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||||
/// while executing the actual API request.
|
||||
///
|
||||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||||
///
|
||||
/// Sets the *delegate* property to the given value.
|
||||
pub fn delegate(mut self, new_value: &'a mut Delegate) -> StatscollectionUpdateaggregatedstatCall<'a, C, A> {
|
||||
self._delegate = Some(new_value);
|
||||
self
|
||||
@@ -741,8 +744,8 @@ impl<'a, C, A> StatscollectionUpdateaggregatedstatCall<'a, C, A> where C: Borrow
|
||||
|
||||
/// Identifies the authorization scope for the method you are building.
|
||||
///
|
||||
/// Use this method to actively specify which scope should be used, instead of relying on the
|
||||
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
||||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||||
/// `Scope::MonitoringReadonly`.
|
||||
///
|
||||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||||
/// tokens for more than one scope.
|
||||
@@ -915,22 +918,21 @@ impl<'a, C, A> StatscollectionUpdatestatCall<'a, C, A> where C: BorrowMut<hyper:
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Sets the *request* property to the given value.
|
||||
///
|
||||
/// Even though the property as already been set when instantiating this call,
|
||||
/// we provide this method for API completeness.
|
||||
///
|
||||
pub fn request(mut self, new_value: &Stats) -> StatscollectionUpdatestatCall<'a, C, A> {
|
||||
self._request = new_value.clone();
|
||||
self
|
||||
}
|
||||
/// Sets the *delegate* property to the given value.
|
||||
///
|
||||
///
|
||||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||||
/// while executing the actual API request.
|
||||
///
|
||||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||||
///
|
||||
/// Sets the *delegate* property to the given value.
|
||||
pub fn delegate(mut self, new_value: &'a mut Delegate) -> StatscollectionUpdatestatCall<'a, C, A> {
|
||||
self._delegate = Some(new_value);
|
||||
self
|
||||
@@ -960,8 +962,8 @@ impl<'a, C, A> StatscollectionUpdatestatCall<'a, C, A> where C: BorrowMut<hyper:
|
||||
|
||||
/// Identifies the authorization scope for the method you are building.
|
||||
///
|
||||
/// Use this method to actively specify which scope should be used, instead of relying on the
|
||||
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
||||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||||
/// `Scope::MonitoringReadonly`.
|
||||
///
|
||||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||||
/// tokens for more than one scope.
|
||||
|
||||
Reference in New Issue
Block a user