mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-02-23 15:49:49 +01:00
prepare release of version 2.0, regen all APIs
This commit is contained in:
@@ -3,50 +3,46 @@
|
||||
// DO NOT EDIT !
|
||||
#![allow(unused_variables, unused_imports, dead_code, unused_mut)]
|
||||
|
||||
extern crate tokio;
|
||||
|
||||
#[macro_use]
|
||||
extern crate clap;
|
||||
extern crate yup_oauth2 as oauth2;
|
||||
extern crate yup_hyper_mock as mock;
|
||||
extern crate hyper_rustls;
|
||||
extern crate serde;
|
||||
extern crate serde_json;
|
||||
extern crate hyper;
|
||||
extern crate mime;
|
||||
extern crate strsim;
|
||||
extern crate google_adexchangeseller2 as api;
|
||||
|
||||
use std::env;
|
||||
use std::io::{self, Write};
|
||||
use clap::{App, SubCommand, Arg};
|
||||
|
||||
mod cmn;
|
||||
use google_adexchangeseller2::{api, Error};
|
||||
|
||||
use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg,
|
||||
mod client;
|
||||
|
||||
use client::{InvalidOptionsError, CLIError, arg_from_str, writer_from_opts, parse_kv_arg,
|
||||
input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError, CallType, UploadProtocol,
|
||||
calltype_from_str, remove_json_null_values, ComplexType, JsonType, JsonTypeInfo};
|
||||
|
||||
use std::default::Default;
|
||||
use std::str::FromStr;
|
||||
|
||||
use oauth2::{Authenticator, DefaultAuthenticatorDelegate, FlowType};
|
||||
use serde_json as json;
|
||||
use clap::ArgMatches;
|
||||
|
||||
enum DoitError {
|
||||
IoError(String, io::Error),
|
||||
ApiError(api::Error),
|
||||
ApiError(Error),
|
||||
}
|
||||
|
||||
struct Engine<'n> {
|
||||
opt: ArgMatches<'n>,
|
||||
hub: api::AdExchangeSeller<hyper::Client, Authenticator<DefaultAuthenticatorDelegate, JsonTokenStorage, hyper::Client>>,
|
||||
hub: api::AdExchangeSeller<hyper::Client<hyper_rustls::HttpsConnector<hyper::client::connect::HttpConnector>, hyper::body::Body>
|
||||
>,
|
||||
gp: Vec<&'static str>,
|
||||
gpm: Vec<(&'static str, &'static str)>,
|
||||
}
|
||||
|
||||
|
||||
impl<'n> Engine<'n> {
|
||||
fn _accounts_adclients_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
async fn _accounts_adclients_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
-> Result<(), DoitError> {
|
||||
let mut call = self.hub.accounts().adclients_list(opt.value_of("account-id").unwrap_or(""));
|
||||
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
||||
@@ -90,7 +86,7 @@ impl<'n> Engine<'n> {
|
||||
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
||||
};
|
||||
match match protocol {
|
||||
CallType::Standard => call.doit(),
|
||||
CallType::Standard => call.doit().await,
|
||||
_ => unreachable!()
|
||||
} {
|
||||
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
||||
@@ -105,7 +101,7 @@ impl<'n> Engine<'n> {
|
||||
}
|
||||
}
|
||||
|
||||
fn _accounts_alerts_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
async fn _accounts_alerts_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
-> Result<(), DoitError> {
|
||||
let mut call = self.hub.accounts().alerts_list(opt.value_of("account-id").unwrap_or(""));
|
||||
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
||||
@@ -146,7 +142,7 @@ impl<'n> Engine<'n> {
|
||||
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
||||
};
|
||||
match match protocol {
|
||||
CallType::Standard => call.doit(),
|
||||
CallType::Standard => call.doit().await,
|
||||
_ => unreachable!()
|
||||
} {
|
||||
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
||||
@@ -161,7 +157,7 @@ impl<'n> Engine<'n> {
|
||||
}
|
||||
}
|
||||
|
||||
fn _accounts_customchannels_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
async fn _accounts_customchannels_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
-> Result<(), DoitError> {
|
||||
let mut call = self.hub.accounts().customchannels_get(opt.value_of("account-id").unwrap_or(""), opt.value_of("ad-client-id").unwrap_or(""), opt.value_of("custom-channel-id").unwrap_or(""));
|
||||
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
||||
@@ -198,7 +194,7 @@ impl<'n> Engine<'n> {
|
||||
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
||||
};
|
||||
match match protocol {
|
||||
CallType::Standard => call.doit(),
|
||||
CallType::Standard => call.doit().await,
|
||||
_ => unreachable!()
|
||||
} {
|
||||
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
||||
@@ -213,7 +209,7 @@ impl<'n> Engine<'n> {
|
||||
}
|
||||
}
|
||||
|
||||
fn _accounts_customchannels_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
async fn _accounts_customchannels_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
-> Result<(), DoitError> {
|
||||
let mut call = self.hub.accounts().customchannels_list(opt.value_of("account-id").unwrap_or(""), opt.value_of("ad-client-id").unwrap_or(""));
|
||||
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
||||
@@ -257,7 +253,7 @@ impl<'n> Engine<'n> {
|
||||
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
||||
};
|
||||
match match protocol {
|
||||
CallType::Standard => call.doit(),
|
||||
CallType::Standard => call.doit().await,
|
||||
_ => unreachable!()
|
||||
} {
|
||||
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
||||
@@ -272,7 +268,7 @@ impl<'n> Engine<'n> {
|
||||
}
|
||||
}
|
||||
|
||||
fn _accounts_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
async fn _accounts_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
-> Result<(), DoitError> {
|
||||
let mut call = self.hub.accounts().get(opt.value_of("account-id").unwrap_or(""));
|
||||
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
||||
@@ -309,7 +305,7 @@ impl<'n> Engine<'n> {
|
||||
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
||||
};
|
||||
match match protocol {
|
||||
CallType::Standard => call.doit(),
|
||||
CallType::Standard => call.doit().await,
|
||||
_ => unreachable!()
|
||||
} {
|
||||
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
||||
@@ -324,7 +320,7 @@ impl<'n> Engine<'n> {
|
||||
}
|
||||
}
|
||||
|
||||
fn _accounts_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
async fn _accounts_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
-> Result<(), DoitError> {
|
||||
let mut call = self.hub.accounts().list();
|
||||
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
||||
@@ -368,7 +364,7 @@ impl<'n> Engine<'n> {
|
||||
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
||||
};
|
||||
match match protocol {
|
||||
CallType::Standard => call.doit(),
|
||||
CallType::Standard => call.doit().await,
|
||||
_ => unreachable!()
|
||||
} {
|
||||
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
||||
@@ -383,7 +379,7 @@ impl<'n> Engine<'n> {
|
||||
}
|
||||
}
|
||||
|
||||
fn _accounts_metadata_dimensions_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
async fn _accounts_metadata_dimensions_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
-> Result<(), DoitError> {
|
||||
let mut call = self.hub.accounts().metadata_dimensions_list(opt.value_of("account-id").unwrap_or(""));
|
||||
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
||||
@@ -420,7 +416,7 @@ impl<'n> Engine<'n> {
|
||||
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
||||
};
|
||||
match match protocol {
|
||||
CallType::Standard => call.doit(),
|
||||
CallType::Standard => call.doit().await,
|
||||
_ => unreachable!()
|
||||
} {
|
||||
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
||||
@@ -435,7 +431,7 @@ impl<'n> Engine<'n> {
|
||||
}
|
||||
}
|
||||
|
||||
fn _accounts_metadata_metrics_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
async fn _accounts_metadata_metrics_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
-> Result<(), DoitError> {
|
||||
let mut call = self.hub.accounts().metadata_metrics_list(opt.value_of("account-id").unwrap_or(""));
|
||||
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
||||
@@ -472,7 +468,7 @@ impl<'n> Engine<'n> {
|
||||
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
||||
};
|
||||
match match protocol {
|
||||
CallType::Standard => call.doit(),
|
||||
CallType::Standard => call.doit().await,
|
||||
_ => unreachable!()
|
||||
} {
|
||||
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
||||
@@ -487,7 +483,7 @@ impl<'n> Engine<'n> {
|
||||
}
|
||||
}
|
||||
|
||||
fn _accounts_preferreddeals_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
async fn _accounts_preferreddeals_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
-> Result<(), DoitError> {
|
||||
let mut call = self.hub.accounts().preferreddeals_get(opt.value_of("account-id").unwrap_or(""), opt.value_of("deal-id").unwrap_or(""));
|
||||
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
||||
@@ -524,7 +520,7 @@ impl<'n> Engine<'n> {
|
||||
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
||||
};
|
||||
match match protocol {
|
||||
CallType::Standard => call.doit(),
|
||||
CallType::Standard => call.doit().await,
|
||||
_ => unreachable!()
|
||||
} {
|
||||
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
||||
@@ -539,7 +535,7 @@ impl<'n> Engine<'n> {
|
||||
}
|
||||
}
|
||||
|
||||
fn _accounts_preferreddeals_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
async fn _accounts_preferreddeals_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
-> Result<(), DoitError> {
|
||||
let mut call = self.hub.accounts().preferreddeals_list(opt.value_of("account-id").unwrap_or(""));
|
||||
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
||||
@@ -576,7 +572,7 @@ impl<'n> Engine<'n> {
|
||||
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
||||
};
|
||||
match match protocol {
|
||||
CallType::Standard => call.doit(),
|
||||
CallType::Standard => call.doit().await,
|
||||
_ => unreachable!()
|
||||
} {
|
||||
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
||||
@@ -591,7 +587,7 @@ impl<'n> Engine<'n> {
|
||||
}
|
||||
}
|
||||
|
||||
fn _accounts_reports_generate(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
async fn _accounts_reports_generate(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
-> Result<(), DoitError> {
|
||||
let mut download_mode = false;
|
||||
let mut call = self.hub.accounts().reports_generate(opt.value_of("account-id").unwrap_or(""), opt.value_of("start-date").unwrap_or(""), opt.value_of("end-date").unwrap_or(""));
|
||||
@@ -635,7 +631,7 @@ impl<'n> Engine<'n> {
|
||||
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
||||
{let mut v = Vec::new();
|
||||
v.extend(self.gp.iter().map(|v|*v));
|
||||
v.extend(["sort", "locale", "metric", "max-results", "filter", "start-index", "dimension"].iter().map(|v|*v));
|
||||
v.extend(["dimension", "max-results", "start-index", "locale", "filter", "metric", "sort"].iter().map(|v|*v));
|
||||
v } ));
|
||||
}
|
||||
}
|
||||
@@ -654,7 +650,7 @@ impl<'n> Engine<'n> {
|
||||
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
||||
};
|
||||
match match protocol {
|
||||
CallType::Standard => call.doit(),
|
||||
CallType::Standard => call.doit().await,
|
||||
_ => unreachable!()
|
||||
} {
|
||||
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
||||
@@ -665,8 +661,9 @@ impl<'n> Engine<'n> {
|
||||
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
||||
ostream.flush().unwrap();
|
||||
} else {
|
||||
io::copy(&mut response, &mut ostream).unwrap();
|
||||
ostream.flush().unwrap();
|
||||
let bytes = hyper::body::to_bytes(response.into_body()).await.expect("a string as API currently is inefficient").to_vec();
|
||||
ostream.write_all(&bytes).expect("write to be complete");
|
||||
ostream.flush().expect("io to never fail which should really be fixed one day");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -674,7 +671,7 @@ impl<'n> Engine<'n> {
|
||||
}
|
||||
}
|
||||
|
||||
fn _accounts_reports_saved_generate(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
async fn _accounts_reports_saved_generate(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
-> Result<(), DoitError> {
|
||||
let mut call = self.hub.accounts().reports_saved_generate(opt.value_of("account-id").unwrap_or(""), opt.value_of("saved-report-id").unwrap_or(""));
|
||||
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
||||
@@ -702,7 +699,7 @@ impl<'n> Engine<'n> {
|
||||
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
||||
{let mut v = Vec::new();
|
||||
v.extend(self.gp.iter().map(|v|*v));
|
||||
v.extend(["locale", "start-index", "max-results"].iter().map(|v|*v));
|
||||
v.extend(["locale", "max-results", "start-index"].iter().map(|v|*v));
|
||||
v } ));
|
||||
}
|
||||
}
|
||||
@@ -721,7 +718,7 @@ impl<'n> Engine<'n> {
|
||||
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
||||
};
|
||||
match match protocol {
|
||||
CallType::Standard => call.doit(),
|
||||
CallType::Standard => call.doit().await,
|
||||
_ => unreachable!()
|
||||
} {
|
||||
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
||||
@@ -736,7 +733,7 @@ impl<'n> Engine<'n> {
|
||||
}
|
||||
}
|
||||
|
||||
fn _accounts_reports_saved_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
async fn _accounts_reports_saved_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
-> Result<(), DoitError> {
|
||||
let mut call = self.hub.accounts().reports_saved_list(opt.value_of("account-id").unwrap_or(""));
|
||||
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
||||
@@ -780,7 +777,7 @@ impl<'n> Engine<'n> {
|
||||
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
||||
};
|
||||
match match protocol {
|
||||
CallType::Standard => call.doit(),
|
||||
CallType::Standard => call.doit().await,
|
||||
_ => unreachable!()
|
||||
} {
|
||||
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
||||
@@ -795,7 +792,7 @@ impl<'n> Engine<'n> {
|
||||
}
|
||||
}
|
||||
|
||||
fn _accounts_urlchannels_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
async fn _accounts_urlchannels_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
-> Result<(), DoitError> {
|
||||
let mut call = self.hub.accounts().urlchannels_list(opt.value_of("account-id").unwrap_or(""), opt.value_of("ad-client-id").unwrap_or(""));
|
||||
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
||||
@@ -839,7 +836,7 @@ impl<'n> Engine<'n> {
|
||||
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
||||
};
|
||||
match match protocol {
|
||||
CallType::Standard => call.doit(),
|
||||
CallType::Standard => call.doit().await,
|
||||
_ => unreachable!()
|
||||
} {
|
||||
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
||||
@@ -854,7 +851,7 @@ impl<'n> Engine<'n> {
|
||||
}
|
||||
}
|
||||
|
||||
fn _doit(&self, dry_run: bool) -> Result<Result<(), DoitError>, Option<InvalidOptionsError>> {
|
||||
async fn _doit(&self, dry_run: bool) -> Result<Result<(), DoitError>, Option<InvalidOptionsError>> {
|
||||
let mut err = InvalidOptionsError::new();
|
||||
let mut call_result: Result<(), DoitError> = Ok(());
|
||||
let mut err_opt: Option<InvalidOptionsError> = None;
|
||||
@@ -862,46 +859,46 @@ impl<'n> Engine<'n> {
|
||||
("accounts", Some(opt)) => {
|
||||
match opt.subcommand() {
|
||||
("adclients-list", Some(opt)) => {
|
||||
call_result = self._accounts_adclients_list(opt, dry_run, &mut err);
|
||||
call_result = self._accounts_adclients_list(opt, dry_run, &mut err).await;
|
||||
},
|
||||
("alerts-list", Some(opt)) => {
|
||||
call_result = self._accounts_alerts_list(opt, dry_run, &mut err);
|
||||
call_result = self._accounts_alerts_list(opt, dry_run, &mut err).await;
|
||||
},
|
||||
("customchannels-get", Some(opt)) => {
|
||||
call_result = self._accounts_customchannels_get(opt, dry_run, &mut err);
|
||||
call_result = self._accounts_customchannels_get(opt, dry_run, &mut err).await;
|
||||
},
|
||||
("customchannels-list", Some(opt)) => {
|
||||
call_result = self._accounts_customchannels_list(opt, dry_run, &mut err);
|
||||
call_result = self._accounts_customchannels_list(opt, dry_run, &mut err).await;
|
||||
},
|
||||
("get", Some(opt)) => {
|
||||
call_result = self._accounts_get(opt, dry_run, &mut err);
|
||||
call_result = self._accounts_get(opt, dry_run, &mut err).await;
|
||||
},
|
||||
("list", Some(opt)) => {
|
||||
call_result = self._accounts_list(opt, dry_run, &mut err);
|
||||
call_result = self._accounts_list(opt, dry_run, &mut err).await;
|
||||
},
|
||||
("metadata-dimensions-list", Some(opt)) => {
|
||||
call_result = self._accounts_metadata_dimensions_list(opt, dry_run, &mut err);
|
||||
call_result = self._accounts_metadata_dimensions_list(opt, dry_run, &mut err).await;
|
||||
},
|
||||
("metadata-metrics-list", Some(opt)) => {
|
||||
call_result = self._accounts_metadata_metrics_list(opt, dry_run, &mut err);
|
||||
call_result = self._accounts_metadata_metrics_list(opt, dry_run, &mut err).await;
|
||||
},
|
||||
("preferreddeals-get", Some(opt)) => {
|
||||
call_result = self._accounts_preferreddeals_get(opt, dry_run, &mut err);
|
||||
call_result = self._accounts_preferreddeals_get(opt, dry_run, &mut err).await;
|
||||
},
|
||||
("preferreddeals-list", Some(opt)) => {
|
||||
call_result = self._accounts_preferreddeals_list(opt, dry_run, &mut err);
|
||||
call_result = self._accounts_preferreddeals_list(opt, dry_run, &mut err).await;
|
||||
},
|
||||
("reports-generate", Some(opt)) => {
|
||||
call_result = self._accounts_reports_generate(opt, dry_run, &mut err);
|
||||
call_result = self._accounts_reports_generate(opt, dry_run, &mut err).await;
|
||||
},
|
||||
("reports-saved-generate", Some(opt)) => {
|
||||
call_result = self._accounts_reports_saved_generate(opt, dry_run, &mut err);
|
||||
call_result = self._accounts_reports_saved_generate(opt, dry_run, &mut err).await;
|
||||
},
|
||||
("reports-saved-list", Some(opt)) => {
|
||||
call_result = self._accounts_reports_saved_list(opt, dry_run, &mut err);
|
||||
call_result = self._accounts_reports_saved_list(opt, dry_run, &mut err).await;
|
||||
},
|
||||
("urlchannels-list", Some(opt)) => {
|
||||
call_result = self._accounts_urlchannels_list(opt, dry_run, &mut err);
|
||||
call_result = self._accounts_urlchannels_list(opt, dry_run, &mut err).await;
|
||||
},
|
||||
_ => {
|
||||
err.issues.push(CLIError::MissingMethodError("accounts".to_string()));
|
||||
@@ -926,41 +923,26 @@ impl<'n> Engine<'n> {
|
||||
}
|
||||
|
||||
// Please note that this call will fail if any part of the opt can't be handled
|
||||
fn new(opt: ArgMatches<'n>) -> Result<Engine<'n>, InvalidOptionsError> {
|
||||
async fn new(opt: ArgMatches<'n>) -> Result<Engine<'n>, InvalidOptionsError> {
|
||||
let (config_dir, secret) = {
|
||||
let config_dir = match cmn::assure_config_dir_exists(opt.value_of("folder").unwrap_or("~/.google-service-cli")) {
|
||||
let config_dir = match client::assure_config_dir_exists(opt.value_of("folder").unwrap_or("~/.google-service-cli")) {
|
||||
Err(e) => return Err(InvalidOptionsError::single(e, 3)),
|
||||
Ok(p) => p,
|
||||
};
|
||||
|
||||
match cmn::application_secret_from_directory(&config_dir, "adexchangeseller2-secret.json",
|
||||
match client::application_secret_from_directory(&config_dir, "adexchangeseller2-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,
|
||||
if opt.is_present("debug-auth") {
|
||||
hyper::Client::with_connector(mock::TeeConnector {
|
||||
connector: hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())
|
||||
})
|
||||
} else {
|
||||
hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new()))
|
||||
},
|
||||
JsonTokenStorage {
|
||||
program_name: "adexchangeseller2",
|
||||
db_dir: config_dir.clone(),
|
||||
}, Some(FlowType::InstalledRedirect(54324)));
|
||||
let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
|
||||
secret,
|
||||
yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||||
).persist_tokens_to_disk(format!("{}/adexchangeseller2", config_dir)).build().await.unwrap();
|
||||
|
||||
let client =
|
||||
if opt.is_present("debug") {
|
||||
hyper::Client::with_connector(mock::TeeConnector {
|
||||
connector: hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())
|
||||
})
|
||||
} else {
|
||||
hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new()))
|
||||
};
|
||||
let client = hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots());
|
||||
let engine = Engine {
|
||||
opt: opt,
|
||||
hub: api::AdExchangeSeller::new(client, auth),
|
||||
@@ -973,22 +955,23 @@ impl<'n> Engine<'n> {
|
||||
]
|
||||
};
|
||||
|
||||
match engine._doit(true) {
|
||||
match engine._doit(true).await {
|
||||
Err(Some(err)) => Err(err),
|
||||
Err(None) => Ok(engine),
|
||||
Ok(_) => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
fn doit(&self) -> Result<(), DoitError> {
|
||||
match self._doit(false) {
|
||||
async fn doit(&self) -> Result<(), DoitError> {
|
||||
match self._doit(false).await {
|
||||
Ok(res) => res,
|
||||
Err(_) => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let mut exit_status = 0i32;
|
||||
let arg_data = [
|
||||
("accounts", "methods: 'adclients-list', 'alerts-list', 'customchannels-get', 'customchannels-list', 'get', 'list', 'metadata-dimensions-list', 'metadata-metrics-list', 'preferreddeals-get', 'preferreddeals-list', 'reports-generate', 'reports-saved-generate', 'reports-saved-list' and 'urlchannels-list'", vec![
|
||||
@@ -1348,7 +1331,7 @@ fn main() {
|
||||
|
||||
let mut app = App::new("adexchangeseller2")
|
||||
.author("Sebastian Thiel <byronimo@gmail.com>")
|
||||
.version("1.0.14+20171101")
|
||||
.version("2.0.0+20171101")
|
||||
.about("Accesses the inventory of Ad Exchange seller users and generates reports.")
|
||||
.after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_adexchangeseller2_cli")
|
||||
.arg(Arg::with_name("url")
|
||||
@@ -1363,12 +1346,7 @@ fn main() {
|
||||
.takes_value(true))
|
||||
.arg(Arg::with_name("debug")
|
||||
.long("debug")
|
||||
.help("Output all server communication to standard error. `tx` and `rx` are placed into the same stream.")
|
||||
.multiple(false)
|
||||
.takes_value(false))
|
||||
.arg(Arg::with_name("debug-auth")
|
||||
.long("debug-auth")
|
||||
.help("Output all communication related to authentication to standard error. `tx` and `rx` are placed into the same stream.")
|
||||
.help("Debug print all errors")
|
||||
.multiple(false)
|
||||
.takes_value(false));
|
||||
|
||||
@@ -1416,13 +1394,13 @@ fn main() {
|
||||
let matches = app.get_matches();
|
||||
|
||||
let debug = matches.is_present("debug");
|
||||
match Engine::new(matches) {
|
||||
match Engine::new(matches).await {
|
||||
Err(err) => {
|
||||
exit_status = err.exit_code;
|
||||
writeln!(io::stderr(), "{}", err).ok();
|
||||
},
|
||||
Ok(engine) => {
|
||||
if let Err(doit_err) = engine.doit() {
|
||||
if let Err(doit_err) = engine.doit().await {
|
||||
exit_status = 1;
|
||||
match doit_err {
|
||||
DoitError::IoError(path, err) => {
|
||||
@@ -1441,4 +1419,4 @@ fn main() {
|
||||
}
|
||||
|
||||
std::process::exit(exit_status);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user