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

@@ -4,7 +4,7 @@
[package]
name = "google-photoslibrary1-cli"
version = "1.0.8+20190402"
version = "1.0.9+20190702"
authors = ["Sebastian Thiel <byronimo@gmail.com>"]
description = "A complete library to interact with Photos Library (protocol v1)"
repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/photoslibrary1-cli"
@@ -39,4 +39,4 @@ clap = "^2.0"
[dependencies.google-photoslibrary1]
path = "../photoslibrary1"
version = "1.0.8+20190402"
version = "1.0.9+20190702"

View File

@@ -6,7 +6,7 @@ DO NOT EDIT !
The MIT License (MIT)
=====================
Copyright © `2015-2016` `Sebastian Thiel`
Copyright © `2015-2019` `Sebastian Thiel`
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation

View File

@@ -25,12 +25,14 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma
# Usage
This documentation was generated from the *Photos Library* API at revision *20190402*. The CLI is at version *1.0.8*.
This documentation was generated from the *Photos Library* API at revision *20190702*. The CLI is at version *1.0.9*.
```bash
photoslibrary1 [options]
albums
add-enrichment <album-id> (-r <kv>)... [-p <v>]... [-o <out>]
batch-add-media-items <album-id> (-r <kv>)... [-p <v>]... [-o <out>]
batch-remove-media-items <album-id> (-r <kv>)... [-p <v>]... [-o <out>]
create (-r <kv>)... [-p <v>]... [-o <out>]
get <album-id> [-p <v>]... [-o <out>]
list [-p <v>]... [-o <out>]

View File

@@ -1,4 +1,4 @@
site_name: Photos Library v1.0.8+20190402
site_name: Photos Library v1.0.9+20190702
site_url: http://byron.github.io/google-apis-rs/google-photoslibrary1-cli
site_description: A complete library to interact with Photos Library (protocol v1)
@@ -10,6 +10,8 @@ site_dir: build_html
pages:
- ['index.md', 'Home']
- ['albums_add-enrichment.md', 'Albums', 'Add Enrichment']
- ['albums_batch-add-media-items.md', 'Albums', 'Batch Add Media Items']
- ['albums_batch-remove-media-items.md', 'Albums', 'Batch Remove Media Items']
- ['albums_create.md', 'Albums', 'Create']
- ['albums_get.md', 'Albums', 'Get']
- ['albums_list.md', 'Albums', 'List']
@@ -27,5 +29,5 @@ pages:
theme: readthedocs
copyright: Copyright &copy; 2015-2016, `Sebastian Thiel`
copyright: Copyright &copy; 2015-2019, `Sebastian Thiel`

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

@@ -143,6 +143,176 @@ impl<'n> Engine<'n> {
}
}
fn _albums_batch_add_media_items(&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()[..] {
"media-item-ids" => Some(("mediaItemIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
_ => {
let suggestion = FieldCursor::did_you_mean(key, &vec!["media-item-ids"]);
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::BatchAddMediaItemsToAlbumRequest = json::value::from_value(object).unwrap();
let mut call = self.hub.albums().batch_add_media_items(request, opt.value_of("album-id").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 _albums_batch_remove_media_items(&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()[..] {
"media-item-ids" => Some(("mediaItemIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
_ => {
let suggestion = FieldCursor::did_you_mean(key, &vec!["media-item-ids"]);
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::BatchRemoveMediaItemsFromAlbumRequest = json::value::from_value(object).unwrap();
let mut call = self.hub.albums().batch_remove_media_items(request, opt.value_of("album-id").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 _albums_create(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
@@ -808,9 +978,10 @@ impl<'n> Engine<'n> {
"filters.include-archived-media" => Some(("filters.includeArchivedMedia", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
"filters.exclude-non-app-created-data" => Some(("filters.excludeNonAppCreatedData", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
"filters.media-type-filter.media-types" => Some(("filters.mediaTypeFilter.mediaTypes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
"filters.feature-filter.included-features" => Some(("filters.featureFilter.includedFeatures", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
"page-token" => Some(("pageToken", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
_ => {
let suggestion = FieldCursor::did_you_mean(key, &vec!["album-id", "content-filter", "exclude-non-app-created-data", "excluded-content-categories", "filters", "include-archived-media", "included-content-categories", "media-type-filter", "media-types", "page-size", "page-token"]);
let suggestion = FieldCursor::did_you_mean(key, &vec!["album-id", "content-filter", "exclude-non-app-created-data", "excluded-content-categories", "feature-filter", "filters", "include-archived-media", "included-content-categories", "included-features", "media-type-filter", "media-types", "page-size", "page-token"]);
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
None
}
@@ -1164,6 +1335,12 @@ impl<'n> Engine<'n> {
("add-enrichment", Some(opt)) => {
call_result = self._albums_add_enrichment(opt, dry_run, &mut err);
},
("batch-add-media-items", Some(opt)) => {
call_result = self._albums_batch_add_media_items(opt, dry_run, &mut err);
},
("batch-remove-media-items", Some(opt)) => {
call_result = self._albums_batch_remove_media_items(opt, dry_run, &mut err);
},
("create", Some(opt)) => {
call_result = self._albums_create(opt, dry_run, &mut err);
},
@@ -1313,7 +1490,7 @@ impl<'n> Engine<'n> {
fn main() {
let mut exit_status = 0i32;
let arg_data = [
("albums", "methods: 'add-enrichment', 'create', 'get', 'list', 'share' and 'unshare'", vec![
("albums", "methods: 'add-enrichment', 'batch-add-media-items', 'batch-remove-media-items', 'create', 'get', 'list', 'share' and 'unshare'", vec![
("add-enrichment",
Some(r##"Adds an enrichment at a specified position in a defined album."##),
"Details at http://byron.github.io/google-apis-rs/google_photoslibrary1_cli/albums_add-enrichment",
@@ -1336,6 +1513,87 @@ 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)),
]),
("batch-add-media-items",
Some(r##"Adds one or more media items in a user's Google Photos library to
an album. The media items and albums must have been created by the
developer via the API.
Media items are added to the end of the album. If multiple media items are
given, they are added in the order specified in this call.
Each album can contain up to 20,000 media items.
Only media items that are in the user's library can be added to an
album. For albums that are shared, the album must either be owned by the
user or the user must have joined the album as a collaborator.
Partial success is not supported. The entire request will fail if an
invalid media item or album is specified."##),
"Details at http://byron.github.io/google-apis-rs/google_photoslibrary1_cli/albums_batch-add-media-items",
vec![
(Some(r##"album-id"##),
None,
Some(r##"Identifier of the Album that the
media items are added to."##),
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"##),
Some(false),
Some(false)),
]),
("batch-remove-media-items",
Some(r##"Removes one or more media items from a specified album. The media items and
the album must have been created by the developer via the API.
For albums that are shared, this action is only supported for media items
that were added to the album by this user, or for all media items if the
album was created by this user.
Partial success is not supported. The entire request will fail and no
action will be performed on the album if an invalid media item or album is
specified."##),
"Details at http://byron.github.io/google-apis-rs/google_photoslibrary1_cli/albums_batch-remove-media-items",
vec![
(Some(r##"album-id"##),
None,
Some(r##"Identifier of the Album that the media
items are to be removed from."##),
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"##),
@@ -1481,8 +1739,9 @@ fn main() {
<a href="/photos/library/guides/upload-media">Uploading media</a>.
This call adds the media item to the library. If an album `id` is
specified, the call adds the media item to the album too. By default, the
media item will be added to the end of the library or album.
specified, the call adds the media item to the album too. Each album can
contain up to 20,000 media items. By default, the media item will be added
to the end of the library or album.
If an album `id` and position are both defined, the media item is
added to the album at the specified position.
@@ -1688,7 +1947,7 @@ fn main() {
let mut app = App::new("photoslibrary1")
.author("Sebastian Thiel <byronimo@gmail.com>")
.version("1.0.8+20190402")
.version("1.0.9+20190702")
.about("Manage photos, videos, and albums in Google Photos
")
.after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_photoslibrary1_cli")