mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-02-23 15:49:49 +01:00
fix(all): update all code to latest version
* add new APIs * remove old ones * add latest json files
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
extern crate docopt;
|
||||
extern crate yup_oauth2 as oauth2;
|
||||
extern crate yup_hyper_mock as mock;
|
||||
extern crate rustc_serialize;
|
||||
extern crate serde;
|
||||
extern crate hyper;
|
||||
@@ -33,6 +34,12 @@ Configuration:
|
||||
A directory into which we will store our persistent data. Defaults to a user-writable
|
||||
directory that we will create during the first invocation.
|
||||
[default: ~/.google-service-cli]
|
||||
--debug
|
||||
Output all server communication to standard error. `tx` and `rx` are placed into
|
||||
the same stream.
|
||||
--debug-auth
|
||||
Output all communication related to authentication to standard error. `tx` and `rx` are placed into
|
||||
the same stream.
|
||||
");
|
||||
|
||||
mod cmn;
|
||||
@@ -54,10 +61,10 @@ struct Engine {
|
||||
impl Engine {
|
||||
fn _statscollection_updateaggregatedstats(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
-> Option<api::Error> {
|
||||
let mut request: api::AggregatedStats = Default::default();
|
||||
let mut request = api::AggregatedStats::default();
|
||||
let mut call = self.hub.statscollection().updateaggregatedstats(&request);
|
||||
for parg in self.opt.arg_v.iter() {
|
||||
let (key, value) = parse_kv_arg(&*parg, err);
|
||||
let (key, value) = parse_kv_arg(&*parg, err, false);
|
||||
match key {
|
||||
"alt"
|
||||
|"fields"
|
||||
@@ -77,9 +84,10 @@ impl Engine {
|
||||
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
||||
}
|
||||
}
|
||||
let mut field_name: FieldCursor = Default::default();
|
||||
|
||||
let mut field_name = FieldCursor::default();
|
||||
for kvarg in self.opt.arg_kv.iter() {
|
||||
let (key, value) = parse_kv_arg(&*kvarg, err);
|
||||
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
||||
if let Err(field_err) = field_name.set(&*key) {
|
||||
err.issues.push(field_err);
|
||||
}
|
||||
@@ -101,8 +109,7 @@ impl Engine {
|
||||
} {
|
||||
Err(api_err) => Some(api_err),
|
||||
Ok((mut response, output_schema)) => {
|
||||
println!("DEBUG: REMOVE ME {:?}", response);
|
||||
serde::json::to_writer(&mut ostream, &output_schema).unwrap();
|
||||
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
||||
None
|
||||
}
|
||||
}
|
||||
@@ -111,10 +118,10 @@ impl Engine {
|
||||
|
||||
fn _statscollection_updatestats(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
-> Option<api::Error> {
|
||||
let mut request: api::Stats = Default::default();
|
||||
let mut request = api::Stats::default();
|
||||
let mut call = self.hub.statscollection().updatestats(&request);
|
||||
for parg in self.opt.arg_v.iter() {
|
||||
let (key, value) = parse_kv_arg(&*parg, err);
|
||||
let (key, value) = parse_kv_arg(&*parg, err, false);
|
||||
match key {
|
||||
"alt"
|
||||
|"fields"
|
||||
@@ -134,9 +141,10 @@ impl Engine {
|
||||
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
||||
}
|
||||
}
|
||||
let mut field_name: FieldCursor = Default::default();
|
||||
|
||||
let mut field_name = FieldCursor::default();
|
||||
for kvarg in self.opt.arg_kv.iter() {
|
||||
let (key, value) = parse_kv_arg(&*kvarg, err);
|
||||
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
||||
if let Err(field_err) = field_name.set(&*key) {
|
||||
err.issues.push(field_err);
|
||||
}
|
||||
@@ -161,8 +169,7 @@ impl Engine {
|
||||
} {
|
||||
Err(api_err) => Some(api_err),
|
||||
Ok((mut response, output_schema)) => {
|
||||
println!("DEBUG: REMOVE ME {:?}", response);
|
||||
serde::json::to_writer(&mut ostream, &output_schema).unwrap();
|
||||
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
||||
None
|
||||
}
|
||||
}
|
||||
@@ -202,21 +209,37 @@ impl Engine {
|
||||
Ok(p) => p,
|
||||
};
|
||||
|
||||
match cmn::application_secret_from_directory(&config_dir, "cloudlatencytest2-secret.json") {
|
||||
match cmn::application_secret_from_directory(&config_dir, "cloudlatencytest2-secret.json",
|
||||
"{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") {
|
||||
Ok(secret) => (config_dir, secret),
|
||||
Err(e) => return Err(InvalidOptionsError::single(e, 4))
|
||||
}
|
||||
};
|
||||
|
||||
let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||||
hyper::Client::new(),
|
||||
JsonTokenStorage {
|
||||
program_name: "cloudlatencytest2",
|
||||
db_dir: config_dir.clone(),
|
||||
}, None);
|
||||
let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate,
|
||||
if opt.flag_debug_auth {
|
||||
hyper::Client::with_connector(mock::TeeConnector {
|
||||
connector: hyper::net::HttpConnector(None)
|
||||
})
|
||||
} else {
|
||||
hyper::Client::new()
|
||||
},
|
||||
JsonTokenStorage {
|
||||
program_name: "cloudlatencytest2",
|
||||
db_dir: config_dir.clone(),
|
||||
}, None);
|
||||
|
||||
let client =
|
||||
if opt.flag_debug {
|
||||
hyper::Client::with_connector(mock::TeeConnector {
|
||||
connector: hyper::net::HttpConnector(None)
|
||||
})
|
||||
} else {
|
||||
hyper::Client::new()
|
||||
};
|
||||
let engine = Engine {
|
||||
opt: opt,
|
||||
hub: api::Cloudlatencytest::new(hyper::Client::new(), auth),
|
||||
hub: api::Cloudlatencytest::new(client, auth),
|
||||
};
|
||||
|
||||
match engine._doit(true) {
|
||||
@@ -236,12 +259,13 @@ fn main() {
|
||||
let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit());
|
||||
match Engine::new(opts) {
|
||||
Err(err) => {
|
||||
write!(io::stderr(), "{}", err).ok();
|
||||
writeln!(io::stderr(), "{}", err).ok();
|
||||
env::set_exit_status(err.exit_code);
|
||||
},
|
||||
Ok(engine) => {
|
||||
if let Some(err) = engine.doit() {
|
||||
write!(io::stderr(), "{}", err).ok();
|
||||
writeln!(io::stderr(), "{:?}", err).ok();
|
||||
writeln!(io::stderr(), "{}", err).ok();
|
||||
env::set_exit_status(1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user