Bump version to 1.0.9; update JSON schemas; add new APIs

This commit is contained in:
Sebastian Thiel
2019-07-05 11:32:35 +08:00
parent 99e97ceece
commit e42ebc0c2b
2442 changed files with 190984 additions and 71186 deletions

View File

@@ -67,6 +67,17 @@ pub fn remove_json_null_values(value: &mut Value) {
map.remove(key);
}
}
json::value::Value::Array(ref mut arr) => {
let mut i = 0;
while i < arr.len() {
if arr[i].is_null() {
arr.remove(i);
} else {
remove_json_null_values(&mut arr[i]);
i += 1;
}
}
}
_ => {}
}
}

View File

@@ -525,216 +525,6 @@ impl<'n> Engine<'n> {
}
}
fn _urlcrawlerrorscounts_query(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut call = self.hub.urlcrawlerrorscounts().query(opt.value_of("site-url").unwrap_or(""));
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let (key, value) = parse_kv_arg(&*parg, err, false);
match key {
"platform" => {
call = call.platform(value.unwrap_or(""));
},
"latest-counts-only" => {
call = call.latest_counts_only(arg_from_str(value.unwrap_or("false"), err, "latest-counts-only", "boolean"));
},
"category" => {
call = call.category(value.unwrap_or(""));
},
_ => {
let mut found = false;
for param in &self.gp {
if key == *param {
found = true;
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
break;
}
}
if !found {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v.extend(["category", "platform", "latest-counts-only"].iter().map(|v|*v));
v } ));
}
}
}
}
let protocol = CallType::Standard;
if dry_run {
Ok(())
} else {
assert!(err.issues.len() == 0);
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
call = call.add_scope(scope);
}
let mut ostream = match writer_from_opts(opt.value_of("out")) {
Ok(mut f) => f,
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
};
match match protocol {
CallType::Standard => call.doit(),
_ => unreachable!()
} {
Err(api_err) => Err(DoitError::ApiError(api_err)),
Ok((mut response, output_schema)) => {
let mut value = json::value::to_value(&output_schema).expect("serde to work");
remove_json_null_values(&mut value);
json::to_writer_pretty(&mut ostream, &value).unwrap();
ostream.flush().unwrap();
Ok(())
}
}
}
}
fn _urlcrawlerrorssamples_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut call = self.hub.urlcrawlerrorssamples().get(opt.value_of("site-url").unwrap_or(""), opt.value_of("url").unwrap_or(""), opt.value_of("category").unwrap_or(""), opt.value_of("platform").unwrap_or(""));
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let (key, value) = parse_kv_arg(&*parg, err, false);
match key {
_ => {
let mut found = false;
for param in &self.gp {
if key == *param {
found = true;
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
break;
}
}
if !found {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v } ));
}
}
}
}
let protocol = CallType::Standard;
if dry_run {
Ok(())
} else {
assert!(err.issues.len() == 0);
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
call = call.add_scope(scope);
}
let mut ostream = match writer_from_opts(opt.value_of("out")) {
Ok(mut f) => f,
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
};
match match protocol {
CallType::Standard => call.doit(),
_ => unreachable!()
} {
Err(api_err) => Err(DoitError::ApiError(api_err)),
Ok((mut response, output_schema)) => {
let mut value = json::value::to_value(&output_schema).expect("serde to work");
remove_json_null_values(&mut value);
json::to_writer_pretty(&mut ostream, &value).unwrap();
ostream.flush().unwrap();
Ok(())
}
}
}
}
fn _urlcrawlerrorssamples_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut call = self.hub.urlcrawlerrorssamples().list(opt.value_of("site-url").unwrap_or(""), opt.value_of("category").unwrap_or(""), opt.value_of("platform").unwrap_or(""));
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let (key, value) = parse_kv_arg(&*parg, err, false);
match key {
_ => {
let mut found = false;
for param in &self.gp {
if key == *param {
found = true;
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
break;
}
}
if !found {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v } ));
}
}
}
}
let protocol = CallType::Standard;
if dry_run {
Ok(())
} else {
assert!(err.issues.len() == 0);
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
call = call.add_scope(scope);
}
let mut ostream = match writer_from_opts(opt.value_of("out")) {
Ok(mut f) => f,
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
};
match match protocol {
CallType::Standard => call.doit(),
_ => unreachable!()
} {
Err(api_err) => Err(DoitError::ApiError(api_err)),
Ok((mut response, output_schema)) => {
let mut value = json::value::to_value(&output_schema).expect("serde to work");
remove_json_null_values(&mut value);
json::to_writer_pretty(&mut ostream, &value).unwrap();
ostream.flush().unwrap();
Ok(())
}
}
}
}
fn _urlcrawlerrorssamples_mark_as_fixed(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut call = self.hub.urlcrawlerrorssamples().mark_as_fixed(opt.value_of("site-url").unwrap_or(""), opt.value_of("url").unwrap_or(""), opt.value_of("category").unwrap_or(""), opt.value_of("platform").unwrap_or(""));
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let (key, value) = parse_kv_arg(&*parg, err, false);
match key {
_ => {
let mut found = false;
for param in &self.gp {
if key == *param {
found = true;
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
break;
}
}
if !found {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v } ));
}
}
}
}
let protocol = CallType::Standard;
if dry_run {
Ok(())
} else {
assert!(err.issues.len() == 0);
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
call = call.add_scope(scope);
}
match match protocol {
CallType::Standard => call.doit(),
_ => unreachable!()
} {
Err(api_err) => Err(DoitError::ApiError(api_err)),
Ok(mut response) => {
Ok(())
}
}
}
}
fn _doit(&self, dry_run: bool) -> Result<Result<(), DoitError>, Option<InvalidOptionsError>> {
let mut err = InvalidOptionsError::new();
let mut call_result: Result<(), DoitError> = Ok(());
@@ -791,34 +581,6 @@ impl<'n> Engine<'n> {
}
}
},
("urlcrawlerrorscounts", Some(opt)) => {
match opt.subcommand() {
("query", Some(opt)) => {
call_result = self._urlcrawlerrorscounts_query(opt, dry_run, &mut err);
},
_ => {
err.issues.push(CLIError::MissingMethodError("urlcrawlerrorscounts".to_string()));
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
}
}
},
("urlcrawlerrorssamples", Some(opt)) => {
match opt.subcommand() {
("get", Some(opt)) => {
call_result = self._urlcrawlerrorssamples_get(opt, dry_run, &mut err);
},
("list", Some(opt)) => {
call_result = self._urlcrawlerrorssamples_list(opt, dry_run, &mut err);
},
("mark-as-fixed", Some(opt)) => {
call_result = self._urlcrawlerrorssamples_mark_as_fixed(opt, dry_run, &mut err);
},
_ => {
err.issues.push(CLIError::MissingMethodError("urlcrawlerrorssamples".to_string()));
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
}
}
},
_ => {
err.issues.push(CLIError::MissingCommandError);
writeln!(io::stderr(), "{}\n", self.opt.usage()).ok();
@@ -1104,147 +866,11 @@ fn main() {
]),
]),
("urlcrawlerrorscounts", "methods: 'query'", vec![
("query",
Some(r##"Retrieves a time series of the number of URL crawl errors per error category and platform."##),
"Details at http://byron.github.io/google-apis-rs/google_webmasters3_cli/urlcrawlerrorscounts_query",
vec![
(Some(r##"site-url"##),
None,
Some(r##"The site's URL, including protocol. For example: http://www.example.com/"##),
Some(true),
Some(false)),
(Some(r##"v"##),
Some(r##"p"##),
Some(r##"Set various optional parameters, matching the key=value form"##),
Some(false),
Some(true)),
(Some(r##"out"##),
Some(r##"o"##),
Some(r##"Specify the file into which to write the program's output"##),
Some(false),
Some(false)),
]),
]),
("urlcrawlerrorssamples", "methods: 'get', 'list' and 'mark-as-fixed'", vec![
("get",
Some(r##"Retrieves details about crawl errors for a site's sample URL."##),
"Details at http://byron.github.io/google-apis-rs/google_webmasters3_cli/urlcrawlerrorssamples_get",
vec![
(Some(r##"site-url"##),
None,
Some(r##"The site's URL, including protocol. For example: http://www.example.com/"##),
Some(true),
Some(false)),
(Some(r##"url"##),
None,
Some(r##"The relative path (without the site) of the sample URL. It must be one of the URLs returned by list(). For example, for the URL https://www.example.com/pagename on the site https://www.example.com/, the url value is pagename"##),
Some(true),
Some(false)),
(Some(r##"category"##),
None,
Some(r##"The crawl error category. For example: authPermissions"##),
Some(true),
Some(false)),
(Some(r##"platform"##),
None,
Some(r##"The user agent type (platform) that made the request. For example: web"##),
Some(true),
Some(false)),
(Some(r##"v"##),
Some(r##"p"##),
Some(r##"Set various optional parameters, matching the key=value form"##),
Some(false),
Some(true)),
(Some(r##"out"##),
Some(r##"o"##),
Some(r##"Specify the file into which to write the program's output"##),
Some(false),
Some(false)),
]),
("list",
Some(r##"Lists a site's sample URLs for the specified crawl error category and platform."##),
"Details at http://byron.github.io/google-apis-rs/google_webmasters3_cli/urlcrawlerrorssamples_list",
vec![
(Some(r##"site-url"##),
None,
Some(r##"The site's URL, including protocol. For example: http://www.example.com/"##),
Some(true),
Some(false)),
(Some(r##"category"##),
None,
Some(r##"The crawl error category. For example: authPermissions"##),
Some(true),
Some(false)),
(Some(r##"platform"##),
None,
Some(r##"The user agent type (platform) that made the request. For example: web"##),
Some(true),
Some(false)),
(Some(r##"v"##),
Some(r##"p"##),
Some(r##"Set various optional parameters, matching the key=value form"##),
Some(false),
Some(true)),
(Some(r##"out"##),
Some(r##"o"##),
Some(r##"Specify the file into which to write the program's output"##),
Some(false),
Some(false)),
]),
("mark-as-fixed",
Some(r##"Marks the provided site's sample URL as fixed, and removes it from the samples list."##),
"Details at http://byron.github.io/google-apis-rs/google_webmasters3_cli/urlcrawlerrorssamples_mark-as-fixed",
vec![
(Some(r##"site-url"##),
None,
Some(r##"The site's URL, including protocol. For example: http://www.example.com/"##),
Some(true),
Some(false)),
(Some(r##"url"##),
None,
Some(r##"The relative path (without the site) of the sample URL. It must be one of the URLs returned by list(). For example, for the URL https://www.example.com/pagename on the site https://www.example.com/, the url value is pagename"##),
Some(true),
Some(false)),
(Some(r##"category"##),
None,
Some(r##"The crawl error category. For example: authPermissions"##),
Some(true),
Some(false)),
(Some(r##"platform"##),
None,
Some(r##"The user agent type (platform) that made the request. For example: web"##),
Some(true),
Some(false)),
(Some(r##"v"##),
Some(r##"p"##),
Some(r##"Set various optional parameters, matching the key=value form"##),
Some(false),
Some(true)),
]),
]),
];
let mut app = App::new("webmasters3")
.author("Sebastian Thiel <byronimo@gmail.com>")
.version("1.0.8+20180627")
.version("1.0.9+20190428")
.about("View Google Search Console data for your verified sites.")
.after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_webmasters3_cli")
.arg(Arg::with_name("url")