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

@@ -581,6 +581,90 @@ impl<'n> Engine<'n> {
}
}
fn _projects_repos_sync(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut field_cursor = FieldCursor::default();
let mut object = json::value::Value::Object(Default::default());
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let last_errc = err.issues.len();
let (key, value) = parse_kv_arg(&*kvarg, err, false);
let mut temp_cursor = field_cursor.clone();
if let Err(field_err) = temp_cursor.set(&*key) {
err.issues.push(field_err);
}
if value.is_none() {
field_cursor = temp_cursor.clone();
if err.issues.len() > last_errc {
err.issues.remove(last_errc);
}
continue;
}
let type_info: Option<(&'static str, JsonTypeInfo)> =
match &temp_cursor.to_string()[..] {
_ => {
let suggestion = FieldCursor::did_you_mean(key, &vec![]);
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
None
}
};
if let Some((field_cursor_str, type_info)) = type_info {
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
}
}
let mut request: api::SyncRepoRequest = json::value::from_value(object).unwrap();
let mut call = self.hub.projects().repos_sync(request, opt.value_of("name").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 _projects_repos_test_iam_permissions(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
@@ -784,6 +868,9 @@ impl<'n> Engine<'n> {
("repos-set-iam-policy", Some(opt)) => {
call_result = self._projects_repos_set_iam_policy(opt, dry_run, &mut err);
},
("repos-sync", Some(opt)) => {
call_result = self._projects_repos_sync(opt, dry_run, &mut err);
},
("repos-test-iam-permissions", Some(opt)) => {
call_result = self._projects_repos_test_iam_permissions(opt, dry_run, &mut err);
},
@@ -881,7 +968,7 @@ impl<'n> Engine<'n> {
fn main() {
let mut exit_status = 0i32;
let arg_data = [
("projects", "methods: 'get-config', 'repos-create', 'repos-delete', 'repos-get', 'repos-get-iam-policy', 'repos-list', 'repos-patch', 'repos-set-iam-policy', 'repos-test-iam-permissions' and 'update-config'", vec![
("projects", "methods: 'get-config', 'repos-create', 'repos-delete', 'repos-get', 'repos-get-iam-policy', 'repos-list', 'repos-patch', 'repos-set-iam-policy', 'repos-sync', 'repos-test-iam-permissions' and 'update-config'", vec![
("get-config",
Some(r##"Returns the Cloud Source Repositories configuration of the project."##),
"Details at http://byron.github.io/google-apis-rs/google_sourcerepo1_cli/projects_get-config",
@@ -1085,6 +1172,37 @@ fn main() {
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)),
]),
("repos-sync",
Some(r##"Synchronize a connected repo.
The response contains SyncRepoMetadata in the metadata field."##),
"Details at http://byron.github.io/google-apis-rs/google_sourcerepo1_cli/projects_repos-sync",
vec![
(Some(r##"name"##),
None,
Some(r##"The name of the repo to synchronize. Values are of the form
`projects/<project>/repos/<repo>`."##),
Some(true),
Some(false)),
(Some(r##"kv"##),
Some(r##"r"##),
Some(r##"Set various fields of the request structure, matching the key=value form"##),
Some(true),
Some(true)),
(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"##),
@@ -1157,7 +1275,7 @@ fn main() {
let mut app = App::new("sourcerepo1")
.author("Sebastian Thiel <byronimo@gmail.com>")
.version("1.0.8+20190221")
.version("1.0.9+20190611")
.about("Accesses source code repositories hosted by Google.")
.after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_sourcerepo1_cli")
.arg(Arg::with_name("url")