From c2dd9c7a020e0367bc87b20fa8054c85f48b71c1 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 26 Apr 2015 13:42:31 +0200 Subject: [PATCH] fix(version-up): code updated to v0.1.6, latest CLI * also includes publishing tag files --- .../v1.3/crates/0.1.6-api+20150326 | 0 .../v2.0/crates/0.1.6-api+20150326 | 0 .../directory_v1/crates/0.1.6-api+20150314 | 0 .../crates/0.1.6-api+20150303 | 0 .../reports_v1/crates/0.1.6-api+20150115 | 0 .../adsense/v1.4/crates/0.1.6-api+20150326 | 0 .../v4.1/crates/0.1.6-api+20150307 | 0 .../analytics/v3/crates/0.1.6-api+20150305 | 0 .../v1/crates/0.1.6-api+20150309 | 0 .../v2/crates/0.1.6-api+20150323 | 0 .../appsactivity/v1/crates/0.1.6-api+20140828 | 0 etc/api/appstate/v1/crates/0.1.6-api+20150414 | 0 etc/api/audit/v1/crates/0.1.6-api+20150419 | 0 .../v1beta2/crates/0.1.6-api+20141112 | 0 etc/api/bigquery/v2/crates/0.1.6-api+20150326 | 0 etc/api/blogger/v3/crates/0.1.6-api+20150422 | 0 etc/api/books/v1/crates/0.1.6-api+20150401 | 0 etc/api/calendar/v3/crates/0.1.6-api+20150326 | 0 .../civicinfo/v2/crates/0.1.6-api+20150302 | 0 .../v2/crates/0.1.6-api+20150206 | 0 .../v2beta2/crates/0.1.6-api+20150401 | 0 .../cloudsearch/v1/crates/0.1.6-api+20150416 | 0 etc/api/compute/v1/crates/0.1.6-api+20150326 | 0 .../v1beta1/crates/0.1.6-api+20150420 | 0 etc/api/content/v2/crates/0.1.6-api+20150421 | 0 .../coordinate/v1/crates/0.1.6-api+20141215 | 0 .../customsearch/v1/crates/0.1.6-api+20131205 | 0 .../v1beta2/crates/0.1.6-api+20150402 | 0 .../v2beta1/crates/0.1.6-api+20150415 | 0 .../v2.1/crates/0.1.6-api+20150326 | 0 .../discovery/v1/crates/0.1.6-api+00000000 | 0 etc/api/dns/v1/crates/0.1.6-api+20150218 | 0 .../v1/crates/0.1.6-api+20150326 | 0 .../v2/crates/0.1.6-api+20150303 | 0 etc/api/drive/v2/crates/0.1.6-api+20150326 | 0 etc/api/fitness/v1/crates/0.1.6-api+20150326 | 0 etc/api/freebase/v1/crates/0.1.6-api+20150330 | 0 .../v1sandbox/crates/0.1.6-api+20150330 | 0 .../fusiontables/v2/crates/0.1.6-api+20150326 | 0 etc/api/games/v1/crates/0.1.6-api+20150413 | 0 .../v1configuration/crates/0.1.6-api+20150413 | 0 .../v1management/crates/0.1.6-api+20150413 | 0 etc/api/gan/v1beta1/crates/0.1.6-api+20130205 | 0 .../v1beta2/crates/0.1.6-api+20150326 | 0 etc/api/gmail/v1/crates/0.1.6-api+20150303 | 0 .../v1/crates/0.1.6-api+20140416 | 0 .../v1/crates/0.1.6-api+20140428 | 0 .../v3/crates/0.1.6-api+20150406 | 0 .../licensing/v1/crates/0.1.6-api+20140122 | 0 .../logging/v1beta3/crates/0.1.6-api+20150326 | 0 .../manager/v1beta2/crates/0.1.6-api+20140915 | 0 .../mapsengine/v1/crates/0.1.6-api+20150414 | 0 etc/api/mirror/v1/crates/0.1.6-api+20150220 | 0 etc/api/oauth2/v2/crates/0.1.6-api+20150416 | 0 .../v2/crates/0.1.6-api+20150317 | 0 etc/api/plus/v1/crates/0.1.6-api+20150303 | 0 .../plusdomains/v1/crates/0.1.6-api+20150303 | 0 .../prediction/v1.6/crates/0.1.6-api+20140522 | 0 .../pubsub/v1beta2/crates/0.1.6-api+20150326 | 0 .../qpxexpress/v1/crates/0.1.6-api+20140321 | 0 .../v1beta2/crates/0.1.6-api+20150223 | 0 .../v1beta1/crates/0.1.6-api+20150326 | 0 .../v1sandbox/crates/0.1.6-api+20141112 | 0 .../v1beta2/crates/0.1.6-api+20150302 | 0 .../v1/crates/0.1.6-api+20131007 | 0 .../v1explorer/crates/0.1.6-api+20150112 | 0 .../v1beta4/crates/0.1.6-api+20150305 | 0 etc/api/storage/v1/crates/0.1.6-api+20150326 | 0 .../tagmanager/v1/crates/0.1.6-api+20150121 | 0 .../v1beta2/crates/0.1.6-api+20141111 | 0 etc/api/tasks/v1/crates/0.1.6-api+20141121 | 0 .../translate/v2/crates/0.1.6-api+20141123 | 0 .../urlshortener/v1/crates/0.1.6-api+20150319 | 0 etc/api/webfonts/v1/crates/0.1.6-api+20140210 | 0 .../webmasters/v3/crates/0.1.6-api+20140908 | 0 etc/api/youtube/v3/crates/0.1.6-api+20150414 | 0 .../v1/crates/0.1.6-api+20150304 | 0 gen/adexchangebuyer1d3-cli/Cargo.toml | 2 +- gen/adexchangebuyer1d3-cli/README.md | 122 +- gen/adexchangebuyer1d3-cli/mkdocs.yml | 2 +- gen/adexchangebuyer1d3-cli/src/cmn.rs | 2 +- gen/adexchangebuyer1d3-cli/src/main.rs | 660 +- gen/adexchangebuyer1d3/Cargo.toml | 2 +- gen/adexchangebuyer1d3/README.md | 11 +- gen/adexchangebuyer1d3/src/cmn.rs | 54 +- gen/adexchangebuyer1d3/src/lib.rs | 335 +- gen/adexchangeseller2-cli/Cargo.toml | 2 +- gen/adexchangeseller2-cli/README.md | 115 +- gen/adexchangeseller2-cli/mkdocs.yml | 2 +- gen/adexchangeseller2-cli/src/cmn.rs | 2 +- gen/adexchangeseller2-cli/src/main.rs | 97 +- gen/adexchangeseller2/Cargo.toml | 2 +- gen/adexchangeseller2/README.md | 9 +- gen/adexchangeseller2/src/cmn.rs | 54 +- gen/adexchangeseller2/src/lib.rs | 176 +- gen/admin1_directory-cli/Cargo.toml | 2 +- gen/admin1_directory-cli/README.md | 168 +- gen/admin1_directory-cli/mkdocs.yml | 2 +- gen/admin1_directory-cli/src/cmn.rs | 2 +- gen/admin1_directory-cli/src/main.rs | 2231 ++++--- gen/admin1_directory/Cargo.toml | 2 +- gen/admin1_directory/README.md | 11 +- gen/admin1_directory/src/cmn.rs | 54 +- gen/admin1_directory/src/lib.rs | 1017 ++- gen/admin1_reports-cli/Cargo.toml | 2 +- gen/admin1_reports-cli/README.md | 106 +- gen/admin1_reports-cli/mkdocs.yml | 2 +- gen/admin1_reports-cli/src/cmn.rs | 2 +- gen/admin1_reports-cli/src/main.rs | 220 +- gen/admin1_reports/Cargo.toml | 2 +- gen/admin1_reports/README.md | 11 +- gen/admin1_reports/src/cmn.rs | 54 +- gen/admin1_reports/src/lib.rs | 99 +- gen/admin2_email_migration-cli/Cargo.toml | 2 +- gen/admin2_email_migration-cli/README.md | 102 +- gen/admin2_email_migration-cli/mkdocs.yml | 2 +- gen/admin2_email_migration-cli/src/cmn.rs | 2 +- gen/admin2_email_migration-cli/src/main.rs | 95 +- gen/admin2_email_migration/Cargo.toml | 2 +- gen/admin2_email_migration/README.md | 11 +- gen/admin2_email_migration/src/cmn.rs | 54 +- gen/admin2_email_migration/src/lib.rs | 62 +- gen/adsense1d4-cli/Cargo.toml | 2 +- gen/adsense1d4-cli/README.md | 139 +- gen/adsense1d4-cli/mkdocs.yml | 2 +- gen/adsense1d4-cli/src/cmn.rs | 2 +- gen/adsense1d4-cli/src/main.rs | 217 +- gen/adsense1d4/Cargo.toml | 2 +- gen/adsense1d4/README.md | 9 +- gen/adsense1d4/src/cmn.rs | 54 +- gen/adsense1d4/src/lib.rs | 436 +- gen/adsensehost4d1-cli/Cargo.toml | 2 +- gen/adsensehost4d1-cli/README.md | 127 +- gen/adsensehost4d1-cli/mkdocs.yml | 2 +- gen/adsensehost4d1-cli/src/cmn.rs | 2 +- gen/adsensehost4d1-cli/src/main.rs | 584 +- gen/adsensehost4d1/Cargo.toml | 2 +- gen/adsensehost4d1/README.md | 9 +- gen/adsensehost4d1/src/cmn.rs | 54 +- gen/adsensehost4d1/src/lib.rs | 378 +- gen/analytics3-cli/Cargo.toml | 2 +- gen/analytics3-cli/README.md | 179 +- gen/analytics3-cli/mkdocs.yml | 2 +- gen/analytics3-cli/src/cmn.rs | 2 +- gen/analytics3-cli/src/main.rs | 2695 +++++--- gen/analytics3/Cargo.toml | 2 +- gen/analytics3/README.md | 11 +- gen/analytics3/src/cmn.rs | 54 +- gen/analytics3/src/lib.rs | 1245 ++-- gen/androidenterprise1-cli/Cargo.toml | 2 +- gen/androidenterprise1-cli/README.md | 145 +- gen/androidenterprise1-cli/mkdocs.yml | 2 +- gen/androidenterprise1-cli/src/cmn.rs | 2 +- gen/androidenterprise1-cli/src/main.rs | 1077 +-- gen/androidenterprise1/Cargo.toml | 2 +- gen/androidenterprise1/README.md | 11 +- gen/androidenterprise1/src/cmn.rs | 54 +- gen/androidenterprise1/src/lib.rs | 636 +- gen/androidpublisher2-cli/Cargo.toml | 2 +- gen/androidpublisher2-cli/README.md | 152 +- gen/androidpublisher2-cli/mkdocs.yml | 2 +- gen/androidpublisher2-cli/src/cmn.rs | 2 +- gen/androidpublisher2-cli/src/main.rs | 1399 ++-- gen/androidpublisher2/Cargo.toml | 2 +- gen/androidpublisher2/README.md | 11 +- gen/androidpublisher2/src/cmn.rs | 54 +- gen/androidpublisher2/src/lib.rs | 808 ++- gen/appsactivity1-cli/Cargo.toml | 2 +- gen/appsactivity1-cli/README.md | 102 +- gen/appsactivity1-cli/mkdocs.yml | 2 +- gen/appsactivity1-cli/src/cmn.rs | 2 +- gen/appsactivity1-cli/src/main.rs | 32 +- gen/appsactivity1/Cargo.toml | 2 +- gen/appsactivity1/README.md | 9 +- gen/appsactivity1/src/cmn.rs | 54 +- gen/appsactivity1/src/lib.rs | 33 +- gen/appstate1-cli/Cargo.toml | 2 +- gen/appstate1-cli/README.md | 106 +- gen/appstate1-cli/mkdocs.yml | 2 +- gen/appstate1-cli/src/cmn.rs | 2 +- gen/appstate1-cli/src/main.rs | 101 +- gen/appstate1/Cargo.toml | 2 +- gen/appstate1/README.md | 11 +- gen/appstate1/src/cmn.rs | 54 +- gen/appstate1/src/lib.rs | 89 +- gen/audit1-cli/Cargo.toml | 2 +- gen/audit1-cli/README.md | 98 +- gen/audit1-cli/mkdocs.yml | 2 +- gen/audit1-cli/src/cmn.rs | 2 +- gen/audit1-cli/src/main.rs | 25 +- gen/audit1/Cargo.toml | 2 +- gen/audit1/README.md | 9 +- gen/audit1/src/cmn.rs | 54 +- gen/audit1/src/lib.rs | 33 +- gen/autoscaler1_beta2-cli/Cargo.toml | 2 +- gen/autoscaler1_beta2-cli/README.md | 111 +- gen/autoscaler1_beta2-cli/mkdocs.yml | 2 +- gen/autoscaler1_beta2-cli/src/cmn.rs | 2 +- gen/autoscaler1_beta2-cli/src/main.rs | 266 +- gen/autoscaler1_beta2/Cargo.toml | 2 +- gen/autoscaler1_beta2/README.md | 9 +- gen/autoscaler1_beta2/src/cmn.rs | 54 +- gen/autoscaler1_beta2/src/lib.rs | 160 +- gen/bigquery2-cli/Cargo.toml | 2 +- gen/bigquery2-cli/README.md | 121 +- gen/bigquery2-cli/mkdocs.yml | 2 +- gen/bigquery2-cli/src/cmn.rs | 2 +- gen/bigquery2-cli/src/main.rs | 686 +- gen/bigquery2/Cargo.toml | 2 +- gen/bigquery2/README.md | 11 +- gen/bigquery2/src/cmn.rs | 54 +- gen/bigquery2/src/lib.rs | 349 +- gen/blogger3-cli/Cargo.toml | 2 +- gen/blogger3-cli/README.md | 134 +- gen/blogger3-cli/mkdocs.yml | 2 +- gen/blogger3-cli/src/cmn.rs | 2 +- gen/blogger3-cli/src/main.rs | 678 +- gen/blogger3/Cargo.toml | 2 +- gen/blogger3/README.md | 9 +- gen/blogger3/src/cmn.rs | 54 +- gen/blogger3/src/lib.rs | 439 +- gen/books1-cli/Cargo.toml | 2 +- gen/books1-cli/README.md | 145 +- gen/books1-cli/mkdocs.yml | 2 +- gen/books1-cli/src/cmn.rs | 2 +- gen/books1-cli/src/main.rs | 529 +- gen/books1/Cargo.toml | 2 +- gen/books1/README.md | 9 +- gen/books1/src/cmn.rs | 54 +- gen/books1/src/lib.rs | 528 +- gen/calendar3-cli/Cargo.toml | 2 +- gen/calendar3-cli/README.md | 138 +- gen/calendar3-cli/mkdocs.yml | 2 +- gen/calendar3-cli/src/cmn.rs | 2 +- gen/calendar3-cli/src/main.rs | 2153 +++--- gen/calendar3/Cargo.toml | 2 +- gen/calendar3/README.md | 11 +- gen/calendar3/src/cmn.rs | 54 +- gen/calendar3/src/lib.rs | 611 +- gen/civicinfo2-cli/Cargo.toml | 2 +- gen/civicinfo2-cli/README.md | 102 +- gen/civicinfo2-cli/mkdocs.yml | 2 +- gen/civicinfo2-cli/src/cmn.rs | 2 +- gen/civicinfo2-cli/src/main.rs | 33 +- gen/civicinfo2/Cargo.toml | 2 +- gen/civicinfo2/README.md | 9 +- gen/civicinfo2/src/cmn.rs | 54 +- gen/civicinfo2/src/lib.rs | 77 +- gen/cloudlatencytest2-cli/Cargo.toml | 2 +- gen/cloudlatencytest2-cli/README.md | 103 +- gen/cloudlatencytest2-cli/mkdocs.yml | 2 +- gen/cloudlatencytest2-cli/src/cmn.rs | 2 +- gen/cloudlatencytest2-cli/src/main.rs | 117 +- gen/cloudlatencytest2/Cargo.toml | 2 +- gen/cloudlatencytest2/README.md | 11 +- gen/cloudlatencytest2/src/cmn.rs | 54 +- gen/cloudlatencytest2/src/lib.rs | 68 +- gen/cloudmonitoring2_beta2-cli/Cargo.toml | 2 +- gen/cloudmonitoring2_beta2-cli/README.md | 107 +- gen/cloudmonitoring2_beta2-cli/mkdocs.yml | 2 +- gen/cloudmonitoring2_beta2-cli/src/cmn.rs | 2 +- gen/cloudmonitoring2_beta2-cli/src/main.rs | 324 +- gen/cloudmonitoring2_beta2/Cargo.toml | 2 +- gen/cloudmonitoring2_beta2/README.md | 11 +- gen/cloudmonitoring2_beta2/src/cmn.rs | 54 +- gen/cloudmonitoring2_beta2/src/lib.rs | 142 +- gen/cloudsearch1-cli/Cargo.toml | 2 +- gen/cloudsearch1-cli/README.md | 97 +- gen/cloudsearch1-cli/mkdocs.yml | 2 +- gen/cloudsearch1-cli/src/cmn.rs | 2 +- gen/cloudsearch1-cli/src/main.rs | 23 +- gen/cloudsearch1/Cargo.toml | 2 +- gen/cloudsearch1/README.md | 2 +- gen/cloudsearch1/src/cmn.rs | 54 +- gen/cloudsearch1/src/lib.rs | 8 +- gen/compute1-cli/Cargo.toml | 2 +- gen/compute1-cli/README.md | 247 +- gen/compute1-cli/mkdocs.yml | 2 +- gen/compute1-cli/src/cmn.rs | 2 +- gen/compute1-cli/src/main.rs | 3536 ++++++---- gen/compute1/Cargo.toml | 2 +- gen/compute1/README.md | 9 +- gen/compute1/src/cmn.rs | 54 +- gen/compute1/src/lib.rs | 2112 ++++-- gen/container1_beta1-cli/Cargo.toml | 2 +- gen/container1_beta1-cli/README.md | 110 +- gen/container1_beta1-cli/mkdocs.yml | 2 +- gen/container1_beta1-cli/src/cmn.rs | 2 +- gen/container1_beta1-cli/src/main.rs | 132 +- gen/container1_beta1/Cargo.toml | 2 +- gen/container1_beta1/README.md | 9 +- gen/container1_beta1/src/cmn.rs | 54 +- gen/container1_beta1/src/lib.rs | 131 +- gen/content2-cli/Cargo.toml | 2 +- gen/content2-cli/README.md | 142 +- gen/content2-cli/mkdocs.yml | 2 +- gen/content2-cli/src/cmn.rs | 2 +- gen/content2-cli/src/main.rs | 1299 ++-- gen/content2/Cargo.toml | 2 +- gen/content2/README.md | 11 +- gen/content2/src/cmn.rs | 54 +- gen/content2/src/lib.rs | 681 +- gen/coordinate1-cli/Cargo.toml | 2 +- gen/coordinate1-cli/README.md | 113 +- gen/coordinate1-cli/mkdocs.yml | 2 +- gen/coordinate1-cli/src/cmn.rs | 2 +- gen/coordinate1-cli/src/main.rs | 564 +- gen/coordinate1/Cargo.toml | 2 +- gen/coordinate1/README.md | 11 +- gen/coordinate1/src/cmn.rs | 54 +- gen/coordinate1/src/lib.rs | 208 +- gen/customsearch1-cli/Cargo.toml | 2 +- gen/customsearch1-cli/README.md | 98 +- gen/customsearch1-cli/mkdocs.yml | 2 +- gen/customsearch1-cli/src/cmn.rs | 2 +- gen/customsearch1-cli/src/main.rs | 25 +- gen/customsearch1/Cargo.toml | 2 +- gen/customsearch1/README.md | 9 +- gen/customsearch1/src/cmn.rs | 54 +- gen/customsearch1/src/lib.rs | 33 +- gen/datastore1_beta2-cli/Cargo.toml | 2 +- gen/datastore1_beta2-cli/README.md | 107 +- gen/datastore1_beta2-cli/mkdocs.yml | 2 +- gen/datastore1_beta2-cli/src/cmn.rs | 2 +- gen/datastore1_beta2-cli/src/main.rs | 383 +- gen/datastore1_beta2/Cargo.toml | 2 +- gen/datastore1_beta2/README.md | 11 +- gen/datastore1_beta2/src/cmn.rs | 54 +- gen/datastore1_beta2/src/lib.rs | 152 +- gen/deploymentmanager2_beta1-cli/Cargo.toml | 2 +- gen/deploymentmanager2_beta1-cli/README.md | 112 +- gen/deploymentmanager2_beta1-cli/mkdocs.yml | 2 +- gen/deploymentmanager2_beta1-cli/src/cmn.rs | 2 +- gen/deploymentmanager2_beta1-cli/src/main.rs | 149 +- gen/deploymentmanager2_beta1/Cargo.toml | 2 +- gen/deploymentmanager2_beta1/README.md | 9 +- gen/deploymentmanager2_beta1/src/cmn.rs | 54 +- gen/deploymentmanager2_beta1/src/lib.rs | 153 +- gen/dfareporting2d1-cli/Cargo.toml | 2 +- gen/dfareporting2d1-cli/README.md | 294 +- gen/dfareporting2d1-cli/mkdocs.yml | 2 +- gen/dfareporting2d1-cli/src/cmn.rs | 2 +- gen/dfareporting2d1-cli/src/main.rs | 5914 ++++++++++------- gen/dfareporting2d1/Cargo.toml | 2 +- gen/dfareporting2d1/README.md | 9 +- gen/dfareporting2d1/src/cmn.rs | 54 +- gen/dfareporting2d1/src/lib.rs | 2920 +++++--- gen/discovery1-cli/Cargo.toml | 2 +- gen/discovery1-cli/README.md | 99 +- gen/discovery1-cli/mkdocs.yml | 2 +- gen/discovery1-cli/src/cmn.rs | 2 +- gen/discovery1-cli/src/main.rs | 27 +- gen/discovery1/Cargo.toml | 2 +- gen/discovery1/README.md | 9 +- gen/discovery1/src/cmn.rs | 54 +- gen/discovery1/src/lib.rs | 44 +- gen/dns1-cli/Cargo.toml | 2 +- gen/dns1-cli/README.md | 110 +- gen/dns1-cli/mkdocs.yml | 2 +- gen/dns1-cli/src/cmn.rs | 2 +- gen/dns1-cli/src/main.rs | 196 +- gen/dns1/Cargo.toml | 2 +- gen/dns1/README.md | 9 +- gen/dns1/src/cmn.rs | 54 +- gen/dns1/src/lib.rs | 139 +- gen/doubleclickbidmanager1-cli/Cargo.toml | 2 +- gen/doubleclickbidmanager1-cli/README.md | 105 +- gen/doubleclickbidmanager1-cli/mkdocs.yml | 2 +- gen/doubleclickbidmanager1-cli/src/cmn.rs | 2 +- gen/doubleclickbidmanager1-cli/src/main.rs | 279 +- gen/doubleclickbidmanager1/Cargo.toml | 2 +- gen/doubleclickbidmanager1/README.md | 9 +- gen/doubleclickbidmanager1/src/cmn.rs | 54 +- gen/doubleclickbidmanager1/src/lib.rs | 146 +- gen/doubleclicksearch2-cli/Cargo.toml | 2 +- gen/doubleclicksearch2-cli/README.md | 111 +- gen/doubleclicksearch2-cli/mkdocs.yml | 2 +- gen/doubleclicksearch2-cli/src/cmn.rs | 2 +- gen/doubleclicksearch2-cli/src/main.rs | 369 +- gen/doubleclicksearch2/Cargo.toml | 2 +- gen/doubleclicksearch2/README.md | 9 +- gen/doubleclicksearch2/src/cmn.rs | 54 +- gen/doubleclicksearch2/src/lib.rs | 190 +- gen/drive2-cli/Cargo.toml | 2 +- gen/drive2-cli/README.md | 160 +- gen/drive2-cli/mkdocs.yml | 2 +- gen/drive2-cli/src/cmn.rs | 2 +- gen/drive2-cli/src/main.rs | 2147 +++--- gen/drive2/Cargo.toml | 2 +- gen/drive2/README.md | 11 +- gen/drive2/src/cmn.rs | 54 +- gen/drive2/src/lib.rs | 932 ++- gen/fitness1-cli/Cargo.toml | 2 +- gen/fitness1-cli/README.md | 113 +- gen/fitness1-cli/mkdocs.yml | 2 +- gen/fitness1-cli/src/cmn.rs | 2 +- gen/fitness1-cli/src/main.rs | 406 +- gen/fitness1/Cargo.toml | 2 +- gen/fitness1/README.md | 11 +- gen/fitness1/src/cmn.rs | 54 +- gen/fitness1/src/lib.rs | 204 +- gen/freebase1-cli/Cargo.toml | 2 +- gen/freebase1-cli/README.md | 99 +- gen/freebase1-cli/mkdocs.yml | 2 +- gen/freebase1-cli/src/cmn.rs | 2 +- gen/freebase1-cli/src/main.rs | 27 +- gen/freebase1/Cargo.toml | 2 +- gen/freebase1/README.md | 9 +- gen/freebase1/src/cmn.rs | 54 +- gen/freebase1/src/lib.rs | 42 +- gen/freebase1_sandbox-cli/Cargo.toml | 2 +- gen/freebase1_sandbox-cli/README.md | 99 +- gen/freebase1_sandbox-cli/mkdocs.yml | 2 +- gen/freebase1_sandbox-cli/src/cmn.rs | 2 +- gen/freebase1_sandbox-cli/src/main.rs | 27 +- gen/freebase1_sandbox/Cargo.toml | 2 +- gen/freebase1_sandbox/README.md | 9 +- gen/freebase1_sandbox/src/cmn.rs | 54 +- gen/freebase1_sandbox/src/lib.rs | 42 +- gen/fusiontables2-cli/Cargo.toml | 2 +- gen/fusiontables2-cli/README.md | 134 +- gen/fusiontables2-cli/mkdocs.yml | 2 +- gen/fusiontables2-cli/src/cmn.rs | 2 +- gen/fusiontables2-cli/src/main.rs | 968 +-- gen/fusiontables2/Cargo.toml | 2 +- gen/fusiontables2/README.md | 9 +- gen/fusiontables2/src/cmn.rs | 54 +- gen/fusiontables2/src/lib.rs | 546 +- gen/games1-cli/Cargo.toml | 2 +- gen/games1-cli/README.md | 153 +- gen/games1-cli/mkdocs.yml | 2 +- gen/games1-cli/src/cmn.rs | 2 +- gen/games1-cli/src/main.rs | 1041 +-- gen/games1/Cargo.toml | 2 +- gen/games1/README.md | 9 +- gen/games1/src/cmn.rs | 54 +- gen/games1/src/lib.rs | 700 +- .../Cargo.toml | 2 +- .../README.md | 114 +- .../mkdocs.yml | 2 +- .../src/cmn.rs | 2 +- .../src/main.rs | 470 +- .../Cargo.toml | 2 +- .../README.md | 9 +- .../src/cmn.rs | 54 +- .../src/lib.rs | 238 +- .../Cargo.toml | 2 +- gen/gamesmanagement1_management-cli/README.md | 128 +- .../mkdocs.yml | 2 +- .../src/cmn.rs | 2 +- .../src/main.rs | 382 +- gen/gamesmanagement1_management/Cargo.toml | 2 +- gen/gamesmanagement1_management/README.md | 9 +- gen/gamesmanagement1_management/src/cmn.rs | 54 +- gen/gamesmanagement1_management/src/lib.rs | 315 +- gen/gan1_beta1-cli/Cargo.toml | 2 +- gen/gan1_beta1-cli/README.md | 107 +- gen/gan1_beta1-cli/mkdocs.yml | 2 +- gen/gan1_beta1-cli/src/cmn.rs | 2 +- gen/gan1_beta1-cli/src/main.rs | 106 +- gen/gan1_beta1/Cargo.toml | 2 +- gen/gan1_beta1/README.md | 9 +- gen/gan1_beta1/src/cmn.rs | 54 +- gen/gan1_beta1/src/lib.rs | 142 +- gen/genomics1_beta2-cli/Cargo.toml | 2 +- gen/genomics1_beta2-cli/README.md | 161 +- gen/genomics1_beta2-cli/mkdocs.yml | 2 +- gen/genomics1_beta2-cli/src/cmn.rs | 2 +- gen/genomics1_beta2-cli/src/main.rs | 2668 +++++--- gen/genomics1_beta2/Cargo.toml | 2 +- gen/genomics1_beta2/README.md | 11 +- gen/genomics1_beta2/src/cmn.rs | 54 +- gen/genomics1_beta2/src/lib.rs | 1048 +-- gen/gmail1-cli/Cargo.toml | 2 +- gen/gmail1-cli/README.md | 131 +- gen/gmail1-cli/mkdocs.yml | 2 +- gen/gmail1-cli/src/cmn.rs | 2 +- gen/gmail1-cli/src/main.rs | 994 +-- gen/gmail1/Cargo.toml | 2 +- gen/gmail1/README.md | 11 +- gen/gmail1/src/cmn.rs | 54 +- gen/gmail1/src/lib.rs | 560 +- gen/groupsmigration1-cli/Cargo.toml | 2 +- gen/groupsmigration1-cli/README.md | 102 +- gen/groupsmigration1-cli/mkdocs.yml | 2 +- gen/groupsmigration1-cli/src/cmn.rs | 2 +- gen/groupsmigration1-cli/src/main.rs | 32 +- gen/groupsmigration1/Cargo.toml | 2 +- gen/groupsmigration1/README.md | 9 +- gen/groupsmigration1/src/cmn.rs | 54 +- gen/groupsmigration1/src/lib.rs | 50 +- gen/groupssettings1-cli/Cargo.toml | 2 +- gen/groupssettings1-cli/README.md | 104 +- gen/groupssettings1-cli/mkdocs.yml | 2 +- gen/groupssettings1-cli/src/cmn.rs | 2 +- gen/groupssettings1-cli/src/main.rs | 168 +- gen/groupssettings1/Cargo.toml | 2 +- gen/groupssettings1/README.md | 11 +- gen/groupssettings1/src/cmn.rs | 54 +- gen/groupssettings1/src/lib.rs | 79 +- gen/identitytoolkit3-cli/Cargo.toml | 2 +- gen/identitytoolkit3-cli/README.md | 109 +- gen/identitytoolkit3-cli/mkdocs.yml | 2 +- gen/identitytoolkit3-cli/src/cmn.rs | 2 +- gen/identitytoolkit3-cli/src/main.rs | 651 +- gen/identitytoolkit3/Cargo.toml | 2 +- gen/identitytoolkit3/README.md | 11 +- gen/identitytoolkit3/src/cmn.rs | 54 +- gen/identitytoolkit3/src/lib.rs | 258 +- gen/licensing1-cli/Cargo.toml | 2 +- gen/licensing1-cli/README.md | 108 +- gen/licensing1-cli/mkdocs.yml | 2 +- gen/licensing1-cli/src/cmn.rs | 2 +- gen/licensing1-cli/src/main.rs | 251 +- gen/licensing1/Cargo.toml | 2 +- gen/licensing1/README.md | 9 +- gen/licensing1/src/cmn.rs | 54 +- gen/licensing1/src/lib.rs | 127 +- gen/logging1_beta3-cli/Cargo.toml | 2 +- gen/logging1_beta3-cli/README.md | 116 +- gen/logging1_beta3-cli/mkdocs.yml | 2 +- gen/logging1_beta3-cli/src/cmn.rs | 2 +- gen/logging1_beta3-cli/src/main.rs | 349 +- gen/logging1_beta3/Cargo.toml | 2 +- gen/logging1_beta3/README.md | 11 +- gen/logging1_beta3/src/cmn.rs | 54 +- gen/logging1_beta3/src/lib.rs | 241 +- gen/manager1_beta2-cli/Cargo.toml | 2 +- gen/manager1_beta2-cli/README.md | 109 +- gen/manager1_beta2-cli/mkdocs.yml | 2 +- gen/manager1_beta2-cli/src/cmn.rs | 2 +- gen/manager1_beta2-cli/src/main.rs | 179 +- gen/manager1_beta2/Cargo.toml | 2 +- gen/manager1_beta2/README.md | 9 +- gen/manager1_beta2/src/cmn.rs | 54 +- gen/manager1_beta2/src/lib.rs | 126 +- gen/mapsengine1-cli/Cargo.toml | 2 +- gen/mapsengine1-cli/README.md | 178 +- gen/mapsengine1-cli/mkdocs.yml | 2 +- gen/mapsengine1-cli/src/cmn.rs | 2 +- gen/mapsengine1-cli/src/main.rs | 1891 ++++-- gen/mapsengine1/Cargo.toml | 2 +- gen/mapsengine1/README.md | 9 +- gen/mapsengine1/src/cmn.rs | 54 +- gen/mapsengine1/src/lib.rs | 1160 ++-- gen/mirror1-cli/Cargo.toml | 2 +- gen/mirror1-cli/README.md | 125 +- gen/mirror1-cli/mkdocs.yml | 2 +- gen/mirror1-cli/src/cmn.rs | 2 +- gen/mirror1-cli/src/main.rs | 703 +- gen/mirror1/Cargo.toml | 2 +- gen/mirror1/README.md | 11 +- gen/mirror1/src/cmn.rs | 54 +- gen/mirror1/src/lib.rs | 423 +- gen/oauth2_v2-cli/Cargo.toml | 2 +- gen/oauth2_v2-cli/README.md | 105 +- gen/oauth2_v2-cli/mkdocs.yml | 2 +- gen/oauth2_v2-cli/src/cmn.rs | 2 +- gen/oauth2_v2-cli/src/main.rs | 41 +- gen/oauth2_v2/Cargo.toml | 2 +- gen/oauth2_v2/README.md | 9 +- gen/oauth2_v2/src/cmn.rs | 54 +- gen/oauth2_v2/src/lib.rs | 66 +- gen/pagespeedonline2-cli/Cargo.toml | 2 +- gen/pagespeedonline2-cli/README.md | 98 +- gen/pagespeedonline2-cli/mkdocs.yml | 2 +- gen/pagespeedonline2-cli/src/cmn.rs | 2 +- gen/pagespeedonline2-cli/src/main.rs | 25 +- gen/pagespeedonline2/Cargo.toml | 2 +- gen/pagespeedonline2/README.md | 9 +- gen/pagespeedonline2/src/cmn.rs | 54 +- gen/pagespeedonline2/src/lib.rs | 33 +- gen/plus1-cli/Cargo.toml | 2 +- gen/plus1-cli/README.md | 113 +- gen/plus1-cli/mkdocs.yml | 2 +- gen/plus1-cli/src/cmn.rs | 2 +- gen/plus1-cli/src/main.rs | 156 +- gen/plus1/Cargo.toml | 2 +- gen/plus1/README.md | 9 +- gen/plus1/src/cmn.rs | 54 +- gen/plus1/src/lib.rs | 162 +- gen/plusdomains1-cli/Cargo.toml | 2 +- gen/plusdomains1-cli/README.md | 121 +- gen/plusdomains1-cli/mkdocs.yml | 2 +- gen/plusdomains1-cli/src/cmn.rs | 2 +- gen/plusdomains1-cli/src/main.rs | 511 +- gen/plusdomains1/Cargo.toml | 2 +- gen/plusdomains1/README.md | 9 +- gen/plusdomains1/src/cmn.rs | 54 +- gen/plusdomains1/src/lib.rs | 315 +- gen/prediction1d6-cli/Cargo.toml | 2 +- gen/prediction1d6-cli/README.md | 109 +- gen/prediction1d6-cli/mkdocs.yml | 2 +- gen/prediction1d6-cli/src/cmn.rs | 2 +- gen/prediction1d6-cli/src/main.rs | 257 +- gen/prediction1d6/Cargo.toml | 2 +- gen/prediction1d6/README.md | 11 +- gen/prediction1d6/src/cmn.rs | 54 +- gen/prediction1d6/src/lib.rs | 152 +- gen/pubsub1_beta2-cli/Cargo.toml | 2 +- gen/pubsub1_beta2-cli/README.md | 115 +- gen/pubsub1_beta2-cli/mkdocs.yml | 2 +- gen/pubsub1_beta2-cli/src/cmn.rs | 2 +- gen/pubsub1_beta2-cli/src/main.rs | 460 +- gen/pubsub1_beta2/Cargo.toml | 2 +- gen/pubsub1_beta2/README.md | 11 +- gen/pubsub1_beta2/src/cmn.rs | 54 +- gen/pubsub1_beta2/src/lib.rs | 278 +- gen/qpxexpress1-cli/Cargo.toml | 2 +- gen/qpxexpress1-cli/README.md | 98 +- gen/qpxexpress1-cli/mkdocs.yml | 2 +- gen/qpxexpress1-cli/src/cmn.rs | 2 +- gen/qpxexpress1-cli/src/main.rs | 88 +- gen/qpxexpress1/Cargo.toml | 2 +- gen/qpxexpress1/README.md | 11 +- gen/qpxexpress1/src/cmn.rs | 54 +- gen/qpxexpress1/src/lib.rs | 47 +- gen/replicapool1_beta2-cli/Cargo.toml | 2 +- gen/replicapool1_beta2-cli/README.md | 113 +- gen/replicapool1_beta2-cli/mkdocs.yml | 2 +- gen/replicapool1_beta2-cli/src/cmn.rs | 2 +- gen/replicapool1_beta2-cli/src/main.rs | 397 +- gen/replicapool1_beta2/Cargo.toml | 2 +- gen/replicapool1_beta2/README.md | 9 +- gen/replicapool1_beta2/src/cmn.rs | 54 +- gen/replicapool1_beta2/src/lib.rs | 214 +- gen/replicapoolupdater1_beta1-cli/Cargo.toml | 2 +- gen/replicapoolupdater1_beta1-cli/README.md | 110 +- gen/replicapoolupdater1_beta1-cli/mkdocs.yml | 2 +- gen/replicapoolupdater1_beta1-cli/src/cmn.rs | 2 +- gen/replicapoolupdater1_beta1-cli/src/main.rs | 135 +- gen/replicapoolupdater1_beta1/Cargo.toml | 2 +- gen/replicapoolupdater1_beta1/README.md | 9 +- gen/replicapoolupdater1_beta1/src/cmn.rs | 54 +- gen/replicapoolupdater1_beta1/src/lib.rs | 131 +- gen/reseller1_sandbox-cli/Cargo.toml | 2 +- gen/reseller1_sandbox-cli/README.md | 115 +- gen/reseller1_sandbox-cli/mkdocs.yml | 2 +- gen/reseller1_sandbox-cli/src/cmn.rs | 2 +- gen/reseller1_sandbox-cli/src/main.rs | 632 +- gen/reseller1_sandbox/Cargo.toml | 2 +- gen/reseller1_sandbox/README.md | 9 +- gen/reseller1_sandbox/src/cmn.rs | 54 +- gen/reseller1_sandbox/src/lib.rs | 244 +- gen/resourceviews1_beta2-cli/Cargo.toml | 2 +- gen/resourceviews1_beta2-cli/README.md | 112 +- gen/resourceviews1_beta2-cli/mkdocs.yml | 2 +- gen/resourceviews1_beta2-cli/src/cmn.rs | 2 +- gen/resourceviews1_beta2-cli/src/main.rs | 292 +- gen/resourceviews1_beta2/Cargo.toml | 2 +- gen/resourceviews1_beta2/README.md | 11 +- gen/resourceviews1_beta2/src/cmn.rs | 54 +- gen/resourceviews1_beta2/src/lib.rs | 187 +- gen/siteverification1-cli/Cargo.toml | 2 +- gen/siteverification1-cli/README.md | 108 +- gen/siteverification1-cli/mkdocs.yml | 2 +- gen/siteverification1-cli/src/cmn.rs | 2 +- gen/siteverification1-cli/src/main.rs | 362 +- gen/siteverification1/Cargo.toml | 2 +- gen/siteverification1/README.md | 11 +- gen/siteverification1/src/cmn.rs | 54 +- gen/siteverification1/src/lib.rs | 141 +- gen/spectrum1_explorer-cli/Cargo.toml | 2 +- gen/spectrum1_explorer-cli/README.md | 103 +- gen/spectrum1_explorer-cli/mkdocs.yml | 2 +- gen/spectrum1_explorer-cli/src/cmn.rs | 2 +- gen/spectrum1_explorer-cli/src/main.rs | 399 +- gen/spectrum1_explorer/Cargo.toml | 2 +- gen/spectrum1_explorer/README.md | 11 +- gen/spectrum1_explorer/src/cmn.rs | 54 +- gen/spectrum1_explorer/src/lib.rs | 152 +- gen/sqladmin1_beta4-cli/Cargo.toml | 2 +- gen/sqladmin1_beta4-cli/README.md | 136 +- gen/sqladmin1_beta4-cli/mkdocs.yml | 2 +- gen/sqladmin1_beta4-cli/src/cmn.rs | 2 +- gen/sqladmin1_beta4-cli/src/main.rs | 1003 +-- gen/sqladmin1_beta4/Cargo.toml | 2 +- gen/sqladmin1_beta4/README.md | 11 +- gen/sqladmin1_beta4/src/cmn.rs | 54 +- gen/sqladmin1_beta4/src/lib.rs | 541 +- gen/storage1-cli/Cargo.toml | 2 +- gen/storage1-cli/README.md | 136 +- gen/storage1-cli/mkdocs.yml | 2 +- gen/storage1-cli/src/cmn.rs | 2 +- gen/storage1-cli/src/main.rs | 1950 +++--- gen/storage1/Cargo.toml | 2 +- gen/storage1/README.md | 11 +- gen/storage1/src/cmn.rs | 54 +- gen/storage1/src/lib.rs | 616 +- gen/tagmanager1-cli/Cargo.toml | 2 +- gen/tagmanager1-cli/README.md | 147 +- gen/tagmanager1-cli/mkdocs.yml | 2 +- gen/tagmanager1-cli/src/cmn.rs | 2 +- gen/tagmanager1-cli/src/main.rs | 1416 ++-- gen/tagmanager1/Cargo.toml | 2 +- gen/tagmanager1/README.md | 11 +- gen/tagmanager1/src/cmn.rs | 54 +- gen/tagmanager1/src/lib.rs | 686 +- gen/taskqueue1_beta2-cli/Cargo.toml | 2 +- gen/taskqueue1_beta2-cli/README.md | 109 +- gen/taskqueue1_beta2-cli/mkdocs.yml | 2 +- gen/taskqueue1_beta2-cli/src/cmn.rs | 2 +- gen/taskqueue1_beta2-cli/src/main.rs | 260 +- gen/taskqueue1_beta2/Cargo.toml | 2 +- gen/taskqueue1_beta2/README.md | 9 +- gen/taskqueue1_beta2/src/cmn.rs | 54 +- gen/taskqueue1_beta2/src/lib.rs | 138 +- gen/tasks1-cli/Cargo.toml | 2 +- gen/tasks1-cli/README.md | 115 +- gen/tasks1-cli/mkdocs.yml | 2 +- gen/tasks1-cli/src/cmn.rs | 2 +- gen/tasks1-cli/src/main.rs | 517 +- gen/tasks1/Cargo.toml | 2 +- gen/tasks1/README.md | 9 +- gen/tasks1/src/cmn.rs | 54 +- gen/tasks1/src/lib.rs | 230 +- gen/translate2-cli/Cargo.toml | 2 +- gen/translate2-cli/README.md | 100 +- gen/translate2-cli/mkdocs.yml | 2 +- gen/translate2-cli/src/cmn.rs | 2 +- gen/translate2-cli/src/main.rs | 29 +- gen/translate2/Cargo.toml | 2 +- gen/translate2/README.md | 9 +- gen/translate2/src/cmn.rs | 54 +- gen/translate2/src/lib.rs | 55 +- gen/urlshortener1-cli/Cargo.toml | 2 +- gen/urlshortener1-cli/README.md | 104 +- gen/urlshortener1-cli/mkdocs.yml | 2 +- gen/urlshortener1-cli/src/cmn.rs | 2 +- gen/urlshortener1-cli/src/main.rs | 105 +- gen/urlshortener1/Cargo.toml | 2 +- gen/urlshortener1/README.md | 9 +- gen/urlshortener1/src/cmn.rs | 54 +- gen/urlshortener1/src/lib.rs | 65 +- gen/webfonts1-cli/Cargo.toml | 2 +- gen/webfonts1-cli/README.md | 98 +- gen/webfonts1-cli/mkdocs.yml | 2 +- gen/webfonts1-cli/src/cmn.rs | 2 +- gen/webfonts1-cli/src/main.rs | 25 +- gen/webfonts1/Cargo.toml | 2 +- gen/webfonts1/README.md | 9 +- gen/webfonts1/src/cmn.rs | 54 +- gen/webfonts1/src/lib.rs | 33 +- gen/webmasters3-cli/Cargo.toml | 2 +- gen/webmasters3-cli/README.md | 113 +- gen/webmasters3-cli/mkdocs.yml | 2 +- gen/webmasters3-cli/src/cmn.rs | 2 +- gen/webmasters3-cli/src/main.rs | 87 +- gen/webmasters3/Cargo.toml | 2 +- gen/webmasters3/README.md | 9 +- gen/webmasters3/src/cmn.rs | 54 +- gen/webmasters3/src/lib.rs | 144 +- gen/youtube3-cli/Cargo.toml | 2 +- gen/youtube3-cli/README.md | 162 +- gen/youtube3-cli/mkdocs.yml | 2 +- gen/youtube3-cli/src/cmn.rs | 2 +- gen/youtube3-cli/src/main.rs | 2020 +++--- gen/youtube3/README.md | 9 +- gen/youtube3/cargo.toml | 2 +- gen/youtube3/src/cmn.rs | 54 +- gen/youtube3/src/lib.rs | 1066 ++- gen/youtubeanalytics1-cli/Cargo.toml | 2 +- gen/youtubeanalytics1-cli/README.md | 111 +- gen/youtubeanalytics1-cli/mkdocs.yml | 2 +- gen/youtubeanalytics1-cli/src/cmn.rs | 2 +- gen/youtubeanalytics1-cli/src/main.rs | 308 +- gen/youtubeanalytics1/Cargo.toml | 2 +- gen/youtubeanalytics1/README.md | 9 +- gen/youtubeanalytics1/src/cmn.rs | 54 +- gen/youtubeanalytics1/src/lib.rs | 158 +- 770 files changed, 63340 insertions(+), 31427 deletions(-) create mode 100644 etc/api/adexchangebuyer/v1.3/crates/0.1.6-api+20150326 create mode 100644 etc/api/adexchangeseller/v2.0/crates/0.1.6-api+20150326 create mode 100644 etc/api/admin/directory_v1/crates/0.1.6-api+20150314 create mode 100644 etc/api/admin/email_migration_v2/crates/0.1.6-api+20150303 create mode 100644 etc/api/admin/reports_v1/crates/0.1.6-api+20150115 create mode 100644 etc/api/adsense/v1.4/crates/0.1.6-api+20150326 create mode 100644 etc/api/adsensehost/v4.1/crates/0.1.6-api+20150307 create mode 100644 etc/api/analytics/v3/crates/0.1.6-api+20150305 create mode 100644 etc/api/androidenterprise/v1/crates/0.1.6-api+20150309 create mode 100644 etc/api/androidpublisher/v2/crates/0.1.6-api+20150323 create mode 100644 etc/api/appsactivity/v1/crates/0.1.6-api+20140828 create mode 100644 etc/api/appstate/v1/crates/0.1.6-api+20150414 create mode 100644 etc/api/audit/v1/crates/0.1.6-api+20150419 create mode 100644 etc/api/autoscaler/v1beta2/crates/0.1.6-api+20141112 create mode 100644 etc/api/bigquery/v2/crates/0.1.6-api+20150326 create mode 100644 etc/api/blogger/v3/crates/0.1.6-api+20150422 create mode 100644 etc/api/books/v1/crates/0.1.6-api+20150401 create mode 100644 etc/api/calendar/v3/crates/0.1.6-api+20150326 create mode 100644 etc/api/civicinfo/v2/crates/0.1.6-api+20150302 create mode 100644 etc/api/cloudlatencytest/v2/crates/0.1.6-api+20150206 create mode 100644 etc/api/cloudmonitoring/v2beta2/crates/0.1.6-api+20150401 create mode 100644 etc/api/cloudsearch/v1/crates/0.1.6-api+20150416 create mode 100644 etc/api/compute/v1/crates/0.1.6-api+20150326 create mode 100644 etc/api/container/v1beta1/crates/0.1.6-api+20150420 create mode 100644 etc/api/content/v2/crates/0.1.6-api+20150421 create mode 100644 etc/api/coordinate/v1/crates/0.1.6-api+20141215 create mode 100644 etc/api/customsearch/v1/crates/0.1.6-api+20131205 create mode 100644 etc/api/datastore/v1beta2/crates/0.1.6-api+20150402 create mode 100644 etc/api/deploymentmanager/v2beta1/crates/0.1.6-api+20150415 create mode 100644 etc/api/dfareporting/v2.1/crates/0.1.6-api+20150326 create mode 100644 etc/api/discovery/v1/crates/0.1.6-api+00000000 create mode 100644 etc/api/dns/v1/crates/0.1.6-api+20150218 create mode 100644 etc/api/doubleclickbidmanager/v1/crates/0.1.6-api+20150326 create mode 100644 etc/api/doubleclicksearch/v2/crates/0.1.6-api+20150303 create mode 100644 etc/api/drive/v2/crates/0.1.6-api+20150326 create mode 100644 etc/api/fitness/v1/crates/0.1.6-api+20150326 create mode 100644 etc/api/freebase/v1/crates/0.1.6-api+20150330 create mode 100644 etc/api/freebase/v1sandbox/crates/0.1.6-api+20150330 create mode 100644 etc/api/fusiontables/v2/crates/0.1.6-api+20150326 create mode 100644 etc/api/games/v1/crates/0.1.6-api+20150413 create mode 100644 etc/api/gamesconfiguration/v1configuration/crates/0.1.6-api+20150413 create mode 100644 etc/api/gamesmanagement/v1management/crates/0.1.6-api+20150413 create mode 100644 etc/api/gan/v1beta1/crates/0.1.6-api+20130205 create mode 100644 etc/api/genomics/v1beta2/crates/0.1.6-api+20150326 create mode 100644 etc/api/gmail/v1/crates/0.1.6-api+20150303 create mode 100644 etc/api/groupsmigration/v1/crates/0.1.6-api+20140416 create mode 100644 etc/api/groupssettings/v1/crates/0.1.6-api+20140428 create mode 100644 etc/api/identitytoolkit/v3/crates/0.1.6-api+20150406 create mode 100644 etc/api/licensing/v1/crates/0.1.6-api+20140122 create mode 100644 etc/api/logging/v1beta3/crates/0.1.6-api+20150326 create mode 100644 etc/api/manager/v1beta2/crates/0.1.6-api+20140915 create mode 100644 etc/api/mapsengine/v1/crates/0.1.6-api+20150414 create mode 100644 etc/api/mirror/v1/crates/0.1.6-api+20150220 create mode 100644 etc/api/oauth2/v2/crates/0.1.6-api+20150416 create mode 100644 etc/api/pagespeedonline/v2/crates/0.1.6-api+20150317 create mode 100644 etc/api/plus/v1/crates/0.1.6-api+20150303 create mode 100644 etc/api/plusdomains/v1/crates/0.1.6-api+20150303 create mode 100644 etc/api/prediction/v1.6/crates/0.1.6-api+20140522 create mode 100644 etc/api/pubsub/v1beta2/crates/0.1.6-api+20150326 create mode 100644 etc/api/qpxexpress/v1/crates/0.1.6-api+20140321 create mode 100644 etc/api/replicapool/v1beta2/crates/0.1.6-api+20150223 create mode 100644 etc/api/replicapoolupdater/v1beta1/crates/0.1.6-api+20150326 create mode 100644 etc/api/reseller/v1sandbox/crates/0.1.6-api+20141112 create mode 100644 etc/api/resourceviews/v1beta2/crates/0.1.6-api+20150302 create mode 100644 etc/api/siteverification/v1/crates/0.1.6-api+20131007 create mode 100644 etc/api/spectrum/v1explorer/crates/0.1.6-api+20150112 create mode 100644 etc/api/sqladmin/v1beta4/crates/0.1.6-api+20150305 create mode 100644 etc/api/storage/v1/crates/0.1.6-api+20150326 create mode 100644 etc/api/tagmanager/v1/crates/0.1.6-api+20150121 create mode 100644 etc/api/taskqueue/v1beta2/crates/0.1.6-api+20141111 create mode 100644 etc/api/tasks/v1/crates/0.1.6-api+20141121 create mode 100644 etc/api/translate/v2/crates/0.1.6-api+20141123 create mode 100644 etc/api/urlshortener/v1/crates/0.1.6-api+20150319 create mode 100644 etc/api/webfonts/v1/crates/0.1.6-api+20140210 create mode 100644 etc/api/webmasters/v3/crates/0.1.6-api+20140908 create mode 100644 etc/api/youtube/v3/crates/0.1.6-api+20150414 create mode 100644 etc/api/youtubeanalytics/v1/crates/0.1.6-api+20150304 diff --git a/etc/api/adexchangebuyer/v1.3/crates/0.1.6-api+20150326 b/etc/api/adexchangebuyer/v1.3/crates/0.1.6-api+20150326 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/adexchangeseller/v2.0/crates/0.1.6-api+20150326 b/etc/api/adexchangeseller/v2.0/crates/0.1.6-api+20150326 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/admin/directory_v1/crates/0.1.6-api+20150314 b/etc/api/admin/directory_v1/crates/0.1.6-api+20150314 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/admin/email_migration_v2/crates/0.1.6-api+20150303 b/etc/api/admin/email_migration_v2/crates/0.1.6-api+20150303 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/admin/reports_v1/crates/0.1.6-api+20150115 b/etc/api/admin/reports_v1/crates/0.1.6-api+20150115 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/adsense/v1.4/crates/0.1.6-api+20150326 b/etc/api/adsense/v1.4/crates/0.1.6-api+20150326 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/adsensehost/v4.1/crates/0.1.6-api+20150307 b/etc/api/adsensehost/v4.1/crates/0.1.6-api+20150307 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/analytics/v3/crates/0.1.6-api+20150305 b/etc/api/analytics/v3/crates/0.1.6-api+20150305 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/androidenterprise/v1/crates/0.1.6-api+20150309 b/etc/api/androidenterprise/v1/crates/0.1.6-api+20150309 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/androidpublisher/v2/crates/0.1.6-api+20150323 b/etc/api/androidpublisher/v2/crates/0.1.6-api+20150323 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/appsactivity/v1/crates/0.1.6-api+20140828 b/etc/api/appsactivity/v1/crates/0.1.6-api+20140828 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/appstate/v1/crates/0.1.6-api+20150414 b/etc/api/appstate/v1/crates/0.1.6-api+20150414 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/audit/v1/crates/0.1.6-api+20150419 b/etc/api/audit/v1/crates/0.1.6-api+20150419 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/autoscaler/v1beta2/crates/0.1.6-api+20141112 b/etc/api/autoscaler/v1beta2/crates/0.1.6-api+20141112 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/bigquery/v2/crates/0.1.6-api+20150326 b/etc/api/bigquery/v2/crates/0.1.6-api+20150326 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/blogger/v3/crates/0.1.6-api+20150422 b/etc/api/blogger/v3/crates/0.1.6-api+20150422 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/books/v1/crates/0.1.6-api+20150401 b/etc/api/books/v1/crates/0.1.6-api+20150401 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/calendar/v3/crates/0.1.6-api+20150326 b/etc/api/calendar/v3/crates/0.1.6-api+20150326 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/civicinfo/v2/crates/0.1.6-api+20150302 b/etc/api/civicinfo/v2/crates/0.1.6-api+20150302 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/cloudlatencytest/v2/crates/0.1.6-api+20150206 b/etc/api/cloudlatencytest/v2/crates/0.1.6-api+20150206 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/cloudmonitoring/v2beta2/crates/0.1.6-api+20150401 b/etc/api/cloudmonitoring/v2beta2/crates/0.1.6-api+20150401 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/cloudsearch/v1/crates/0.1.6-api+20150416 b/etc/api/cloudsearch/v1/crates/0.1.6-api+20150416 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/compute/v1/crates/0.1.6-api+20150326 b/etc/api/compute/v1/crates/0.1.6-api+20150326 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/container/v1beta1/crates/0.1.6-api+20150420 b/etc/api/container/v1beta1/crates/0.1.6-api+20150420 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/content/v2/crates/0.1.6-api+20150421 b/etc/api/content/v2/crates/0.1.6-api+20150421 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/coordinate/v1/crates/0.1.6-api+20141215 b/etc/api/coordinate/v1/crates/0.1.6-api+20141215 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/customsearch/v1/crates/0.1.6-api+20131205 b/etc/api/customsearch/v1/crates/0.1.6-api+20131205 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/datastore/v1beta2/crates/0.1.6-api+20150402 b/etc/api/datastore/v1beta2/crates/0.1.6-api+20150402 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/deploymentmanager/v2beta1/crates/0.1.6-api+20150415 b/etc/api/deploymentmanager/v2beta1/crates/0.1.6-api+20150415 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/dfareporting/v2.1/crates/0.1.6-api+20150326 b/etc/api/dfareporting/v2.1/crates/0.1.6-api+20150326 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/discovery/v1/crates/0.1.6-api+00000000 b/etc/api/discovery/v1/crates/0.1.6-api+00000000 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/dns/v1/crates/0.1.6-api+20150218 b/etc/api/dns/v1/crates/0.1.6-api+20150218 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/doubleclickbidmanager/v1/crates/0.1.6-api+20150326 b/etc/api/doubleclickbidmanager/v1/crates/0.1.6-api+20150326 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/doubleclicksearch/v2/crates/0.1.6-api+20150303 b/etc/api/doubleclicksearch/v2/crates/0.1.6-api+20150303 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/drive/v2/crates/0.1.6-api+20150326 b/etc/api/drive/v2/crates/0.1.6-api+20150326 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/fitness/v1/crates/0.1.6-api+20150326 b/etc/api/fitness/v1/crates/0.1.6-api+20150326 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/freebase/v1/crates/0.1.6-api+20150330 b/etc/api/freebase/v1/crates/0.1.6-api+20150330 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/freebase/v1sandbox/crates/0.1.6-api+20150330 b/etc/api/freebase/v1sandbox/crates/0.1.6-api+20150330 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/fusiontables/v2/crates/0.1.6-api+20150326 b/etc/api/fusiontables/v2/crates/0.1.6-api+20150326 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/games/v1/crates/0.1.6-api+20150413 b/etc/api/games/v1/crates/0.1.6-api+20150413 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/gamesconfiguration/v1configuration/crates/0.1.6-api+20150413 b/etc/api/gamesconfiguration/v1configuration/crates/0.1.6-api+20150413 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/gamesmanagement/v1management/crates/0.1.6-api+20150413 b/etc/api/gamesmanagement/v1management/crates/0.1.6-api+20150413 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/gan/v1beta1/crates/0.1.6-api+20130205 b/etc/api/gan/v1beta1/crates/0.1.6-api+20130205 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/genomics/v1beta2/crates/0.1.6-api+20150326 b/etc/api/genomics/v1beta2/crates/0.1.6-api+20150326 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/gmail/v1/crates/0.1.6-api+20150303 b/etc/api/gmail/v1/crates/0.1.6-api+20150303 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/groupsmigration/v1/crates/0.1.6-api+20140416 b/etc/api/groupsmigration/v1/crates/0.1.6-api+20140416 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/groupssettings/v1/crates/0.1.6-api+20140428 b/etc/api/groupssettings/v1/crates/0.1.6-api+20140428 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/identitytoolkit/v3/crates/0.1.6-api+20150406 b/etc/api/identitytoolkit/v3/crates/0.1.6-api+20150406 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/licensing/v1/crates/0.1.6-api+20140122 b/etc/api/licensing/v1/crates/0.1.6-api+20140122 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/logging/v1beta3/crates/0.1.6-api+20150326 b/etc/api/logging/v1beta3/crates/0.1.6-api+20150326 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/manager/v1beta2/crates/0.1.6-api+20140915 b/etc/api/manager/v1beta2/crates/0.1.6-api+20140915 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/mapsengine/v1/crates/0.1.6-api+20150414 b/etc/api/mapsengine/v1/crates/0.1.6-api+20150414 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/mirror/v1/crates/0.1.6-api+20150220 b/etc/api/mirror/v1/crates/0.1.6-api+20150220 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/oauth2/v2/crates/0.1.6-api+20150416 b/etc/api/oauth2/v2/crates/0.1.6-api+20150416 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/pagespeedonline/v2/crates/0.1.6-api+20150317 b/etc/api/pagespeedonline/v2/crates/0.1.6-api+20150317 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/plus/v1/crates/0.1.6-api+20150303 b/etc/api/plus/v1/crates/0.1.6-api+20150303 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/plusdomains/v1/crates/0.1.6-api+20150303 b/etc/api/plusdomains/v1/crates/0.1.6-api+20150303 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/prediction/v1.6/crates/0.1.6-api+20140522 b/etc/api/prediction/v1.6/crates/0.1.6-api+20140522 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/pubsub/v1beta2/crates/0.1.6-api+20150326 b/etc/api/pubsub/v1beta2/crates/0.1.6-api+20150326 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/qpxexpress/v1/crates/0.1.6-api+20140321 b/etc/api/qpxexpress/v1/crates/0.1.6-api+20140321 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/replicapool/v1beta2/crates/0.1.6-api+20150223 b/etc/api/replicapool/v1beta2/crates/0.1.6-api+20150223 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/replicapoolupdater/v1beta1/crates/0.1.6-api+20150326 b/etc/api/replicapoolupdater/v1beta1/crates/0.1.6-api+20150326 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/reseller/v1sandbox/crates/0.1.6-api+20141112 b/etc/api/reseller/v1sandbox/crates/0.1.6-api+20141112 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/resourceviews/v1beta2/crates/0.1.6-api+20150302 b/etc/api/resourceviews/v1beta2/crates/0.1.6-api+20150302 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/siteverification/v1/crates/0.1.6-api+20131007 b/etc/api/siteverification/v1/crates/0.1.6-api+20131007 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/spectrum/v1explorer/crates/0.1.6-api+20150112 b/etc/api/spectrum/v1explorer/crates/0.1.6-api+20150112 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/sqladmin/v1beta4/crates/0.1.6-api+20150305 b/etc/api/sqladmin/v1beta4/crates/0.1.6-api+20150305 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/storage/v1/crates/0.1.6-api+20150326 b/etc/api/storage/v1/crates/0.1.6-api+20150326 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/tagmanager/v1/crates/0.1.6-api+20150121 b/etc/api/tagmanager/v1/crates/0.1.6-api+20150121 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/taskqueue/v1beta2/crates/0.1.6-api+20141111 b/etc/api/taskqueue/v1beta2/crates/0.1.6-api+20141111 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/tasks/v1/crates/0.1.6-api+20141121 b/etc/api/tasks/v1/crates/0.1.6-api+20141121 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/translate/v2/crates/0.1.6-api+20141123 b/etc/api/translate/v2/crates/0.1.6-api+20141123 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/urlshortener/v1/crates/0.1.6-api+20150319 b/etc/api/urlshortener/v1/crates/0.1.6-api+20150319 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/webfonts/v1/crates/0.1.6-api+20140210 b/etc/api/webfonts/v1/crates/0.1.6-api+20140210 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/webmasters/v3/crates/0.1.6-api+20140908 b/etc/api/webmasters/v3/crates/0.1.6-api+20140908 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/youtube/v3/crates/0.1.6-api+20150414 b/etc/api/youtube/v3/crates/0.1.6-api+20150414 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/etc/api/youtubeanalytics/v1/crates/0.1.6-api+20150304 b/etc/api/youtubeanalytics/v1/crates/0.1.6-api+20150304 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gen/adexchangebuyer1d3-cli/Cargo.toml b/gen/adexchangebuyer1d3-cli/Cargo.toml index 57c9ab0108..91119d1062 100644 --- a/gen/adexchangebuyer1d3-cli/Cargo.toml +++ b/gen/adexchangebuyer1d3-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-adexchangebuyer1d3-cli" -version = "0.0.1+20150326" +version = "0.1.0+20150326" authors = ["Sebastian Thiel "] description = "A complete library to interact with Ad Exchange Buyer (protocol v1.3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/adexchangebuyer1d3-cli" diff --git a/gen/adexchangebuyer1d3-cli/README.md b/gen/adexchangebuyer1d3-cli/README.md index 863572e953..af5c882bbb 100644 --- a/gen/adexchangebuyer1d3-cli/README.md +++ b/gen/adexchangebuyer1d3-cli/README.md @@ -1,4 +1,122 @@ -# HELLO ADEXCHANGEBUYER:V1.3 + +The `adexchangebuyer1d3` command-line interface *(CLI)* allows to use most features of the *Google Ad Exchange Buyer* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *Ad Exchange Buyer* API at revision *20150326*. The CLI is at version *0.1.0*. + +```bash + adexchangebuyer1d3 [options] accounts get [-p ...] [-o ] + adexchangebuyer1d3 [options] accounts list [-p ...] [-o ] + adexchangebuyer1d3 [options] accounts patch -r ... [-p ...] [-o ] + adexchangebuyer1d3 [options] accounts update -r ... [-p ...] [-o ] + adexchangebuyer1d3 [options] billing-info get [-p ...] [-o ] + adexchangebuyer1d3 [options] billing-info list [-p ...] [-o ] + adexchangebuyer1d3 [options] budget get [-p ...] [-o ] + adexchangebuyer1d3 [options] budget patch -r ... [-p ...] [-o ] + adexchangebuyer1d3 [options] budget update -r ... [-p ...] [-o ] + adexchangebuyer1d3 [options] creatives get [-p ...] [-o ] + adexchangebuyer1d3 [options] creatives insert -r ... [-p ...] [-o ] + adexchangebuyer1d3 [options] creatives list [-p ...] [-o ] + adexchangebuyer1d3 [options] direct-deals get [-p ...] [-o ] + adexchangebuyer1d3 [options] direct-deals list [-p ...] [-o ] + adexchangebuyer1d3 [options] performance-report list [-p ...] [-o ] + adexchangebuyer1d3 [options] pretargeting-config delete [-p ...] + adexchangebuyer1d3 [options] pretargeting-config get [-p ...] [-o ] + adexchangebuyer1d3 [options] pretargeting-config insert -r ... [-p ...] [-o ] + adexchangebuyer1d3 [options] pretargeting-config list [-p ...] [-o ] + adexchangebuyer1d3 [options] pretargeting-config patch -r ... [-p ...] [-o ] + adexchangebuyer1d3 [options] pretargeting-config update -r ... [-p ...] [-o ] + adexchangebuyer1d3 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_adexchangebuyer1d3_cli/index.html + +Configuration: + --scope + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `adexchangebuyer1d3-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/adexchangebuyer1d3-token-.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/adexchangebuyer1d3-secret.json`, assuming that the required *adexchangebuyer* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `adexchangebuyer1d3 --debug [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/adexchangebuyer1d3-cli/mkdocs.yml b/gen/adexchangebuyer1d3-cli/mkdocs.yml index f104b54d9a..e1fd1f6136 100644 --- a/gen/adexchangebuyer1d3-cli/mkdocs.yml +++ b/gen/adexchangebuyer1d3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Ad Exchange Buyer v0.0.1+20150326 +site_name: Ad Exchange Buyer v0.1.0+20150326 site_url: http://byron.github.io/google-apis-rs/google-adexchangebuyer1d3-cli site_description: Write integrating applications with bcore diff --git a/gen/adexchangebuyer1d3-cli/src/cmn.rs b/gen/adexchangebuyer1d3-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/adexchangebuyer1d3-cli/src/cmn.rs +++ b/gen/adexchangebuyer1d3-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/adexchangebuyer1d3-cli/src/main.rs b/gen/adexchangebuyer1d3-cli/src/main.rs index b8727b852b..98a6f3da1c 100644 --- a/gen/adexchangebuyer1d3-cli/src/main.rs +++ b/gen/adexchangebuyer1d3-cli/src/main.rs @@ -19,46 +19,47 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - adexchangebuyer1d3 [options] accounts get [-p ]... [-o ] - adexchangebuyer1d3 [options] accounts list [-p ]... [-o ] - adexchangebuyer1d3 [options] accounts patch -r ... [-p ]... [-o ] - adexchangebuyer1d3 [options] accounts update -r ... [-p ]... [-o ] - adexchangebuyer1d3 [options] billing-info get [-p ]... [-o ] - adexchangebuyer1d3 [options] billing-info list [-p ]... [-o ] - adexchangebuyer1d3 [options] budget get [-p ]... [-o ] - adexchangebuyer1d3 [options] budget patch -r ... [-p ]... [-o ] - adexchangebuyer1d3 [options] budget update -r ... [-p ]... [-o ] - adexchangebuyer1d3 [options] creatives get [-p ]... [-o ] - adexchangebuyer1d3 [options] creatives insert -r ... [-p ]... [-o ] - adexchangebuyer1d3 [options] creatives list [-p ]... [-o ] - adexchangebuyer1d3 [options] direct-deals get [-p ]... [-o ] - adexchangebuyer1d3 [options] direct-deals list [-p ]... [-o ] - adexchangebuyer1d3 [options] performance-report list [-p ]... [-o ] - adexchangebuyer1d3 [options] pretargeting-config delete [-p ]... - adexchangebuyer1d3 [options] pretargeting-config get [-p ]... [-o ] - adexchangebuyer1d3 [options] pretargeting-config insert -r ... [-p ]... [-o ] - adexchangebuyer1d3 [options] pretargeting-config list [-p ]... [-o ] - adexchangebuyer1d3 [options] pretargeting-config patch -r ... [-p ]... [-o ] - adexchangebuyer1d3 [options] pretargeting-config update -r ... [-p ]... [-o ] + adexchangebuyer1d3 [options] accounts get [-p ...] [-o ] + adexchangebuyer1d3 [options] accounts list [-p ...] [-o ] + adexchangebuyer1d3 [options] accounts patch -r ... [-p ...] [-o ] + adexchangebuyer1d3 [options] accounts update -r ... [-p ...] [-o ] + adexchangebuyer1d3 [options] billing-info get [-p ...] [-o ] + adexchangebuyer1d3 [options] billing-info list [-p ...] [-o ] + adexchangebuyer1d3 [options] budget get [-p ...] [-o ] + adexchangebuyer1d3 [options] budget patch -r ... [-p ...] [-o ] + adexchangebuyer1d3 [options] budget update -r ... [-p ...] [-o ] + adexchangebuyer1d3 [options] creatives get [-p ...] [-o ] + adexchangebuyer1d3 [options] creatives insert -r ... [-p ...] [-o ] + adexchangebuyer1d3 [options] creatives list [-p ...] [-o ] + adexchangebuyer1d3 [options] direct-deals get [-p ...] [-o ] + adexchangebuyer1d3 [options] direct-deals list [-p ...] [-o ] + adexchangebuyer1d3 [options] performance-report list [-p ...] [-o ] + adexchangebuyer1d3 [options] pretargeting-config delete [-p ...] + adexchangebuyer1d3 [options] pretargeting-config get [-p ...] [-o ] + adexchangebuyer1d3 [options] pretargeting-config insert -r ... [-p ...] [-o ] + adexchangebuyer1d3 [options] pretargeting-config list [-p ...] [-o ] + adexchangebuyer1d3 [options] pretargeting-config patch -r ... [-p ...] [-o ] + adexchangebuyer1d3 [options] pretargeting-config update -r ... [-p ...] [-o ] adexchangebuyer1d3 --help -All documentation details can be found TODO: +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_adexchangebuyer1d3_cli/index.html Configuration: --scope - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -108,6 +109,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -151,6 +155,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -167,38 +174,24 @@ impl Engine { fn _accounts_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Account::default(); - let id: i32 = arg_from_str(&self.opt.arg_id, err, "", "integer"); - let mut call = self.hub.accounts().patch(&request, id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Account::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -221,15 +214,41 @@ impl Engine { request.cookie_matching_url = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let id: i32 = arg_from_str(&self.opt.arg_id, err, "", "integer"); + let mut call = self.hub.accounts().patch(request, id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -246,38 +265,24 @@ impl Engine { fn _accounts_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Account::default(); - let id: i32 = arg_from_str(&self.opt.arg_id, err, "", "integer"); - let mut call = self.hub.accounts().update(&request, id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Account::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -300,15 +305,41 @@ impl Engine { request.cookie_matching_url = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let id: i32 = arg_from_str(&self.opt.arg_id, err, "", "integer"); + let mut call = self.hub.accounts().update(request, id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -353,6 +384,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -396,6 +430,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -439,6 +476,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -455,8 +495,48 @@ impl Engine { fn _budget_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Budget::default(); - let mut call = self.hub.budget().patch(&request, &self.opt.arg_account_id, &self.opt.arg_billing_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "budget-amount" => { + request.budget_amount = Some(value.unwrap_or("").to_string()); + }, + "currency-code" => { + request.currency_code = Some(value.unwrap_or("").to_string()); + }, + "billing-id" => { + request.billing_id = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request.account_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.budget().patch(request, &self.opt.arg_account_id, &self.opt.arg_billing_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -478,42 +558,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "budget-amount" => { - request.budget_amount = Some(value.unwrap_or("").to_string()); - }, - "currency-code" => { - request.currency_code = Some(value.unwrap_or("").to_string()); - }, - "billing-id" => { - request.billing_id = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request.account_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -530,8 +582,48 @@ impl Engine { fn _budget_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Budget::default(); - let mut call = self.hub.budget().update(&request, &self.opt.arg_account_id, &self.opt.arg_billing_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "budget-amount" => { + request.budget_amount = Some(value.unwrap_or("").to_string()); + }, + "currency-code" => { + request.currency_code = Some(value.unwrap_or("").to_string()); + }, + "billing-id" => { + request.billing_id = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request.account_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.budget().update(request, &self.opt.arg_account_id, &self.opt.arg_billing_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -553,42 +645,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "budget-amount" => { - request.budget_amount = Some(value.unwrap_or("").to_string()); - }, - "currency-code" => { - request.currency_code = Some(value.unwrap_or("").to_string()); - }, - "billing-id" => { - request.billing_id = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request.account_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -633,6 +697,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -649,43 +716,30 @@ impl Engine { fn _creatives_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Creative::default(); - let mut call = self.hub.creatives().insert(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Creative::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_filtering_reasons_init(request: &mut api::Creative) { if request.filtering_reasons.is_none() { request.filtering_reasons = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "product-categories" => { if request.product_categories.is_none() { request.product_categories = Some(Default::default()); @@ -765,15 +819,40 @@ impl Engine { request.account_id = Some(arg_from_str(value.unwrap_or("-0"), err, "account-id", "integer")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.creatives().insert(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -832,6 +911,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -875,6 +957,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -918,6 +1003,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -967,6 +1055,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1010,6 +1101,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1051,6 +1145,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1067,37 +1164,24 @@ impl Engine { fn _pretargeting_config_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::PretargetingConfig::default(); - let mut call = self.hub.pretargeting_config().insert(&request, &self.opt.arg_account_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::PretargetingConfig::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "billing-id" => { request.billing_id = Some(value.unwrap_or("").to_string()); }, @@ -1204,15 +1288,40 @@ impl Engine { request.supported_creative_attributes.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.pretargeting_config().insert(request, &self.opt.arg_account_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1256,6 +1365,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1272,37 +1384,24 @@ impl Engine { fn _pretargeting_config_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::PretargetingConfig::default(); - let mut call = self.hub.pretargeting_config().patch(&request, &self.opt.arg_account_id, &self.opt.arg_config_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::PretargetingConfig::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "billing-id" => { request.billing_id = Some(value.unwrap_or("").to_string()); }, @@ -1409,15 +1508,40 @@ impl Engine { request.supported_creative_attributes.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.pretargeting_config().patch(request, &self.opt.arg_account_id, &self.opt.arg_config_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1434,37 +1558,24 @@ impl Engine { fn _pretargeting_config_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::PretargetingConfig::default(); - let mut call = self.hub.pretargeting_config().update(&request, &self.opt.arg_account_id, &self.opt.arg_config_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::PretargetingConfig::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "billing-id" => { request.billing_id = Some(value.unwrap_or("").to_string()); }, @@ -1571,15 +1682,40 @@ impl Engine { request.supported_creative_attributes.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.pretargeting_config().update(request, &self.opt.arg_account_id, &self.opt.arg_config_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1743,6 +1879,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -1750,8 +1887,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/adexchangebuyer1d3/Cargo.toml b/gen/adexchangebuyer1d3/Cargo.toml index 723a218acd..3ca84be0e2 100644 --- a/gen/adexchangebuyer1d3/Cargo.toml +++ b/gen/adexchangebuyer1d3/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-adexchangebuyer1d3" -version = "0.1.5+20150326" +version = "0.1.6+20150326" authors = ["Sebastian Thiel "] description = "A complete library to interact with Ad Exchange Buyer (protocol v1.3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/adexchangebuyer1d3" diff --git a/gen/adexchangebuyer1d3/README.md b/gen/adexchangebuyer1d3/README.md index 10cc0b9bf1..9020cd6ad7 100644 --- a/gen/adexchangebuyer1d3/README.md +++ b/gen/adexchangebuyer1d3/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-adexchangebuyer1d3` library allows access to all features of the *Google Ad Exchange Buyer* service. -This documentation was generated from *Ad Exchange Buyer* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *adexchangebuyer:v1.3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *Ad Exchange Buyer* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *adexchangebuyer:v1.3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *Ad Exchange Buyer* *v1d3* API can be found at the [official documentation site](https://developers.google.com/ad-exchange/buyer-rest). @@ -113,21 +113,22 @@ let mut req = PretargetingConfig::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.pretargeting_config().patch(&req, "accountId", "configId") +let result = hub.pretargeting_config().patch(req, "accountId", "configId") .doit(); match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/adexchangebuyer1d3/src/cmn.rs b/gen/adexchangebuyer1d3/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/adexchangebuyer1d3/src/cmn.rs +++ b/gen/adexchangebuyer1d3/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option, + location: Option +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option, _: Option) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec]) -> Option { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/adexchangebuyer1d3/src/lib.rs b/gen/adexchangebuyer1d3/src/lib.rs index 8ef6652864..ad75d34616 100644 --- a/gen/adexchangebuyer1d3/src/lib.rs +++ b/gen/adexchangebuyer1d3/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Ad Exchange Buyer* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *adexchangebuyer:v1.3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *Ad Exchange Buyer* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *adexchangebuyer:v1.3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *Ad Exchange Buyer* *v1d3* API can be found at the //! [official documentation site](https://developers.google.com/ad-exchange/buyer-rest). @@ -114,21 +114,22 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.pretargeting_config().patch(&req, "accountId", "configId") +//! let result = hub.pretargeting_config().patch(req, "accountId", "configId") //! .doit(); //! //! match result { //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -216,7 +217,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -289,21 +290,22 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.pretargeting_config().patch(&req, "accountId", "configId") +/// let result = hub.pretargeting_config().patch(req, "accountId", "configId") /// .doit(); /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -324,7 +326,7 @@ impl<'a, C, A> AdExchangeBuyer AdExchangeBuyer { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -351,7 +353,7 @@ impl<'a, C, A> AdExchangeBuyer } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -1189,10 +1191,10 @@ impl<'a, C, A> BudgetMethods<'a, C, A> { /// * `request` - No description provided. /// * `accountId` - The account id associated with the budget being updated. /// * `billingId` - The billing id associated with the budget being updated. - pub fn patch(&self, request: &Budget, account_id: &str, billing_id: &str) -> BudgetPatchCall<'a, C, A> { + pub fn patch(&self, request: Budget, account_id: &str, billing_id: &str) -> BudgetPatchCall<'a, C, A> { BudgetPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _billing_id: billing_id.to_string(), _delegate: Default::default(), @@ -1210,10 +1212,10 @@ impl<'a, C, A> BudgetMethods<'a, C, A> { /// * `request` - No description provided. /// * `accountId` - The account id associated with the budget being updated. /// * `billingId` - The billing id associated with the budget being updated. - pub fn update(&self, request: &Budget, account_id: &str, billing_id: &str) -> BudgetUpdateCall<'a, C, A> { + pub fn update(&self, request: Budget, account_id: &str, billing_id: &str) -> BudgetUpdateCall<'a, C, A> { BudgetUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _billing_id: billing_id.to_string(), _delegate: Default::default(), @@ -1289,10 +1291,10 @@ impl<'a, C, A> CreativeMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &Creative) -> CreativeInsertCall<'a, C, A> { + pub fn insert(&self, request: Creative) -> CreativeInsertCall<'a, C, A> { CreativeInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1384,10 +1386,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The account id - pub fn update(&self, request: &Account, id: i32) -> AccountUpdateCall<'a, C, A> { + pub fn update(&self, request: Account, id: i32) -> AccountUpdateCall<'a, C, A> { AccountUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id, _delegate: Default::default(), _scopes: Default::default(), @@ -1403,10 +1405,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The account id - pub fn patch(&self, request: &Account, id: i32) -> AccountPatchCall<'a, C, A> { + pub fn patch(&self, request: Account, id: i32) -> AccountPatchCall<'a, C, A> { AccountPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id, _delegate: Default::default(), _scopes: Default::default(), @@ -1576,10 +1578,10 @@ impl<'a, C, A> PretargetingConfigMethods<'a, C, A> { /// * `request` - No description provided. /// * `accountId` - The account id to update the pretargeting config for. /// * `configId` - The specific id of the configuration to update. - pub fn patch(&self, request: &PretargetingConfig, account_id: &str, config_id: &str) -> PretargetingConfigPatchCall<'a, C, A> { + pub fn patch(&self, request: PretargetingConfig, account_id: &str, config_id: &str) -> PretargetingConfigPatchCall<'a, C, A> { PretargetingConfigPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _config_id: config_id.to_string(), _delegate: Default::default(), @@ -1615,10 +1617,10 @@ impl<'a, C, A> PretargetingConfigMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `accountId` - The account id to insert the pretargeting config for. - pub fn insert(&self, request: &PretargetingConfig, account_id: &str) -> PretargetingConfigInsertCall<'a, C, A> { + pub fn insert(&self, request: PretargetingConfig, account_id: &str) -> PretargetingConfigInsertCall<'a, C, A> { PretargetingConfigInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1652,10 +1654,10 @@ impl<'a, C, A> PretargetingConfigMethods<'a, C, A> { /// * `request` - No description provided. /// * `accountId` - The account id to update the pretargeting config for. /// * `configId` - The specific id of the configuration to update. - pub fn update(&self, request: &PretargetingConfig, account_id: &str, config_id: &str) -> PretargetingConfigUpdateCall<'a, C, A> { + pub fn update(&self, request: PretargetingConfig, account_id: &str, config_id: &str) -> PretargetingConfigUpdateCall<'a, C, A> { PretargetingConfigUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _config_id: config_id.to_string(), _delegate: Default::default(), @@ -1818,12 +1820,17 @@ impl<'a, C, A> BillingInfoGetCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1832,7 +1839,7 @@ impl<'a, C, A> BillingInfoGetCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2026,12 +2033,17 @@ impl<'a, C, A> BillingInfoListCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2040,7 +2052,7 @@ impl<'a, C, A> BillingInfoListCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2224,12 +2236,17 @@ impl<'a, C, A> DirectDealListCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2238,7 +2255,7 @@ impl<'a, C, A> DirectDealListCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2448,12 +2465,17 @@ impl<'a, C, A> DirectDealGetCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2462,7 +2484,7 @@ impl<'a, C, A> DirectDealGetCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2569,7 +2591,7 @@ impl<'a, C, A> DirectDealGetCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.budget().patch(&req, "accountId", "billingId") +/// let result = hub.budget().patch(req, "accountId", "billingId") /// .doit(); /// # } /// ``` @@ -2699,12 +2721,17 @@ impl<'a, C, A> BudgetPatchCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2713,7 +2740,7 @@ impl<'a, C, A> BudgetPatchCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2731,8 +2758,8 @@ impl<'a, C, A> BudgetPatchCall<'a, C, A> where C: BorrowMut, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Budget) -> BudgetPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Budget) -> BudgetPatchCall<'a, C, A> { + self._request = new_value; self } /// The account id associated with the budget being updated. @@ -2839,7 +2866,7 @@ impl<'a, C, A> BudgetPatchCall<'a, C, A> where C: BorrowMut, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.budget().update(&req, "accountId", "billingId") +/// let result = hub.budget().update(req, "accountId", "billingId") /// .doit(); /// # } /// ``` @@ -2969,12 +2996,17 @@ impl<'a, C, A> BudgetUpdateCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2983,7 +3015,7 @@ impl<'a, C, A> BudgetUpdateCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3001,8 +3033,8 @@ impl<'a, C, A> BudgetUpdateCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Budget) -> BudgetUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Budget) -> BudgetUpdateCall<'a, C, A> { + self._request = new_value; self } /// The account id associated with the budget being updated. @@ -3224,12 +3256,17 @@ impl<'a, C, A> BudgetGetCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3238,7 +3275,7 @@ impl<'a, C, A> BudgetGetCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3355,7 +3392,7 @@ impl<'a, C, A> BudgetGetCall<'a, C, A> where C: BorrowMut, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.creatives().insert(&req) +/// let result = hub.creatives().insert(req) /// .doit(); /// # } /// ``` @@ -3457,12 +3494,17 @@ impl<'a, C, A> CreativeInsertCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3471,7 +3513,7 @@ impl<'a, C, A> CreativeInsertCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3489,8 +3531,8 @@ impl<'a, C, A> CreativeInsertCall<'a, C, A> where C: BorrowMut, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Creative) -> CreativeInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Creative) -> CreativeInsertCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -3697,12 +3739,17 @@ impl<'a, C, A> CreativeListCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3711,7 +3758,7 @@ impl<'a, C, A> CreativeListCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3960,12 +4007,17 @@ impl<'a, C, A> CreativeGetCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3974,7 +4026,7 @@ impl<'a, C, A> CreativeGetCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4091,7 +4143,7 @@ impl<'a, C, A> CreativeGetCall<'a, C, A> where C: BorrowMut, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().update(&req, -21) +/// let result = hub.accounts().update(req, -21) /// .doit(); /// # } /// ``` @@ -4219,12 +4271,17 @@ impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4233,7 +4290,7 @@ impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4251,8 +4308,8 @@ impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Account) -> AccountUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Account) -> AccountUpdateCall<'a, C, A> { + self._request = new_value; self } /// The account id @@ -4349,7 +4406,7 @@ impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().patch(&req, -21) +/// let result = hub.accounts().patch(req, -21) /// .doit(); /// # } /// ``` @@ -4477,12 +4534,17 @@ impl<'a, C, A> AccountPatchCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4491,7 +4553,7 @@ impl<'a, C, A> AccountPatchCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4509,8 +4571,8 @@ impl<'a, C, A> AccountPatchCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Account) -> AccountPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Account) -> AccountPatchCall<'a, C, A> { + self._request = new_value; self } /// The account id @@ -4694,12 +4756,17 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4708,7 +4775,7 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4918,12 +4985,17 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4932,7 +5004,7 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5142,12 +5214,17 @@ impl<'a, C, A> PerformanceReportListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5156,7 +5233,7 @@ impl<'a, C, A> PerformanceReportListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5411,12 +5488,17 @@ impl<'a, C, A> PretargetingConfigDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -5532,7 +5614,7 @@ impl<'a, C, A> PretargetingConfigDeleteCall<'a, C, A> where C: BorrowMut PretargetingConfigPatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5676,7 +5763,7 @@ impl<'a, C, A> PretargetingConfigPatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5694,8 +5781,8 @@ impl<'a, C, A> PretargetingConfigPatchCall<'a, C, A> where C: BorrowMut PretargetingConfigPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PretargetingConfig) -> PretargetingConfigPatchCall<'a, C, A> { + self._request = new_value; self } /// The account id to update the pretargeting config for. @@ -5917,12 +6004,17 @@ impl<'a, C, A> PretargetingConfigGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5931,7 +6023,7 @@ impl<'a, C, A> PretargetingConfigGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6048,7 +6140,7 @@ impl<'a, C, A> PretargetingConfigGetCall<'a, C, A> where C: BorrowMut PretargetingConfigInsertCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6190,7 +6287,7 @@ impl<'a, C, A> PretargetingConfigInsertCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6208,8 +6305,8 @@ impl<'a, C, A> PretargetingConfigInsertCall<'a, C, A> where C: BorrowMut PretargetingConfigInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PretargetingConfig) -> PretargetingConfigInsertCall<'a, C, A> { + self._request = new_value; self } /// The account id to insert the pretargeting config for. @@ -6419,12 +6516,17 @@ impl<'a, C, A> PretargetingConfigListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6433,7 +6535,7 @@ impl<'a, C, A> PretargetingConfigListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6540,7 +6642,7 @@ impl<'a, C, A> PretargetingConfigListCall<'a, C, A> where C: BorrowMut PretargetingConfigUpdateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6684,7 +6791,7 @@ impl<'a, C, A> PretargetingConfigUpdateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6702,8 +6809,8 @@ impl<'a, C, A> PretargetingConfigUpdateCall<'a, C, A> where C: BorrowMut PretargetingConfigUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PretargetingConfig) -> PretargetingConfigUpdateCall<'a, C, A> { + self._request = new_value; self } /// The account id to update the pretargeting config for. diff --git a/gen/adexchangeseller2-cli/Cargo.toml b/gen/adexchangeseller2-cli/Cargo.toml index 7dcf38dbb0..d54ea2a37b 100644 --- a/gen/adexchangeseller2-cli/Cargo.toml +++ b/gen/adexchangeseller2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-adexchangeseller2-cli" -version = "0.0.1+20150326" +version = "0.1.0+20150326" authors = ["Sebastian Thiel "] description = "A complete library to interact with Ad Exchange Seller (protocol v2.0)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/adexchangeseller2-cli" diff --git a/gen/adexchangeseller2-cli/README.md b/gen/adexchangeseller2-cli/README.md index 778ac3ab91..92d8de921e 100644 --- a/gen/adexchangeseller2-cli/README.md +++ b/gen/adexchangeseller2-cli/README.md @@ -1,4 +1,115 @@ -# HELLO ADEXCHANGESELLER:V2.0 + +The `adexchangeseller2` command-line interface *(CLI)* allows to use most features of the *Google Ad Exchange Seller* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *Ad Exchange Seller* API at revision *20150326*. The CLI is at version *0.1.0*. + +```bash + adexchangeseller2 [options] accounts adclients-list [-p ...] [-o ] + adexchangeseller2 [options] accounts alerts-list [-p ...] [-o ] + adexchangeseller2 [options] accounts customchannels-get [-p ...] [-o ] + adexchangeseller2 [options] accounts customchannels-list [-p ...] [-o ] + adexchangeseller2 [options] accounts get [-p ...] [-o ] + adexchangeseller2 [options] accounts list [-p ...] [-o ] + adexchangeseller2 [options] accounts metadata-dimensions-list [-p ...] [-o ] + adexchangeseller2 [options] accounts metadata-metrics-list [-p ...] [-o ] + adexchangeseller2 [options] accounts preferreddeals-get [-p ...] [-o ] + adexchangeseller2 [options] accounts preferreddeals-list [-p ...] [-o ] + adexchangeseller2 [options] accounts reports-generate [-p ...] [-o ] + adexchangeseller2 [options] accounts reports-saved-generate [-p ...] [-o ] + adexchangeseller2 [options] accounts reports-saved-list [-p ...] [-o ] + adexchangeseller2 [options] accounts urlchannels-list [-p ...] [-o ] + adexchangeseller2 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_adexchangeseller2_cli/index.html + +Configuration: + --scope + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `adexchangeseller2-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/adexchangeseller2-token-.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/adexchangeseller2-secret.json`, assuming that the required *adexchangeseller* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `adexchangeseller2 --debug [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/adexchangeseller2-cli/mkdocs.yml b/gen/adexchangeseller2-cli/mkdocs.yml index b75cd6d9dc..000951f148 100644 --- a/gen/adexchangeseller2-cli/mkdocs.yml +++ b/gen/adexchangeseller2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Ad Exchange Seller v0.0.1+20150326 +site_name: Ad Exchange Seller v0.1.0+20150326 site_url: http://byron.github.io/google-apis-rs/google-adexchangeseller2-cli site_description: Write integrating applications with bcore diff --git a/gen/adexchangeseller2-cli/src/cmn.rs b/gen/adexchangeseller2-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/adexchangeseller2-cli/src/cmn.rs +++ b/gen/adexchangeseller2-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/adexchangeseller2-cli/src/main.rs b/gen/adexchangeseller2-cli/src/main.rs index 673318ec92..a626f93310 100644 --- a/gen/adexchangeseller2-cli/src/main.rs +++ b/gen/adexchangeseller2-cli/src/main.rs @@ -19,39 +19,40 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - adexchangeseller2 [options] accounts adclients-list [-p ]... [-o ] - adexchangeseller2 [options] accounts alerts-list [-p ]... [-o ] - adexchangeseller2 [options] accounts customchannels-get [-p ]... [-o ] - adexchangeseller2 [options] accounts customchannels-list [-p ]... [-o ] - adexchangeseller2 [options] accounts get [-p ]... [-o ] - adexchangeseller2 [options] accounts list [-p ]... [-o ] - adexchangeseller2 [options] accounts metadata-dimensions-list [-p ]... [-o ] - adexchangeseller2 [options] accounts metadata-metrics-list [-p ]... [-o ] - adexchangeseller2 [options] accounts preferreddeals-get [-p ]... [-o ] - adexchangeseller2 [options] accounts preferreddeals-list [-p ]... [-o ] - adexchangeseller2 [options] accounts reports-generate [-p ]... [-o ] - adexchangeseller2 [options] accounts reports-saved-generate [-p ]... [-o ] - adexchangeseller2 [options] accounts reports-saved-list [-p ]... [-o ] - adexchangeseller2 [options] accounts urlchannels-list [-p ]... [-o ] + adexchangeseller2 [options] accounts adclients-list [-p ...] [-o ] + adexchangeseller2 [options] accounts alerts-list [-p ...] [-o ] + adexchangeseller2 [options] accounts customchannels-get [-p ...] [-o ] + adexchangeseller2 [options] accounts customchannels-list [-p ...] [-o ] + adexchangeseller2 [options] accounts get [-p ...] [-o ] + adexchangeseller2 [options] accounts list [-p ...] [-o ] + adexchangeseller2 [options] accounts metadata-dimensions-list [-p ...] [-o ] + adexchangeseller2 [options] accounts metadata-metrics-list [-p ...] [-o ] + adexchangeseller2 [options] accounts preferreddeals-get [-p ...] [-o ] + adexchangeseller2 [options] accounts preferreddeals-list [-p ...] [-o ] + adexchangeseller2 [options] accounts reports-generate [-p ...] [-o ] + adexchangeseller2 [options] accounts reports-saved-generate [-p ...] [-o ] + adexchangeseller2 [options] accounts reports-saved-list [-p ...] [-o ] + adexchangeseller2 [options] accounts urlchannels-list [-p ...] [-o ] adexchangeseller2 --help -All documentation details can be found TODO: +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_adexchangeseller2_cli/index.html Configuration: --scope - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -106,6 +107,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -152,6 +156,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -195,6 +202,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -244,6 +254,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -287,6 +300,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -336,6 +352,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -379,6 +398,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -422,6 +444,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -465,6 +490,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -508,6 +536,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -576,6 +607,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -632,6 +666,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -681,6 +718,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -730,6 +770,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -849,6 +892,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -856,8 +900,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/adexchangeseller2/Cargo.toml b/gen/adexchangeseller2/Cargo.toml index 42ecaeed11..af525c4d1a 100644 --- a/gen/adexchangeseller2/Cargo.toml +++ b/gen/adexchangeseller2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-adexchangeseller2" -version = "0.1.5+20150326" +version = "0.1.6+20150326" authors = ["Sebastian Thiel "] description = "A complete library to interact with Ad Exchange Seller (protocol v2.0)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/adexchangeseller2" diff --git a/gen/adexchangeseller2/README.md b/gen/adexchangeseller2/README.md index d4546807b1..816a6f3d73 100644 --- a/gen/adexchangeseller2/README.md +++ b/gen/adexchangeseller2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-adexchangeseller2` library allows access to all features of the *Google Ad Exchange Seller* service. -This documentation was generated from *Ad Exchange Seller* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *adexchangeseller:v2.0* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *Ad Exchange Seller* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *adexchangeseller:v2.0* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *Ad Exchange Seller* *v2* API can be found at the [official documentation site](https://developers.google.com/ad-exchange/seller-rest/). @@ -123,14 +123,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/adexchangeseller2/src/cmn.rs b/gen/adexchangeseller2/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/adexchangeseller2/src/cmn.rs +++ b/gen/adexchangeseller2/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option, + location: Option +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option, _: Option) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec]) -> Option { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/adexchangeseller2/src/lib.rs b/gen/adexchangeseller2/src/lib.rs index a8ab98234c..5ee3654bdb 100644 --- a/gen/adexchangeseller2/src/lib.rs +++ b/gen/adexchangeseller2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Ad Exchange Seller* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *adexchangeseller:v2.0* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *Ad Exchange Seller* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *adexchangeseller:v2.0* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *Ad Exchange Seller* *v2* API can be found at the //! [official documentation site](https://developers.google.com/ad-exchange/seller-rest/). @@ -124,14 +124,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -219,7 +220,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -304,14 +305,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -332,7 +334,7 @@ impl<'a, C, A> AdExchangeSeller AdExchangeSeller { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -341,7 +343,7 @@ impl<'a, C, A> AdExchangeSeller } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -1310,12 +1312,17 @@ impl<'a, C, A> AccountReportSavedGenerateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1324,7 +1331,7 @@ impl<'a, C, A> AccountReportSavedGenerateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1575,12 +1582,17 @@ impl<'a, C, A> AccountMetadataMetricListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1589,7 +1601,7 @@ impl<'a, C, A> AccountMetadataMetricListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1885,12 +1897,17 @@ impl<'a, C, A> AccountReportGenerateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = if enable_resource_parsing { let mut json_response = String::new(); @@ -1899,7 +1916,7 @@ impl<'a, C, A> AccountReportGenerateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } } else { (res, Default::default()) }; @@ -2204,12 +2221,17 @@ impl<'a, C, A> AccountUrlchannelListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2218,7 +2240,7 @@ impl<'a, C, A> AccountUrlchannelListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2472,12 +2494,17 @@ impl<'a, C, A> AccountReportSavedListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2486,7 +2513,7 @@ impl<'a, C, A> AccountReportSavedListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2722,12 +2749,17 @@ impl<'a, C, A> AccountPreferreddealGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2736,7 +2768,7 @@ impl<'a, C, A> AccountPreferreddealGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2976,12 +3008,17 @@ impl<'a, C, A> AccountAdclientListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2990,7 +3027,7 @@ impl<'a, C, A> AccountAdclientListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3224,12 +3261,17 @@ impl<'a, C, A> AccountMetadataDimensionListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3238,7 +3280,7 @@ impl<'a, C, A> AccountMetadataDimensionListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3462,12 +3504,17 @@ impl<'a, C, A> AccountCustomchannelGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3476,7 +3523,7 @@ impl<'a, C, A> AccountCustomchannelGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3728,12 +3775,17 @@ impl<'a, C, A> AccountCustomchannelListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3742,7 +3794,7 @@ impl<'a, C, A> AccountCustomchannelListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3970,12 +4022,17 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3984,7 +4041,7 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4213,12 +4270,17 @@ impl<'a, C, A> AccountAlertListCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4227,7 +4289,7 @@ impl<'a, C, A> AccountAlertListCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4454,12 +4516,17 @@ impl<'a, C, A> AccountPreferreddealListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4468,7 +4535,7 @@ impl<'a, C, A> AccountPreferreddealListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4688,12 +4755,17 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4702,7 +4774,7 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/admin1_directory-cli/Cargo.toml b/gen/admin1_directory-cli/Cargo.toml index 57cc1748f2..5bb1fd967f 100644 --- a/gen/admin1_directory-cli/Cargo.toml +++ b/gen/admin1_directory-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-admin1_directory-cli" -version = "0.0.1+20150314" +version = "0.1.0+20150314" authors = ["Sebastian Thiel "] description = "A complete library to interact with directory (protocol directory_v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/admin1_directory-cli" diff --git a/gen/admin1_directory-cli/README.md b/gen/admin1_directory-cli/README.md index ee5759b0f6..d6db5c8114 100644 --- a/gen/admin1_directory-cli/README.md +++ b/gen/admin1_directory-cli/README.md @@ -1,4 +1,168 @@ -# HELLO ADMIN:DIRECTORY_V1 + +The `admin1-directory` command-line interface *(CLI)* allows to use most features of the *Google directory* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *directory* API at revision *20150314*. The CLI is at version *0.1.0*. + +```bash + admin1-directory [options] asps delete [-p ...] + admin1-directory [options] asps get [-p ...] [-o ] + admin1-directory [options] asps list [-p ...] [-o ] + admin1-directory [options] channels stop -r ... [-p ...] + admin1-directory [options] chromeosdevices get [-p ...] [-o ] + admin1-directory [options] chromeosdevices list [-p ...] [-o ] + admin1-directory [options] chromeosdevices patch -r ... [-p ...] [-o ] + admin1-directory [options] chromeosdevices update -r ... [-p ...] [-o ] + admin1-directory [options] groups aliases-delete [-p ...] + admin1-directory [options] groups aliases-insert -r ... [-p ...] [-o ] + admin1-directory [options] groups aliases-list [-p ...] [-o ] + admin1-directory [options] groups delete [-p ...] + admin1-directory [options] groups get [-p ...] [-o ] + admin1-directory [options] groups insert -r ... [-p ...] [-o ] + admin1-directory [options] groups list [-p ...] [-o ] + admin1-directory [options] groups patch -r ... [-p ...] [-o ] + admin1-directory [options] groups update -r ... [-p ...] [-o ] + admin1-directory [options] members delete [-p ...] + admin1-directory [options] members get [-p ...] [-o ] + admin1-directory [options] members insert -r ... [-p ...] [-o ] + admin1-directory [options] members list [-p ...] [-o ] + admin1-directory [options] members patch -r ... [-p ...] [-o ] + admin1-directory [options] members update -r ... [-p ...] [-o ] + admin1-directory [options] mobiledevices action -r ... [-p ...] + admin1-directory [options] mobiledevices delete [-p ...] + admin1-directory [options] mobiledevices get [-p ...] [-o ] + admin1-directory [options] mobiledevices list [-p ...] [-o ] + admin1-directory [options] notifications delete [-p ...] + admin1-directory [options] notifications get [-p ...] [-o ] + admin1-directory [options] notifications list [-p ...] [-o ] + admin1-directory [options] notifications patch -r ... [-p ...] [-o ] + admin1-directory [options] notifications update -r ... [-p ...] [-o ] + admin1-directory [options] orgunits delete ... [-p ...] + admin1-directory [options] orgunits get ... [-p ...] [-o ] + admin1-directory [options] orgunits insert -r ... [-p ...] [-o ] + admin1-directory [options] orgunits list [-p ...] [-o ] + admin1-directory [options] orgunits patch ... -r ... [-p ...] [-o ] + admin1-directory [options] orgunits update ... -r ... [-p ...] [-o ] + admin1-directory [options] schemas delete [-p ...] + admin1-directory [options] schemas get [-p ...] [-o ] + admin1-directory [options] schemas insert -r ... [-p ...] [-o ] + admin1-directory [options] schemas list [-p ...] [-o ] + admin1-directory [options] schemas patch -r ... [-p ...] [-o ] + admin1-directory [options] schemas update -r ... [-p ...] [-o ] + admin1-directory [options] tokens delete [-p ...] + admin1-directory [options] tokens get [-p ...] [-o ] + admin1-directory [options] tokens list [-p ...] [-o ] + admin1-directory [options] users aliases-delete [-p ...] + admin1-directory [options] users aliases-insert -r ... [-p ...] [-o ] + admin1-directory [options] users aliases-list [-p ...] [-o ] + admin1-directory [options] users aliases-watch -r ... [-p ...] [-o ] + admin1-directory [options] users delete [-p ...] + admin1-directory [options] users get [-p ...] [-o ] + admin1-directory [options] users insert -r ... [-p ...] [-o ] + admin1-directory [options] users list [-p ...] [-o ] + admin1-directory [options] users make-admin -r ... [-p ...] + admin1-directory [options] users patch -r ... [-p ...] [-o ] + admin1-directory [options] users photos-delete [-p ...] + admin1-directory [options] users photos-get [-p ...] [-o ] + admin1-directory [options] users photos-patch -r ... [-p ...] [-o ] + admin1-directory [options] users photos-update -r ... [-p ...] [-o ] + admin1-directory [options] users undelete -r ... [-p ...] + admin1-directory [options] users update -r ... [-p ...] [-o ] + admin1-directory [options] users watch -r ... [-p ...] [-o ] + admin1-directory [options] verification-codes generate [-p ...] + admin1-directory [options] verification-codes invalidate [-p ...] + admin1-directory [options] verification-codes list [-p ...] [-o ] + admin1-directory --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_admin1_directory_cli/index.html + +Configuration: + --scope + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `admin1-directory-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/admin1-directory-token-.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/admin1-directory-secret.json`, assuming that the required *admin* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `admin1-directory --debug [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/admin1_directory-cli/mkdocs.yml b/gen/admin1_directory-cli/mkdocs.yml index c4580b01e3..3ec3f9cd3a 100644 --- a/gen/admin1_directory-cli/mkdocs.yml +++ b/gen/admin1_directory-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: directory v0.0.1+20150314 +site_name: directory v0.1.0+20150314 site_url: http://byron.github.io/google-apis-rs/google-admin1_directory-cli site_description: Write integrating applications with bcore diff --git a/gen/admin1_directory-cli/src/cmn.rs b/gen/admin1_directory-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/admin1_directory-cli/src/cmn.rs +++ b/gen/admin1_directory-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/admin1_directory-cli/src/main.rs b/gen/admin1_directory-cli/src/main.rs index 3e68426ece..97cd9500ca 100644 --- a/gen/admin1_directory-cli/src/main.rs +++ b/gen/admin1_directory-cli/src/main.rs @@ -19,92 +19,93 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - admin1-directory [options] asps delete [-p ]... - admin1-directory [options] asps get [-p ]... [-o ] - admin1-directory [options] asps list [-p ]... [-o ] - admin1-directory [options] channels stop -r ... [-p ]... - admin1-directory [options] chromeosdevices get [-p ]... [-o ] - admin1-directory [options] chromeosdevices list [-p ]... [-o ] - admin1-directory [options] chromeosdevices patch -r ... [-p ]... [-o ] - admin1-directory [options] chromeosdevices update -r ... [-p ]... [-o ] - admin1-directory [options] groups aliases-delete [-p ]... - admin1-directory [options] groups aliases-insert -r ... [-p ]... [-o ] - admin1-directory [options] groups aliases-list [-p ]... [-o ] - admin1-directory [options] groups delete [-p ]... - admin1-directory [options] groups get [-p ]... [-o ] - admin1-directory [options] groups insert -r ... [-p ]... [-o ] - admin1-directory [options] groups list [-p ]... [-o ] - admin1-directory [options] groups patch -r ... [-p ]... [-o ] - admin1-directory [options] groups update -r ... [-p ]... [-o ] - admin1-directory [options] members delete [-p ]... - admin1-directory [options] members get [-p ]... [-o ] - admin1-directory [options] members insert -r ... [-p ]... [-o ] - admin1-directory [options] members list [-p ]... [-o ] - admin1-directory [options] members patch -r ... [-p ]... [-o ] - admin1-directory [options] members update -r ... [-p ]... [-o ] - admin1-directory [options] mobiledevices action -r ... [-p ]... - admin1-directory [options] mobiledevices delete [-p ]... - admin1-directory [options] mobiledevices get [-p ]... [-o ] - admin1-directory [options] mobiledevices list [-p ]... [-o ] - admin1-directory [options] notifications delete [-p ]... - admin1-directory [options] notifications get [-p ]... [-o ] - admin1-directory [options] notifications list [-p ]... [-o ] - admin1-directory [options] notifications patch -r ... [-p ]... [-o ] - admin1-directory [options] notifications update -r ... [-p ]... [-o ] - admin1-directory [options] orgunits delete ... [-p ]... - admin1-directory [options] orgunits get ... [-p ]... [-o ] - admin1-directory [options] orgunits insert -r ... [-p ]... [-o ] - admin1-directory [options] orgunits list [-p ]... [-o ] - admin1-directory [options] orgunits patch ... -r ... [-p ]... [-o ] - admin1-directory [options] orgunits update ... -r ... [-p ]... [-o ] - admin1-directory [options] schemas delete [-p ]... - admin1-directory [options] schemas get [-p ]... [-o ] - admin1-directory [options] schemas insert -r ... [-p ]... [-o ] - admin1-directory [options] schemas list [-p ]... [-o ] - admin1-directory [options] schemas patch -r ... [-p ]... [-o ] - admin1-directory [options] schemas update -r ... [-p ]... [-o ] - admin1-directory [options] tokens delete [-p ]... - admin1-directory [options] tokens get [-p ]... [-o ] - admin1-directory [options] tokens list [-p ]... [-o ] - admin1-directory [options] users aliases-delete [-p ]... - admin1-directory [options] users aliases-insert -r ... [-p ]... [-o ] - admin1-directory [options] users aliases-list [-p ]... [-o ] - admin1-directory [options] users aliases-watch -r ... [-p ]... [-o ] - admin1-directory [options] users delete [-p ]... - admin1-directory [options] users get [-p ]... [-o ] - admin1-directory [options] users insert -r ... [-p ]... [-o ] - admin1-directory [options] users list [-p ]... [-o ] - admin1-directory [options] users make-admin -r ... [-p ]... - admin1-directory [options] users patch -r ... [-p ]... [-o ] - admin1-directory [options] users photos-delete [-p ]... - admin1-directory [options] users photos-get [-p ]... [-o ] - admin1-directory [options] users photos-patch -r ... [-p ]... [-o ] - admin1-directory [options] users photos-update -r ... [-p ]... [-o ] - admin1-directory [options] users undelete -r ... [-p ]... - admin1-directory [options] users update -r ... [-p ]... [-o ] - admin1-directory [options] users watch -r ... [-p ]... [-o ] - admin1-directory [options] verification-codes generate [-p ]... - admin1-directory [options] verification-codes invalidate [-p ]... - admin1-directory [options] verification-codes list [-p ]... [-o ] + admin1-directory [options] asps delete [-p ...] + admin1-directory [options] asps get [-p ...] [-o ] + admin1-directory [options] asps list [-p ...] [-o ] + admin1-directory [options] channels stop -r ... [-p ...] + admin1-directory [options] chromeosdevices get [-p ...] [-o ] + admin1-directory [options] chromeosdevices list [-p ...] [-o ] + admin1-directory [options] chromeosdevices patch -r ... [-p ...] [-o ] + admin1-directory [options] chromeosdevices update -r ... [-p ...] [-o ] + admin1-directory [options] groups aliases-delete [-p ...] + admin1-directory [options] groups aliases-insert -r ... [-p ...] [-o ] + admin1-directory [options] groups aliases-list [-p ...] [-o ] + admin1-directory [options] groups delete [-p ...] + admin1-directory [options] groups get [-p ...] [-o ] + admin1-directory [options] groups insert -r ... [-p ...] [-o ] + admin1-directory [options] groups list [-p ...] [-o ] + admin1-directory [options] groups patch -r ... [-p ...] [-o ] + admin1-directory [options] groups update -r ... [-p ...] [-o ] + admin1-directory [options] members delete [-p ...] + admin1-directory [options] members get [-p ...] [-o ] + admin1-directory [options] members insert -r ... [-p ...] [-o ] + admin1-directory [options] members list [-p ...] [-o ] + admin1-directory [options] members patch -r ... [-p ...] [-o ] + admin1-directory [options] members update -r ... [-p ...] [-o ] + admin1-directory [options] mobiledevices action -r ... [-p ...] + admin1-directory [options] mobiledevices delete [-p ...] + admin1-directory [options] mobiledevices get [-p ...] [-o ] + admin1-directory [options] mobiledevices list [-p ...] [-o ] + admin1-directory [options] notifications delete [-p ...] + admin1-directory [options] notifications get [-p ...] [-o ] + admin1-directory [options] notifications list [-p ...] [-o ] + admin1-directory [options] notifications patch -r ... [-p ...] [-o ] + admin1-directory [options] notifications update -r ... [-p ...] [-o ] + admin1-directory [options] orgunits delete ... [-p ...] + admin1-directory [options] orgunits get ... [-p ...] [-o ] + admin1-directory [options] orgunits insert -r ... [-p ...] [-o ] + admin1-directory [options] orgunits list [-p ...] [-o ] + admin1-directory [options] orgunits patch ... -r ... [-p ...] [-o ] + admin1-directory [options] orgunits update ... -r ... [-p ...] [-o ] + admin1-directory [options] schemas delete [-p ...] + admin1-directory [options] schemas get [-p ...] [-o ] + admin1-directory [options] schemas insert -r ... [-p ...] [-o ] + admin1-directory [options] schemas list [-p ...] [-o ] + admin1-directory [options] schemas patch -r ... [-p ...] [-o ] + admin1-directory [options] schemas update -r ... [-p ...] [-o ] + admin1-directory [options] tokens delete [-p ...] + admin1-directory [options] tokens get [-p ...] [-o ] + admin1-directory [options] tokens list [-p ...] [-o ] + admin1-directory [options] users aliases-delete [-p ...] + admin1-directory [options] users aliases-insert -r ... [-p ...] [-o ] + admin1-directory [options] users aliases-list [-p ...] [-o ] + admin1-directory [options] users aliases-watch -r ... [-p ...] [-o ] + admin1-directory [options] users delete [-p ...] + admin1-directory [options] users get [-p ...] [-o ] + admin1-directory [options] users insert -r ... [-p ...] [-o ] + admin1-directory [options] users list [-p ...] [-o ] + admin1-directory [options] users make-admin -r ... [-p ...] + admin1-directory [options] users patch -r ... [-p ...] [-o ] + admin1-directory [options] users photos-delete [-p ...] + admin1-directory [options] users photos-get [-p ...] [-o ] + admin1-directory [options] users photos-patch -r ... [-p ...] [-o ] + admin1-directory [options] users photos-update -r ... [-p ...] [-o ] + admin1-directory [options] users undelete -r ... [-p ...] + admin1-directory [options] users update -r ... [-p ...] [-o ] + admin1-directory [options] users watch -r ... [-p ...] [-o ] + admin1-directory [options] verification-codes generate [-p ...] + admin1-directory [options] verification-codes invalidate [-p ...] + admin1-directory [options] verification-codes list [-p ...] [-o ] admin1-directory --help -All documentation details can be found TODO: +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_admin1_directory_cli/index.html Configuration: --scope - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -154,6 +155,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -196,6 +200,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -239,6 +246,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -255,37 +265,24 @@ impl Engine { fn _channels_stop(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Channel::default(); - let mut call = self.hub.channels().stop(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Channel::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "resource-uri" => { request.resource_uri = Some(value.unwrap_or("").to_string()); }, @@ -321,15 +318,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.channels().stop(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -374,6 +396,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -435,6 +460,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -451,40 +479,24 @@ impl Engine { fn _chromeosdevices_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::ChromeOsDevice::default(); - let mut call = self.hub.chromeosdevices().patch(&request, &self.opt.arg_customer_id, &self.opt.arg_device_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "projection" => { - call = call.projection(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ChromeOsDevice::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "mac-address" => { request.mac_address = Some(value.unwrap_or("").to_string()); }, @@ -555,15 +567,43 @@ impl Engine { request.model = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.chromeosdevices().patch(request, &self.opt.arg_customer_id, &self.opt.arg_device_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "projection" => { + call = call.projection(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -580,40 +620,24 @@ impl Engine { fn _chromeosdevices_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::ChromeOsDevice::default(); - let mut call = self.hub.chromeosdevices().update(&request, &self.opt.arg_customer_id, &self.opt.arg_device_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "projection" => { - call = call.projection(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ChromeOsDevice::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "mac-address" => { request.mac_address = Some(value.unwrap_or("").to_string()); }, @@ -684,15 +708,43 @@ impl Engine { request.model = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.chromeosdevices().update(request, &self.opt.arg_customer_id, &self.opt.arg_device_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "projection" => { + call = call.projection(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -736,6 +788,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -750,8 +805,45 @@ impl Engine { fn _groups_aliases_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Alias::default(); - let mut call = self.hub.groups().aliases_insert(&request, &self.opt.arg_group_key); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "alias" => { + request.alias = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "etag" => { + request.etag = Some(value.unwrap_or("").to_string()); + }, + "primary-email" => { + request.primary_email = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.groups().aliases_insert(request, &self.opt.arg_group_key); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -773,39 +865,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "alias" => { - request.alias = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "primary-email" => { - request.primary_email = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -849,6 +916,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -892,6 +962,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -933,6 +1006,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -949,37 +1025,24 @@ impl Engine { fn _groups_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Group::default(); - let mut call = self.hub.groups().insert(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Group::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "non-editable-aliases" => { if request.non_editable_aliases.is_none() { request.non_editable_aliases = Some(Default::default()); @@ -1017,15 +1080,40 @@ impl Engine { request.aliases.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.groups().insert(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1084,6 +1172,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1100,37 +1191,24 @@ impl Engine { fn _groups_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Group::default(); - let mut call = self.hub.groups().patch(&request, &self.opt.arg_group_key); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Group::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "non-editable-aliases" => { if request.non_editable_aliases.is_none() { request.non_editable_aliases = Some(Default::default()); @@ -1168,15 +1246,40 @@ impl Engine { request.aliases.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.groups().patch(request, &self.opt.arg_group_key); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1193,37 +1296,24 @@ impl Engine { fn _groups_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Group::default(); - let mut call = self.hub.groups().update(&request, &self.opt.arg_group_key); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Group::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "non-editable-aliases" => { if request.non_editable_aliases.is_none() { request.non_editable_aliases = Some(Default::default()); @@ -1261,15 +1351,40 @@ impl Engine { request.aliases.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.groups().update(request, &self.opt.arg_group_key); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1313,6 +1428,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1354,6 +1472,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1370,8 +1491,48 @@ impl Engine { fn _members_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Member::default(); - let mut call = self.hub.members().insert(&request, &self.opt.arg_group_key); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "etag" => { + request.etag = Some(value.unwrap_or("").to_string()); + }, + "role" => { + request.role = Some(value.unwrap_or("").to_string()); + }, + "type" => { + request.type_ = Some(value.unwrap_or("").to_string()); + }, + "email" => { + request.email = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.members().insert(request, &self.opt.arg_group_key); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1393,42 +1554,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "role" => { - request.role = Some(value.unwrap_or("").to_string()); - }, - "type" => { - request.type_ = Some(value.unwrap_or("").to_string()); - }, - "email" => { - request.email = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1481,6 +1614,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1497,8 +1633,48 @@ impl Engine { fn _members_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Member::default(); - let mut call = self.hub.members().patch(&request, &self.opt.arg_group_key, &self.opt.arg_member_key); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "etag" => { + request.etag = Some(value.unwrap_or("").to_string()); + }, + "role" => { + request.role = Some(value.unwrap_or("").to_string()); + }, + "type" => { + request.type_ = Some(value.unwrap_or("").to_string()); + }, + "email" => { + request.email = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.members().patch(request, &self.opt.arg_group_key, &self.opt.arg_member_key); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1520,42 +1696,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "role" => { - request.role = Some(value.unwrap_or("").to_string()); - }, - "type" => { - request.type_ = Some(value.unwrap_or("").to_string()); - }, - "email" => { - request.email = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1572,37 +1720,24 @@ impl Engine { fn _members_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Member::default(); - let mut call = self.hub.members().update(&request, &self.opt.arg_group_key, &self.opt.arg_member_key); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Member::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1622,33 +1757,11 @@ impl Engine { request.email = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _mobiledevices_action(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request = api::MobileDeviceAction::default(); - let mut call = self.hub.mobiledevices().action(&request, &self.opt.arg_customer_id, &self.opt.arg_resource_id); + let mut call = self.hub.members().update(request, &self.opt.arg_group_key, &self.opt.arg_member_key); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1670,27 +1783,86 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _mobiledevices_action(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option { - let mut field_name = FieldCursor::default(); + let mut request = api::MobileDeviceAction::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "action" => { request.action = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.mobiledevices().action(request, &self.opt.arg_customer_id, &self.opt.arg_resource_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1732,6 +1904,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1776,6 +1951,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1837,6 +2015,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1880,6 +2061,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1921,6 +2105,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1973,6 +2160,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1989,37 +2179,24 @@ impl Engine { fn _notifications_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Notification::default(); - let mut call = self.hub.notifications().patch(&request, &self.opt.arg_customer, &self.opt.arg_notification_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Notification::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "body" => { request.body = Some(value.unwrap_or("").to_string()); }, @@ -2045,15 +2222,40 @@ impl Engine { request.subject = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.notifications().patch(request, &self.opt.arg_customer, &self.opt.arg_notification_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2070,37 +2272,24 @@ impl Engine { fn _notifications_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Notification::default(); - let mut call = self.hub.notifications().update(&request, &self.opt.arg_customer, &self.opt.arg_notification_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Notification::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "body" => { request.body = Some(value.unwrap_or("").to_string()); }, @@ -2126,15 +2315,40 @@ impl Engine { request.subject = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.notifications().update(request, &self.opt.arg_customer, &self.opt.arg_notification_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2178,6 +2392,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2219,6 +2436,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2235,37 +2455,24 @@ impl Engine { fn _orgunits_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::OrgUnit::default(); - let mut call = self.hub.orgunits().insert(&request, &self.opt.arg_customer_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::OrgUnit::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -2294,15 +2501,40 @@ impl Engine { request.description = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.orgunits().insert(request, &self.opt.arg_customer_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2352,6 +2584,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2368,37 +2603,24 @@ impl Engine { fn _orgunits_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::OrgUnit::default(); - let mut call = self.hub.orgunits().patch(&request, &self.opt.arg_customer_id, &self.opt.arg_org_unit_path); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::OrgUnit::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -2427,15 +2649,40 @@ impl Engine { request.description = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.orgunits().patch(request, &self.opt.arg_customer_id, &self.opt.arg_org_unit_path); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2452,37 +2699,24 @@ impl Engine { fn _orgunits_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::OrgUnit::default(); - let mut call = self.hub.orgunits().update(&request, &self.opt.arg_customer_id, &self.opt.arg_org_unit_path); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::OrgUnit::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -2511,15 +2745,40 @@ impl Engine { request.description = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.orgunits().update(request, &self.opt.arg_customer_id, &self.opt.arg_org_unit_path); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2563,6 +2822,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2604,6 +2866,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2620,8 +2885,42 @@ impl Engine { fn _schemas_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Schema::default(); - let mut call = self.hub.schemas().insert(&request, &self.opt.arg_customer_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "etag" => { + request.etag = Some(value.unwrap_or("").to_string()); + }, + "schema-id" => { + request.schema_id = Some(value.unwrap_or("").to_string()); + }, + "schema-name" => { + request.schema_name = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.schemas().insert(request, &self.opt.arg_customer_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2643,36 +2942,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "schema-id" => { - request.schema_id = Some(value.unwrap_or("").to_string()); - }, - "schema-name" => { - request.schema_name = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2716,6 +2993,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2732,8 +3012,42 @@ impl Engine { fn _schemas_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Schema::default(); - let mut call = self.hub.schemas().patch(&request, &self.opt.arg_customer_id, &self.opt.arg_schema_key); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "etag" => { + request.etag = Some(value.unwrap_or("").to_string()); + }, + "schema-id" => { + request.schema_id = Some(value.unwrap_or("").to_string()); + }, + "schema-name" => { + request.schema_name = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.schemas().patch(request, &self.opt.arg_customer_id, &self.opt.arg_schema_key); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2755,36 +3069,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "schema-id" => { - request.schema_id = Some(value.unwrap_or("").to_string()); - }, - "schema-name" => { - request.schema_name = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2801,8 +3093,42 @@ impl Engine { fn _schemas_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Schema::default(); - let mut call = self.hub.schemas().update(&request, &self.opt.arg_customer_id, &self.opt.arg_schema_key); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "etag" => { + request.etag = Some(value.unwrap_or("").to_string()); + }, + "schema-id" => { + request.schema_id = Some(value.unwrap_or("").to_string()); + }, + "schema-name" => { + request.schema_name = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.schemas().update(request, &self.opt.arg_customer_id, &self.opt.arg_schema_key); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2824,36 +3150,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "schema-id" => { - request.schema_id = Some(value.unwrap_or("").to_string()); - }, - "schema-name" => { - request.schema_name = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2897,6 +3201,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2938,6 +3245,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2981,6 +3291,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3024,6 +3337,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -3038,8 +3354,45 @@ impl Engine { fn _users_aliases_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Alias::default(); - let mut call = self.hub.users().aliases_insert(&request, &self.opt.arg_user_key); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "alias" => { + request.alias = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "etag" => { + request.etag = Some(value.unwrap_or("").to_string()); + }, + "primary-email" => { + request.primary_email = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.users().aliases_insert(request, &self.opt.arg_user_key); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -3061,39 +3414,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "alias" => { - request.alias = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "primary-email" => { - request.primary_email = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3140,6 +3468,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3156,40 +3487,24 @@ impl Engine { fn _users_aliases_watch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Channel::default(); - let mut call = self.hub.users().aliases_watch(&request, &self.opt.arg_user_key); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "event" => { - call = call.event(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Channel::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "resource-uri" => { request.resource_uri = Some(value.unwrap_or("").to_string()); }, @@ -3225,15 +3540,43 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.users().aliases_watch(request, &self.opt.arg_user_key); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "event" => { + call = call.event(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3277,6 +3620,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -3327,6 +3673,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3343,43 +3692,30 @@ impl Engine { fn _users_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::User::default(); - let mut call = self.hub.users().insert(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::User::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_name_init(request: &mut api::User) { if request.name.is_none() { request.name = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "is-delegated-admin" => { request.is_delegated_admin = Some(arg_from_str(value.unwrap_or("false"), err, "is-delegated-admin", "boolean")); }, @@ -3471,15 +3807,40 @@ impl Engine { request.customer_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.users().insert(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3559,6 +3920,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3575,8 +3939,33 @@ impl Engine { fn _users_make_admin(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::UserMakeAdmin::default(); - let mut call = self.hub.users().make_admin(&request, &self.opt.arg_user_key); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "status" => { + request.status = Some(arg_from_str(value.unwrap_or("false"), err, "status", "boolean")); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.users().make_admin(request, &self.opt.arg_user_key); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -3598,27 +3987,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "status" => { - request.status = Some(arg_from_str(value.unwrap_or("false"), err, "status", "boolean")); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -3633,43 +4009,30 @@ impl Engine { fn _users_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::User::default(); - let mut call = self.hub.users().patch(&request, &self.opt.arg_user_key); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::User::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_name_init(request: &mut api::User) { if request.name.is_none() { request.name = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "is-delegated-admin" => { request.is_delegated_admin = Some(arg_from_str(value.unwrap_or("false"), err, "is-delegated-admin", "boolean")); }, @@ -3761,15 +4124,40 @@ impl Engine { request.customer_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.users().patch(request, &self.opt.arg_user_key); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3813,6 +4201,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -3854,6 +4245,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3870,37 +4264,24 @@ impl Engine { fn _users_photos_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::UserPhoto::default(); - let mut call = self.hub.users().photos_patch(&request, &self.opt.arg_user_key); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::UserPhoto::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "mime-type" => { request.mime_type = Some(value.unwrap_or("").to_string()); }, @@ -3926,15 +4307,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.users().photos_patch(request, &self.opt.arg_user_key); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3951,37 +4357,24 @@ impl Engine { fn _users_photos_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::UserPhoto::default(); - let mut call = self.hub.users().photos_update(&request, &self.opt.arg_user_key); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::UserPhoto::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "mime-type" => { request.mime_type = Some(value.unwrap_or("").to_string()); }, @@ -4007,15 +4400,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.users().photos_update(request, &self.opt.arg_user_key); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4032,8 +4450,33 @@ impl Engine { fn _users_undelete(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::UserUndelete::default(); - let mut call = self.hub.users().undelete(&request, &self.opt.arg_user_key); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "org-unit-path" => { + request.org_unit_path = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.users().undelete(request, &self.opt.arg_user_key); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -4055,27 +4498,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "org-unit-path" => { - request.org_unit_path = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -4090,43 +4520,30 @@ impl Engine { fn _users_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::User::default(); - let mut call = self.hub.users().update(&request, &self.opt.arg_user_key); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::User::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_name_init(request: &mut api::User) { if request.name.is_none() { request.name = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "is-delegated-admin" => { request.is_delegated_admin = Some(arg_from_str(value.unwrap_or("false"), err, "is-delegated-admin", "boolean")); }, @@ -4218,15 +4635,40 @@ impl Engine { request.customer_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.users().update(request, &self.opt.arg_user_key); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4243,8 +4685,64 @@ impl Engine { fn _users_watch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Channel::default(); - let mut call = self.hub.users().watch(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "resource-uri" => { + request.resource_uri = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "resource-id" => { + request.resource_id = Some(value.unwrap_or("").to_string()); + }, + "payload" => { + request.payload = Some(arg_from_str(value.unwrap_or("false"), err, "payload", "boolean")); + }, + "token" => { + request.token = Some(value.unwrap_or("").to_string()); + }, + "params" => { + if request.params.is_none() { + request.params = Some(Default::default()); + } + let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); + request.params.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); + }, + "expiration" => { + request.expiration = Some(value.unwrap_or("").to_string()); + }, + "address" => { + request.address = Some(value.unwrap_or("").to_string()); + }, + "type" => { + request.type_ = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.users().watch(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -4302,58 +4800,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "resource-uri" => { - request.resource_uri = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "resource-id" => { - request.resource_id = Some(value.unwrap_or("").to_string()); - }, - "payload" => { - request.payload = Some(arg_from_str(value.unwrap_or("false"), err, "payload", "boolean")); - }, - "token" => { - request.token = Some(value.unwrap_or("").to_string()); - }, - "params" => { - if request.params.is_none() { - request.params = Some(Default::default()); - } - let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); - request.params.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); - }, - "expiration" => { - request.expiration = Some(value.unwrap_or("").to_string()); - }, - "address" => { - request.address = Some(value.unwrap_or("").to_string()); - }, - "type" => { - request.type_ = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4397,6 +4851,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -4438,6 +4895,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -4479,6 +4939,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4759,6 +5222,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -4766,8 +5230,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/admin1_directory/Cargo.toml b/gen/admin1_directory/Cargo.toml index 71dd8e232c..4e99cbecf1 100644 --- a/gen/admin1_directory/Cargo.toml +++ b/gen/admin1_directory/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-admin1_directory" -version = "0.1.5+20150314" +version = "0.1.6+20150314" authors = ["Sebastian Thiel "] description = "A complete library to interact with directory (protocol directory_v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/admin1_directory" diff --git a/gen/admin1_directory/README.md b/gen/admin1_directory/README.md index 8b80773344..9924afc27b 100644 --- a/gen/admin1_directory/README.md +++ b/gen/admin1_directory/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-admin1_directory` library allows access to all features of the *Google directory* service. -This documentation was generated from *directory* crate version *0.1.5+20150314*, where *20150314* is the exact revision of the *admin:directory_v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *directory* crate version *0.1.6+20150314*, where *20150314* is the exact revision of the *admin:directory_v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *directory* *v1_directory* API can be found at the [official documentation site](https://developers.google.com/admin-sdk/directory/). @@ -144,7 +144,7 @@ let mut req = Channel::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.users().watch(&req) +let result = hub.users().watch(req) .view_type("eirmod") .sort_order("sit") .show_deleted("Stet") @@ -163,14 +163,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/admin1_directory/src/cmn.rs b/gen/admin1_directory/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/admin1_directory/src/cmn.rs +++ b/gen/admin1_directory/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option, + location: Option +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option, _: Option) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec]) -> Option { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/admin1_directory/src/lib.rs b/gen/admin1_directory/src/lib.rs index 66fb0b5171..3d6b0d0b6e 100644 --- a/gen/admin1_directory/src/lib.rs +++ b/gen/admin1_directory/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *directory* crate version *0.1.5+20150314*, where *20150314* is the exact revision of the *admin:directory_v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *directory* crate version *0.1.6+20150314*, where *20150314* is the exact revision of the *admin:directory_v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *directory* *v1_directory* API can be found at the //! [official documentation site](https://developers.google.com/admin-sdk/directory/). @@ -145,7 +145,7 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.users().watch(&req) +//! let result = hub.users().watch(req) //! .view_type("labore") //! .sort_order("sea") //! .show_deleted("nonumy") @@ -164,14 +164,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -259,7 +260,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -404,7 +405,7 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().watch(&req) +/// let result = hub.users().watch(req) /// .view_type("et") /// .sort_order("diam") /// .show_deleted("ipsum") @@ -423,14 +424,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -451,7 +453,7 @@ impl<'a, C, A> Directory Directory { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -493,7 +495,7 @@ impl<'a, C, A> Directory } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -1855,10 +1857,10 @@ impl<'a, C, A> ChannelMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn stop(&self, request: &Channel) -> ChannelStopCall<'a, C, A> { + pub fn stop(&self, request: Channel) -> ChannelStopCall<'a, C, A> { ChannelStopCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1914,10 +1916,10 @@ impl<'a, C, A> OrgunitMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `customerId` - Immutable id of the Google Apps account - pub fn insert(&self, request: &OrgUnit, customer_id: &str) -> OrgunitInsertCall<'a, C, A> { + pub fn insert(&self, request: OrgUnit, customer_id: &str) -> OrgunitInsertCall<'a, C, A> { OrgunitInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _customer_id: customer_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1972,10 +1974,10 @@ impl<'a, C, A> OrgunitMethods<'a, C, A> { /// * `request` - No description provided. /// * `customerId` - Immutable id of the Google Apps account /// * `orgUnitPath` - Full path of the organization unit or its Id - pub fn update(&self, request: &OrgUnit, customer_id: &str, org_unit_path: &Vec) -> OrgunitUpdateCall<'a, C, A> { + pub fn update(&self, request: OrgUnit, customer_id: &str, org_unit_path: &Vec) -> OrgunitUpdateCall<'a, C, A> { OrgunitUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _customer_id: customer_id.to_string(), _org_unit_path: org_unit_path.clone(), _delegate: Default::default(), @@ -2012,10 +2014,10 @@ impl<'a, C, A> OrgunitMethods<'a, C, A> { /// * `request` - No description provided. /// * `customerId` - Immutable id of the Google Apps account /// * `orgUnitPath` - Full path of the organization unit or its Id - pub fn patch(&self, request: &OrgUnit, customer_id: &str, org_unit_path: &Vec) -> OrgunitPatchCall<'a, C, A> { + pub fn patch(&self, request: OrgUnit, customer_id: &str, org_unit_path: &Vec) -> OrgunitPatchCall<'a, C, A> { OrgunitPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _customer_id: customer_id.to_string(), _org_unit_path: org_unit_path.clone(), _delegate: Default::default(), @@ -2072,10 +2074,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &User) -> UserInsertCall<'a, C, A> { + pub fn insert(&self, request: User) -> UserInsertCall<'a, C, A> { UserInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2107,10 +2109,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `userKey` - The immutable id of the user - pub fn undelete(&self, request: &UserUndelete, user_key: &str) -> UserUndeleteCall<'a, C, A> { + pub fn undelete(&self, request: UserUndelete, user_key: &str) -> UserUndeleteCall<'a, C, A> { UserUndeleteCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_key: user_key.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2126,10 +2128,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `userKey` - Email or immutable Id of the user as admin - pub fn make_admin(&self, request: &UserMakeAdmin, user_key: &str) -> UserMakeAdminCall<'a, C, A> { + pub fn make_admin(&self, request: UserMakeAdmin, user_key: &str) -> UserMakeAdminCall<'a, C, A> { UserMakeAdminCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_key: user_key.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2145,10 +2147,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `userKey` - Email or immutable Id of the user. If Id, it should match with id of user object - pub fn patch(&self, request: &User, user_key: &str) -> UserPatchCall<'a, C, A> { + pub fn patch(&self, request: User, user_key: &str) -> UserPatchCall<'a, C, A> { UserPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_key: user_key.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2163,10 +2165,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn watch(&self, request: &Channel) -> UserWatchCall<'a, C, A> { + pub fn watch(&self, request: Channel) -> UserWatchCall<'a, C, A> { UserWatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _view_type: Default::default(), _sort_order: Default::default(), _show_deleted: Default::default(), @@ -2210,10 +2212,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `userKey` - Email or immutable Id of the user - pub fn photos_update(&self, request: &UserPhoto, user_key: &str) -> UserPhotoUpdateCall<'a, C, A> { + pub fn photos_update(&self, request: UserPhoto, user_key: &str) -> UserPhotoUpdateCall<'a, C, A> { UserPhotoUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_key: user_key.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2249,10 +2251,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `userKey` - Email or immutable Id of the user - pub fn aliases_insert(&self, request: &Alias, user_key: &str) -> UserAliaseInsertCall<'a, C, A> { + pub fn aliases_insert(&self, request: Alias, user_key: &str) -> UserAliaseInsertCall<'a, C, A> { UserAliaseInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_key: user_key.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2311,10 +2313,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `userKey` - Email or immutable Id of the user. If Id, it should match with id of user object - pub fn update(&self, request: &User, user_key: &str) -> UserUpdateCall<'a, C, A> { + pub fn update(&self, request: User, user_key: &str) -> UserUpdateCall<'a, C, A> { UserUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_key: user_key.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2330,10 +2332,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `userKey` - Email or immutable Id of the user - pub fn aliases_watch(&self, request: &Channel, user_key: &str) -> UserAliaseWatchCall<'a, C, A> { + pub fn aliases_watch(&self, request: Channel, user_key: &str) -> UserAliaseWatchCall<'a, C, A> { UserAliaseWatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_key: user_key.to_string(), _event: Default::default(), _delegate: Default::default(), @@ -2385,10 +2387,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `userKey` - Email or immutable Id of the user - pub fn photos_patch(&self, request: &UserPhoto, user_key: &str) -> UserPhotoPatchCall<'a, C, A> { + pub fn photos_patch(&self, request: UserPhoto, user_key: &str) -> UserPhotoPatchCall<'a, C, A> { UserPhotoPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_key: user_key.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2508,10 +2510,10 @@ impl<'a, C, A> MobiledeviceMethods<'a, C, A> { /// * `request` - No description provided. /// * `customerId` - Immutable id of the Google Apps account /// * `resourceId` - Immutable id of Mobile Device - pub fn action(&self, request: &MobileDeviceAction, customer_id: &str, resource_id: &str) -> MobiledeviceActionCall<'a, C, A> { + pub fn action(&self, request: MobileDeviceAction, customer_id: &str, resource_id: &str) -> MobiledeviceActionCall<'a, C, A> { MobiledeviceActionCall { hub: self.hub, - _request: request.clone(), + _request: request, _customer_id: customer_id.to_string(), _resource_id: resource_id.to_string(), _delegate: Default::default(), @@ -2570,10 +2572,10 @@ impl<'a, C, A> MemberMethods<'a, C, A> { /// * `request` - No description provided. /// * `groupKey` - Email or immutable Id of the group. If Id, it should match with id of group object /// * `memberKey` - Email or immutable Id of the user. If Id, it should match with id of member object - pub fn update(&self, request: &Member, group_key: &str, member_key: &str) -> MemberUpdateCall<'a, C, A> { + pub fn update(&self, request: Member, group_key: &str, member_key: &str) -> MemberUpdateCall<'a, C, A> { MemberUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _group_key: group_key.to_string(), _member_key: member_key.to_string(), _delegate: Default::default(), @@ -2609,10 +2611,10 @@ impl<'a, C, A> MemberMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `groupKey` - Email or immutable Id of the group - pub fn insert(&self, request: &Member, group_key: &str) -> MemberInsertCall<'a, C, A> { + pub fn insert(&self, request: Member, group_key: &str) -> MemberInsertCall<'a, C, A> { MemberInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _group_key: group_key.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2629,10 +2631,10 @@ impl<'a, C, A> MemberMethods<'a, C, A> { /// * `request` - No description provided. /// * `groupKey` - Email or immutable Id of the group. If Id, it should match with id of group object /// * `memberKey` - Email or immutable Id of the user. If Id, it should match with id of member object - pub fn patch(&self, request: &Member, group_key: &str, member_key: &str) -> MemberPatchCall<'a, C, A> { + pub fn patch(&self, request: Member, group_key: &str, member_key: &str) -> MemberPatchCall<'a, C, A> { MemberPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _group_key: group_key.to_string(), _member_key: member_key.to_string(), _delegate: Default::default(), @@ -2769,10 +2771,10 @@ impl<'a, C, A> NotificationMethods<'a, C, A> { /// * `request` - No description provided. /// * `customer` - The unique ID for the customer's Google account. /// * `notificationId` - The unique ID of the notification. - pub fn patch(&self, request: &Notification, customer: &str, notification_id: &str) -> NotificationPatchCall<'a, C, A> { + pub fn patch(&self, request: Notification, customer: &str, notification_id: &str) -> NotificationPatchCall<'a, C, A> { NotificationPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _customer: customer.to_string(), _notification_id: notification_id.to_string(), _delegate: Default::default(), @@ -2790,10 +2792,10 @@ impl<'a, C, A> NotificationMethods<'a, C, A> { /// * `request` - No description provided. /// * `customer` - The unique ID for the customer's Google account. /// * `notificationId` - The unique ID of the notification. - pub fn update(&self, request: &Notification, customer: &str, notification_id: &str) -> NotificationUpdateCall<'a, C, A> { + pub fn update(&self, request: Notification, customer: &str, notification_id: &str) -> NotificationUpdateCall<'a, C, A> { NotificationUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _customer: customer.to_string(), _notification_id: notification_id.to_string(), _delegate: Default::default(), @@ -2894,10 +2896,10 @@ impl<'a, C, A> ChromeosdeviceMethods<'a, C, A> { /// * `request` - No description provided. /// * `customerId` - Immutable id of the Google Apps account /// * `deviceId` - Immutable id of Chrome OS Device - pub fn patch(&self, request: &ChromeOsDevice, customer_id: &str, device_id: &str) -> ChromeosdevicePatchCall<'a, C, A> { + pub fn patch(&self, request: ChromeOsDevice, customer_id: &str, device_id: &str) -> ChromeosdevicePatchCall<'a, C, A> { ChromeosdevicePatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _customer_id: customer_id.to_string(), _device_id: device_id.to_string(), _projection: Default::default(), @@ -2936,10 +2938,10 @@ impl<'a, C, A> ChromeosdeviceMethods<'a, C, A> { /// * `request` - No description provided. /// * `customerId` - Immutable id of the Google Apps account /// * `deviceId` - Immutable id of Chrome OS Device - pub fn update(&self, request: &ChromeOsDevice, customer_id: &str, device_id: &str) -> ChromeosdeviceUpdateCall<'a, C, A> { + pub fn update(&self, request: ChromeOsDevice, customer_id: &str, device_id: &str) -> ChromeosdeviceUpdateCall<'a, C, A> { ChromeosdeviceUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _customer_id: customer_id.to_string(), _device_id: device_id.to_string(), _projection: Default::default(), @@ -3141,10 +3143,10 @@ impl<'a, C, A> GroupMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `groupKey` - Email or immutable Id of the group. If Id, it should match with id of group object - pub fn patch(&self, request: &Group, group_key: &str) -> GroupPatchCall<'a, C, A> { + pub fn patch(&self, request: Group, group_key: &str) -> GroupPatchCall<'a, C, A> { GroupPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _group_key: group_key.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3160,10 +3162,10 @@ impl<'a, C, A> GroupMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `groupKey` - Email or immutable Id of the group. If Id, it should match with id of group object - pub fn update(&self, request: &Group, group_key: &str) -> GroupUpdateCall<'a, C, A> { + pub fn update(&self, request: Group, group_key: &str) -> GroupUpdateCall<'a, C, A> { GroupUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _group_key: group_key.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3196,10 +3198,10 @@ impl<'a, C, A> GroupMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `groupKey` - Email or immutable Id of the group - pub fn aliases_insert(&self, request: &Alias, group_key: &str) -> GroupAliaseInsertCall<'a, C, A> { + pub fn aliases_insert(&self, request: Alias, group_key: &str) -> GroupAliaseInsertCall<'a, C, A> { GroupAliaseInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _group_key: group_key.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3233,10 +3235,10 @@ impl<'a, C, A> GroupMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &Group) -> GroupInsertCall<'a, C, A> { + pub fn insert(&self, request: Group) -> GroupInsertCall<'a, C, A> { GroupInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3425,10 +3427,10 @@ impl<'a, C, A> SchemaMethods<'a, C, A> { /// * `request` - No description provided. /// * `customerId` - Immutable id of the Google Apps account /// * `schemaKey` - Name or immutable Id of the schema. - pub fn patch(&self, request: &Schema, customer_id: &str, schema_key: &str) -> SchemaPatchCall<'a, C, A> { + pub fn patch(&self, request: Schema, customer_id: &str, schema_key: &str) -> SchemaPatchCall<'a, C, A> { SchemaPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _customer_id: customer_id.to_string(), _schema_key: schema_key.to_string(), _delegate: Default::default(), @@ -3445,10 +3447,10 @@ impl<'a, C, A> SchemaMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `customerId` - Immutable id of the Google Apps account - pub fn insert(&self, request: &Schema, customer_id: &str) -> SchemaInsertCall<'a, C, A> { + pub fn insert(&self, request: Schema, customer_id: &str) -> SchemaInsertCall<'a, C, A> { SchemaInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _customer_id: customer_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3484,10 +3486,10 @@ impl<'a, C, A> SchemaMethods<'a, C, A> { /// * `request` - No description provided. /// * `customerId` - Immutable id of the Google Apps account /// * `schemaKey` - Name or immutable Id of the schema. - pub fn update(&self, request: &Schema, customer_id: &str, schema_key: &str) -> SchemaUpdateCall<'a, C, A> { + pub fn update(&self, request: Schema, customer_id: &str, schema_key: &str) -> SchemaUpdateCall<'a, C, A> { SchemaUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _customer_id: customer_id.to_string(), _schema_key: schema_key.to_string(), _delegate: Default::default(), @@ -3652,12 +3654,17 @@ impl<'a, C, A> TokenGetCall<'a, C, A> where C: BorrowMut, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3666,7 +3673,7 @@ impl<'a, C, A> TokenGetCall<'a, C, A> where C: BorrowMut, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3896,12 +3903,17 @@ impl<'a, C, A> TokenListCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3910,7 +3922,7 @@ impl<'a, C, A> TokenListCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4131,12 +4143,17 @@ impl<'a, C, A> TokenDeleteCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -4252,7 +4269,7 @@ impl<'a, C, A> TokenDeleteCall<'a, C, A> where C: BorrowMut, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.channels().stop(&req) +/// let result = hub.channels().stop(req) /// .doit(); /// # } /// ``` @@ -4353,12 +4370,17 @@ impl<'a, C, A> ChannelStopCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -4375,8 +4397,8 @@ impl<'a, C, A> ChannelStopCall<'a, C, A> where C: BorrowMut, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Channel) -> ChannelStopCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Channel) -> ChannelStopCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -4463,7 +4485,7 @@ impl<'a, C, A> ChannelStopCall<'a, C, A> where C: BorrowMut, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.orgunits().insert(&req, "customerId") +/// let result = hub.orgunits().insert(req, "customerId") /// .doit(); /// # } /// ``` @@ -4591,12 +4613,17 @@ impl<'a, C, A> OrgunitInsertCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4605,7 +4632,7 @@ impl<'a, C, A> OrgunitInsertCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4623,8 +4650,8 @@ impl<'a, C, A> OrgunitInsertCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &OrgUnit) -> OrgunitInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: OrgUnit) -> OrgunitInsertCall<'a, C, A> { + self._request = new_value; self } /// Immutable id of the Google Apps account @@ -4844,12 +4871,17 @@ impl<'a, C, A> OrgunitListCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4858,7 +4890,7 @@ impl<'a, C, A> OrgunitListCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5100,12 +5132,17 @@ impl<'a, C, A> OrgunitGetCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5114,7 +5151,7 @@ impl<'a, C, A> OrgunitGetCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5232,7 +5269,7 @@ impl<'a, C, A> OrgunitGetCall<'a, C, A> where C: BorrowMut, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.orgunits().update(&req, "customerId", "orgUnitPath") +/// let result = hub.orgunits().update(req, "customerId", "orgUnitPath") /// .doit(); /// # } /// ``` @@ -5368,12 +5405,17 @@ impl<'a, C, A> OrgunitUpdateCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5382,7 +5424,7 @@ impl<'a, C, A> OrgunitUpdateCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5400,8 +5442,8 @@ impl<'a, C, A> OrgunitUpdateCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &OrgUnit) -> OrgunitUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: OrgUnit) -> OrgunitUpdateCall<'a, C, A> { + self._request = new_value; self } /// Immutable id of the Google Apps account @@ -5629,12 +5671,17 @@ impl<'a, C, A> OrgunitDeleteCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -5751,7 +5798,7 @@ impl<'a, C, A> OrgunitDeleteCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.orgunits().patch(&req, "customerId", "orgUnitPath") +/// let result = hub.orgunits().patch(req, "customerId", "orgUnitPath") /// .doit(); /// # } /// ``` @@ -5887,12 +5934,17 @@ impl<'a, C, A> OrgunitPatchCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5901,7 +5953,7 @@ impl<'a, C, A> OrgunitPatchCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5919,8 +5971,8 @@ impl<'a, C, A> OrgunitPatchCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &OrgUnit) -> OrgunitPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: OrgUnit) -> OrgunitPatchCall<'a, C, A> { + self._request = new_value; self } /// Immutable id of the Google Apps account @@ -6028,7 +6080,7 @@ impl<'a, C, A> OrgunitPatchCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().insert(&req) +/// let result = hub.users().insert(req) /// .doit(); /// # } /// ``` @@ -6130,12 +6182,17 @@ impl<'a, C, A> UserInsertCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6144,7 +6201,7 @@ impl<'a, C, A> UserInsertCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6162,8 +6219,8 @@ impl<'a, C, A> UserInsertCall<'a, C, A> where C: BorrowMut, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &User) -> UserInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: User) -> UserInsertCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -6362,12 +6419,17 @@ impl<'a, C, A> UserPhotoDeleteCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -6473,7 +6535,7 @@ impl<'a, C, A> UserPhotoDeleteCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().undelete(&req, "userKey") +/// let result = hub.users().undelete(req, "userKey") /// .doit(); /// # } /// ``` @@ -6600,12 +6662,17 @@ impl<'a, C, A> UserUndeleteCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -6622,8 +6689,8 @@ impl<'a, C, A> UserUndeleteCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &UserUndelete) -> UserUndeleteCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: UserUndelete) -> UserUndeleteCall<'a, C, A> { + self._request = new_value; self } /// The immutable id of the user @@ -6720,7 +6787,7 @@ impl<'a, C, A> UserUndeleteCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().make_admin(&req, "userKey") +/// let result = hub.users().make_admin(req, "userKey") /// .doit(); /// # } /// ``` @@ -6847,12 +6914,17 @@ impl<'a, C, A> UserMakeAdminCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -6869,8 +6941,8 @@ impl<'a, C, A> UserMakeAdminCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &UserMakeAdmin) -> UserMakeAdminCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: UserMakeAdmin) -> UserMakeAdminCall<'a, C, A> { + self._request = new_value; self } /// Email or immutable Id of the user as admin @@ -6967,7 +7039,7 @@ impl<'a, C, A> UserMakeAdminCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().patch(&req, "userKey") +/// let result = hub.users().patch(req, "userKey") /// .doit(); /// # } /// ``` @@ -7095,12 +7167,17 @@ impl<'a, C, A> UserPatchCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7109,7 +7186,7 @@ impl<'a, C, A> UserPatchCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7127,8 +7204,8 @@ impl<'a, C, A> UserPatchCall<'a, C, A> where C: BorrowMut, A: oau /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &User) -> UserPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: User) -> UserPatchCall<'a, C, A> { + self._request = new_value; self } /// Email or immutable Id of the user. If Id, it should match with id of user object @@ -7225,7 +7302,7 @@ impl<'a, C, A> UserPatchCall<'a, C, A> where C: BorrowMut, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().watch(&req) +/// let result = hub.users().watch(req) /// .view_type("consetetur") /// .sort_order("ut") /// .show_deleted("ea") @@ -7387,12 +7464,17 @@ impl<'a, C, A> UserWatchCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7401,7 +7483,7 @@ impl<'a, C, A> UserWatchCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7419,8 +7501,8 @@ impl<'a, C, A> UserWatchCall<'a, C, A> where C: BorrowMut, A: oau /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Channel) -> UserWatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Channel) -> UserWatchCall<'a, C, A> { + self._request = new_value; self } /// Whether to fetch the ADMIN_VIEW or DOMAIN_PUBLIC view of the user. @@ -7703,12 +7785,17 @@ impl<'a, C, A> UserDeleteCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -7814,7 +7901,7 @@ impl<'a, C, A> UserDeleteCall<'a, C, A> where C: BorrowMut, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().photos_update(&req, "userKey") +/// let result = hub.users().photos_update(req, "userKey") /// .doit(); /// # } /// ``` @@ -7942,12 +8029,17 @@ impl<'a, C, A> UserPhotoUpdateCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7956,7 +8048,7 @@ impl<'a, C, A> UserPhotoUpdateCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7974,8 +8066,8 @@ impl<'a, C, A> UserPhotoUpdateCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &UserPhoto) -> UserPhotoUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: UserPhoto) -> UserPhotoUpdateCall<'a, C, A> { + self._request = new_value; self } /// Email or immutable Id of the user @@ -8200,12 +8292,17 @@ impl<'a, C, A> UserGetCall<'a, C, A> where C: BorrowMut, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8214,7 +8311,7 @@ impl<'a, C, A> UserGetCall<'a, C, A> where C: BorrowMut, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8342,7 +8439,7 @@ impl<'a, C, A> UserGetCall<'a, C, A> where C: BorrowMut, A: oauth /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().aliases_insert(&req, "userKey") +/// let result = hub.users().aliases_insert(req, "userKey") /// .doit(); /// # } /// ``` @@ -8470,12 +8567,17 @@ impl<'a, C, A> UserAliaseInsertCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8484,7 +8586,7 @@ impl<'a, C, A> UserAliaseInsertCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8502,8 +8604,8 @@ impl<'a, C, A> UserAliaseInsertCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Alias) -> UserAliaseInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Alias) -> UserAliaseInsertCall<'a, C, A> { + self._request = new_value; self } /// Email or immutable Id of the user @@ -8747,12 +8849,17 @@ impl<'a, C, A> UserListCall<'a, C, A> where C: BorrowMut, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8761,7 +8868,7 @@ impl<'a, C, A> UserListCall<'a, C, A> where C: BorrowMut, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9056,12 +9163,17 @@ impl<'a, C, A> UserAliaseDeleteCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -9177,7 +9289,7 @@ impl<'a, C, A> UserAliaseDeleteCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().update(&req, "userKey") +/// let result = hub.users().update(req, "userKey") /// .doit(); /// # } /// ``` @@ -9305,12 +9417,17 @@ impl<'a, C, A> UserUpdateCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9319,7 +9436,7 @@ impl<'a, C, A> UserUpdateCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9337,8 +9454,8 @@ impl<'a, C, A> UserUpdateCall<'a, C, A> where C: BorrowMut, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &User) -> UserUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: User) -> UserUpdateCall<'a, C, A> { + self._request = new_value; self } /// Email or immutable Id of the user. If Id, it should match with id of user object @@ -9435,7 +9552,7 @@ impl<'a, C, A> UserUpdateCall<'a, C, A> where C: BorrowMut, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().aliases_watch(&req, "userKey") +/// let result = hub.users().aliases_watch(req, "userKey") /// .event("takimata") /// .doit(); /// # } @@ -9568,12 +9685,17 @@ impl<'a, C, A> UserAliaseWatchCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9582,7 +9704,7 @@ impl<'a, C, A> UserAliaseWatchCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9600,8 +9722,8 @@ impl<'a, C, A> UserAliaseWatchCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Channel) -> UserAliaseWatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Channel) -> UserAliaseWatchCall<'a, C, A> { + self._request = new_value; self } /// Email or immutable Id of the user @@ -9823,12 +9945,17 @@ impl<'a, C, A> UserAliaseListCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9837,7 +9964,7 @@ impl<'a, C, A> UserAliaseListCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10064,12 +10191,17 @@ impl<'a, C, A> UserPhotoGetCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10078,7 +10210,7 @@ impl<'a, C, A> UserPhotoGetCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10185,7 +10317,7 @@ impl<'a, C, A> UserPhotoGetCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().photos_patch(&req, "userKey") +/// let result = hub.users().photos_patch(req, "userKey") /// .doit(); /// # } /// ``` @@ -10313,12 +10445,17 @@ impl<'a, C, A> UserPhotoPatchCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10327,7 +10464,7 @@ impl<'a, C, A> UserPhotoPatchCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10345,8 +10482,8 @@ impl<'a, C, A> UserPhotoPatchCall<'a, C, A> where C: BorrowMut, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &UserPhoto) -> UserPhotoPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: UserPhoto) -> UserPhotoPatchCall<'a, C, A> { + self._request = new_value; self } /// Email or immutable Id of the user @@ -10557,12 +10694,17 @@ impl<'a, C, A> MobiledeviceDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -10798,12 +10940,17 @@ impl<'a, C, A> MobiledeviceGetCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10812,7 +10959,7 @@ impl<'a, C, A> MobiledeviceGetCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11079,12 +11226,17 @@ impl<'a, C, A> MobiledeviceListCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11093,7 +11245,7 @@ impl<'a, C, A> MobiledeviceListCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11242,7 +11394,7 @@ impl<'a, C, A> MobiledeviceListCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.mobiledevices().action(&req, "customerId", "resourceId") +/// let result = hub.mobiledevices().action(req, "customerId", "resourceId") /// .doit(); /// # } /// ``` @@ -11371,12 +11523,17 @@ impl<'a, C, A> MobiledeviceActionCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -11393,8 +11550,8 @@ impl<'a, C, A> MobiledeviceActionCall<'a, C, A> where C: BorrowMut MobiledeviceActionCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: MobileDeviceAction) -> MobiledeviceActionCall<'a, C, A> { + self._request = new_value; self } /// Immutable id of the Google Apps account @@ -11501,7 +11658,7 @@ impl<'a, C, A> MobiledeviceActionCall<'a, C, A> where C: BorrowMut MemberUpdateCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11645,7 +11807,7 @@ impl<'a, C, A> MemberUpdateCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11663,8 +11825,8 @@ impl<'a, C, A> MemberUpdateCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Member) -> MemberUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Member) -> MemberUpdateCall<'a, C, A> { + self._request = new_value; self } /// Email or immutable Id of the group. If Id, it should match with id of group object @@ -11886,12 +12048,17 @@ impl<'a, C, A> MemberGetCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11900,7 +12067,7 @@ impl<'a, C, A> MemberGetCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12017,7 +12184,7 @@ impl<'a, C, A> MemberGetCall<'a, C, A> where C: BorrowMut, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.members().insert(&req, "groupKey") +/// let result = hub.members().insert(req, "groupKey") /// .doit(); /// # } /// ``` @@ -12145,12 +12312,17 @@ impl<'a, C, A> MemberInsertCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12159,7 +12331,7 @@ impl<'a, C, A> MemberInsertCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12177,8 +12349,8 @@ impl<'a, C, A> MemberInsertCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Member) -> MemberInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Member) -> MemberInsertCall<'a, C, A> { + self._request = new_value; self } /// Email or immutable Id of the group @@ -12275,7 +12447,7 @@ impl<'a, C, A> MemberInsertCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.members().patch(&req, "groupKey", "memberKey") +/// let result = hub.members().patch(req, "groupKey", "memberKey") /// .doit(); /// # } /// ``` @@ -12405,12 +12577,17 @@ impl<'a, C, A> MemberPatchCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12419,7 +12596,7 @@ impl<'a, C, A> MemberPatchCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12437,8 +12614,8 @@ impl<'a, C, A> MemberPatchCall<'a, C, A> where C: BorrowMut, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Member) -> MemberPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Member) -> MemberPatchCall<'a, C, A> { + self._request = new_value; self } /// Email or immutable Id of the group. If Id, it should match with id of group object @@ -12659,12 +12836,17 @@ impl<'a, C, A> MemberDeleteCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -12908,12 +13090,17 @@ impl<'a, C, A> MemberListCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12922,7 +13109,7 @@ impl<'a, C, A> MemberListCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13178,12 +13365,17 @@ impl<'a, C, A> NotificationListCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13192,7 +13384,7 @@ impl<'a, C, A> NotificationListCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13434,12 +13626,17 @@ impl<'a, C, A> NotificationDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -13555,7 +13752,7 @@ impl<'a, C, A> NotificationDeleteCall<'a, C, A> where C: BorrowMut NotificationPatchCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13699,7 +13901,7 @@ impl<'a, C, A> NotificationPatchCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13717,8 +13919,8 @@ impl<'a, C, A> NotificationPatchCall<'a, C, A> where C: BorrowMut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Notification) -> NotificationPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Notification) -> NotificationPatchCall<'a, C, A> { + self._request = new_value; self } /// The unique ID for the customer's Google account. @@ -13825,7 +14027,7 @@ impl<'a, C, A> NotificationPatchCall<'a, C, A> where C: BorrowMut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.notifications().update(&req, "customer", "notificationId") +/// let result = hub.notifications().update(req, "customer", "notificationId") /// .doit(); /// # } /// ``` @@ -13955,12 +14157,17 @@ impl<'a, C, A> NotificationUpdateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13969,7 +14176,7 @@ impl<'a, C, A> NotificationUpdateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13987,8 +14194,8 @@ impl<'a, C, A> NotificationUpdateCall<'a, C, A> where C: BorrowMut NotificationUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Notification) -> NotificationUpdateCall<'a, C, A> { + self._request = new_value; self } /// The unique ID for the customer's Google account. @@ -14210,12 +14417,17 @@ impl<'a, C, A> NotificationGetCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14224,7 +14436,7 @@ impl<'a, C, A> NotificationGetCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14484,12 +14696,17 @@ impl<'a, C, A> ChromeosdeviceListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14498,7 +14715,7 @@ impl<'a, C, A> ChromeosdeviceListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14647,7 +14864,7 @@ impl<'a, C, A> ChromeosdeviceListCall<'a, C, A> where C: BorrowMut ChromeosdevicePatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14796,7 +15018,7 @@ impl<'a, C, A> ChromeosdevicePatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14814,8 +15036,8 @@ impl<'a, C, A> ChromeosdevicePatchCall<'a, C, A> where C: BorrowMut ChromeosdevicePatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ChromeOsDevice) -> ChromeosdevicePatchCall<'a, C, A> { + self._request = new_value; self } /// Immutable id of the Google Apps account @@ -15049,12 +15271,17 @@ impl<'a, C, A> ChromeosdeviceGetCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15063,7 +15290,7 @@ impl<'a, C, A> ChromeosdeviceGetCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15187,7 +15414,7 @@ impl<'a, C, A> ChromeosdeviceGetCall<'a, C, A> where C: BorrowMut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.chromeosdevices().update(&req, "customerId", "deviceId") +/// let result = hub.chromeosdevices().update(req, "customerId", "deviceId") /// .projection("consetetur") /// .doit(); /// # } @@ -15322,12 +15549,17 @@ impl<'a, C, A> ChromeosdeviceUpdateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15336,7 +15568,7 @@ impl<'a, C, A> ChromeosdeviceUpdateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15354,8 +15586,8 @@ impl<'a, C, A> ChromeosdeviceUpdateCall<'a, C, A> where C: BorrowMut ChromeosdeviceUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ChromeOsDevice) -> ChromeosdeviceUpdateCall<'a, C, A> { + self._request = new_value; self } /// Immutable id of the Google Apps account @@ -15581,12 +15813,17 @@ impl<'a, C, A> VerificationCodeGenerateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -15804,12 +16041,17 @@ impl<'a, C, A> VerificationCodeInvalidateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -16028,12 +16270,17 @@ impl<'a, C, A> VerificationCodeListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16042,7 +16289,7 @@ impl<'a, C, A> VerificationCodeListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16262,12 +16509,17 @@ impl<'a, C, A> GroupGetCall<'a, C, A> where C: BorrowMut, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16276,7 +16528,7 @@ impl<'a, C, A> GroupGetCall<'a, C, A> where C: BorrowMut, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16495,12 +16747,17 @@ impl<'a, C, A> GroupListCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16509,7 +16766,7 @@ impl<'a, C, A> GroupListCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16754,12 +17011,17 @@ impl<'a, C, A> GroupAliaseListCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16768,7 +17030,7 @@ impl<'a, C, A> GroupAliaseListCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16875,7 +17137,7 @@ impl<'a, C, A> GroupAliaseListCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.groups().patch(&req, "groupKey") +/// let result = hub.groups().patch(req, "groupKey") /// .doit(); /// # } /// ``` @@ -17003,12 +17265,17 @@ impl<'a, C, A> GroupPatchCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -17017,7 +17284,7 @@ impl<'a, C, A> GroupPatchCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -17035,8 +17302,8 @@ impl<'a, C, A> GroupPatchCall<'a, C, A> where C: BorrowMut, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Group) -> GroupPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Group) -> GroupPatchCall<'a, C, A> { + self._request = new_value; self } /// Email or immutable Id of the group. If Id, it should match with id of group object @@ -17133,7 +17400,7 @@ impl<'a, C, A> GroupPatchCall<'a, C, A> where C: BorrowMut, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.groups().update(&req, "groupKey") +/// let result = hub.groups().update(req, "groupKey") /// .doit(); /// # } /// ``` @@ -17261,12 +17528,17 @@ impl<'a, C, A> GroupUpdateCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -17275,7 +17547,7 @@ impl<'a, C, A> GroupUpdateCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -17293,8 +17565,8 @@ impl<'a, C, A> GroupUpdateCall<'a, C, A> where C: BorrowMut, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Group) -> GroupUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Group) -> GroupUpdateCall<'a, C, A> { + self._request = new_value; self } /// Email or immutable Id of the group. If Id, it should match with id of group object @@ -17503,12 +17775,17 @@ impl<'a, C, A> GroupDeleteCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -17614,7 +17891,7 @@ impl<'a, C, A> GroupDeleteCall<'a, C, A> where C: BorrowMut, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.groups().aliases_insert(&req, "groupKey") +/// let result = hub.groups().aliases_insert(req, "groupKey") /// .doit(); /// # } /// ``` @@ -17742,12 +18019,17 @@ impl<'a, C, A> GroupAliaseInsertCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -17756,7 +18038,7 @@ impl<'a, C, A> GroupAliaseInsertCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -17774,8 +18056,8 @@ impl<'a, C, A> GroupAliaseInsertCall<'a, C, A> where C: BorrowMut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Alias) -> GroupAliaseInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Alias) -> GroupAliaseInsertCall<'a, C, A> { + self._request = new_value; self } /// Email or immutable Id of the group @@ -17986,12 +18268,17 @@ impl<'a, C, A> GroupAliaseDeleteCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -18107,7 +18394,7 @@ impl<'a, C, A> GroupAliaseDeleteCall<'a, C, A> where C: BorrowMut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.groups().insert(&req) +/// let result = hub.groups().insert(req) /// .doit(); /// # } /// ``` @@ -18209,12 +18496,17 @@ impl<'a, C, A> GroupInsertCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -18223,7 +18515,7 @@ impl<'a, C, A> GroupInsertCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -18241,8 +18533,8 @@ impl<'a, C, A> GroupInsertCall<'a, C, A> where C: BorrowMut, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Group) -> GroupInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Group) -> GroupInsertCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -18443,12 +18735,17 @@ impl<'a, C, A> AspDeleteCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -18677,12 +18974,17 @@ impl<'a, C, A> AspListCall<'a, C, A> where C: BorrowMut, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -18691,7 +18993,7 @@ impl<'a, C, A> AspListCall<'a, C, A> where C: BorrowMut, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -18913,12 +19215,17 @@ impl<'a, C, A> AspGetCall<'a, C, A> where C: BorrowMut, A: oauth2 if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -18927,7 +19234,7 @@ impl<'a, C, A> AspGetCall<'a, C, A> where C: BorrowMut, A: oauth2 Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -19157,12 +19464,17 @@ impl<'a, C, A> SchemaListCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -19171,7 +19483,7 @@ impl<'a, C, A> SchemaListCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -19393,12 +19705,17 @@ impl<'a, C, A> SchemaGetCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -19407,7 +19724,7 @@ impl<'a, C, A> SchemaGetCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -19524,7 +19841,7 @@ impl<'a, C, A> SchemaGetCall<'a, C, A> where C: BorrowMut, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.schemas().patch(&req, "customerId", "schemaKey") +/// let result = hub.schemas().patch(req, "customerId", "schemaKey") /// .doit(); /// # } /// ``` @@ -19654,12 +19971,17 @@ impl<'a, C, A> SchemaPatchCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -19668,7 +19990,7 @@ impl<'a, C, A> SchemaPatchCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -19686,8 +20008,8 @@ impl<'a, C, A> SchemaPatchCall<'a, C, A> where C: BorrowMut, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Schema) -> SchemaPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Schema) -> SchemaPatchCall<'a, C, A> { + self._request = new_value; self } /// Immutable id of the Google Apps account @@ -19794,7 +20116,7 @@ impl<'a, C, A> SchemaPatchCall<'a, C, A> where C: BorrowMut, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.schemas().insert(&req, "customerId") +/// let result = hub.schemas().insert(req, "customerId") /// .doit(); /// # } /// ``` @@ -19922,12 +20244,17 @@ impl<'a, C, A> SchemaInsertCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -19936,7 +20263,7 @@ impl<'a, C, A> SchemaInsertCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -19954,8 +20281,8 @@ impl<'a, C, A> SchemaInsertCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Schema) -> SchemaInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Schema) -> SchemaInsertCall<'a, C, A> { + self._request = new_value; self } /// Immutable id of the Google Apps account @@ -20166,12 +20493,17 @@ impl<'a, C, A> SchemaDeleteCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -20287,7 +20619,7 @@ impl<'a, C, A> SchemaDeleteCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.schemas().update(&req, "customerId", "schemaKey") +/// let result = hub.schemas().update(req, "customerId", "schemaKey") /// .doit(); /// # } /// ``` @@ -20417,12 +20749,17 @@ impl<'a, C, A> SchemaUpdateCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -20431,7 +20768,7 @@ impl<'a, C, A> SchemaUpdateCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -20449,8 +20786,8 @@ impl<'a, C, A> SchemaUpdateCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Schema) -> SchemaUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Schema) -> SchemaUpdateCall<'a, C, A> { + self._request = new_value; self } /// Immutable id of the Google Apps account diff --git a/gen/admin1_reports-cli/Cargo.toml b/gen/admin1_reports-cli/Cargo.toml index 9b3bfa8c59..7e14157d2f 100644 --- a/gen/admin1_reports-cli/Cargo.toml +++ b/gen/admin1_reports-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-admin1_reports-cli" -version = "0.0.1+20150115" +version = "0.1.0+20150115" authors = ["Sebastian Thiel "] description = "A complete library to interact with reports (protocol reports_v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/admin1_reports-cli" diff --git a/gen/admin1_reports-cli/README.md b/gen/admin1_reports-cli/README.md index d63739eb1c..887753e972 100644 --- a/gen/admin1_reports-cli/README.md +++ b/gen/admin1_reports-cli/README.md @@ -1,4 +1,106 @@ -# HELLO ADMIN:REPORTS_V1 + +The `admin1-reports` command-line interface *(CLI)* allows to use most features of the *Google reports* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *reports* API at revision *20150115*. The CLI is at version *0.1.0*. + +```bash + admin1-reports [options] activities list [-p ...] [-o ] + admin1-reports [options] activities watch -r ... [-p ...] [-o ] + admin1-reports [options] channels stop -r ... [-p ...] + admin1-reports [options] customer-usage-reports get [-p ...] [-o ] + admin1-reports [options] user-usage-report get [-p ...] [-o ] + admin1-reports --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_admin1_reports_cli/index.html + +Configuration: + --scope + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `admin1-reports-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/admin1-reports-token-.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/admin1-reports-secret.json`, assuming that the required *admin* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `admin1-reports --debug [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/admin1_reports-cli/mkdocs.yml b/gen/admin1_reports-cli/mkdocs.yml index d5581f072c..5938a8b69f 100644 --- a/gen/admin1_reports-cli/mkdocs.yml +++ b/gen/admin1_reports-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: reports v0.0.1+20150115 +site_name: reports v0.1.0+20150115 site_url: http://byron.github.io/google-apis-rs/google-admin1_reports-cli site_description: Write integrating applications with bcore diff --git a/gen/admin1_reports-cli/src/cmn.rs b/gen/admin1_reports-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/admin1_reports-cli/src/cmn.rs +++ b/gen/admin1_reports-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/admin1_reports-cli/src/main.rs b/gen/admin1_reports-cli/src/main.rs index 1a9fc29c3e..e5669a54ab 100644 --- a/gen/admin1_reports-cli/src/main.rs +++ b/gen/admin1_reports-cli/src/main.rs @@ -19,30 +19,31 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - admin1-reports [options] activities list [-p ]... [-o ] - admin1-reports [options] activities watch -r ... [-p ]... [-o ] - admin1-reports [options] channels stop -r ... [-p ]... - admin1-reports [options] customer-usage-reports get [-p ]... [-o ] - admin1-reports [options] user-usage-report get [-p ]... [-o ] + admin1-reports [options] activities list [-p ...] [-o ] + admin1-reports [options] activities watch -r ... [-p ...] [-o ] + admin1-reports [options] channels stop -r ... [-p ...] + admin1-reports [options] customer-usage-reports get [-p ...] [-o ] + admin1-reports [options] user-usage-report get [-p ...] [-o ] admin1-reports --help -All documentation details can be found TODO: +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_admin1_reports_cli/index.html Configuration: --scope - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -115,6 +116,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -131,8 +135,64 @@ impl Engine { fn _activities_watch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Channel::default(); - let mut call = self.hub.activities().watch(&request, &self.opt.arg_user_key, &self.opt.arg_application_name); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "resource-uri" => { + request.resource_uri = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "resource-id" => { + request.resource_id = Some(value.unwrap_or("").to_string()); + }, + "payload" => { + request.payload = Some(arg_from_str(value.unwrap_or("false"), err, "payload", "boolean")); + }, + "token" => { + request.token = Some(value.unwrap_or("").to_string()); + }, + "params" => { + if request.params.is_none() { + request.params = Some(Default::default()); + } + let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); + request.params.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); + }, + "expiration" => { + request.expiration = Some(value.unwrap_or("").to_string()); + }, + "address" => { + request.address = Some(value.unwrap_or("").to_string()); + }, + "type" => { + request.type_ = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.activities().watch(request, &self.opt.arg_user_key, &self.opt.arg_application_name); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -178,14 +238,48 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _channels_stop(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option { - let mut field_name = FieldCursor::default(); + let mut request = api::Channel::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "resource-uri" => { request.resource_uri = Some(value.unwrap_or("").to_string()); }, @@ -221,33 +315,11 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _channels_stop(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request = api::Channel::default(); - let mut call = self.hub.channels().stop(&request); + let mut call = self.hub.channels().stop(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -269,58 +341,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "resource-uri" => { - request.resource_uri = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "resource-id" => { - request.resource_id = Some(value.unwrap_or("").to_string()); - }, - "payload" => { - request.payload = Some(arg_from_str(value.unwrap_or("false"), err, "payload", "boolean")); - }, - "token" => { - request.token = Some(value.unwrap_or("").to_string()); - }, - "params" => { - if request.params.is_none() { - request.params = Some(Default::default()); - } - let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); - request.params.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); - }, - "expiration" => { - request.expiration = Some(value.unwrap_or("").to_string()); - }, - "address" => { - request.address = Some(value.unwrap_or("").to_string()); - }, - "type" => { - request.type_ = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -371,6 +399,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -429,6 +460,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -545,6 +579,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -552,8 +587,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/admin1_reports/Cargo.toml b/gen/admin1_reports/Cargo.toml index ddbc44d5b1..b425c525c5 100644 --- a/gen/admin1_reports/Cargo.toml +++ b/gen/admin1_reports/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-admin1_reports" -version = "0.1.5+20150115" +version = "0.1.6+20150115" authors = ["Sebastian Thiel "] description = "A complete library to interact with reports (protocol reports_v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/admin1_reports" diff --git a/gen/admin1_reports/README.md b/gen/admin1_reports/README.md index 3fb9cfc084..2095a006ee 100644 --- a/gen/admin1_reports/README.md +++ b/gen/admin1_reports/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-admin1_reports` library allows access to all features of the *Google reports* service. -This documentation was generated from *reports* crate version *0.1.5+20150115*, where *20150115* is the exact revision of the *admin:reports_v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *reports* crate version *0.1.6+20150115*, where *20150115* is the exact revision of the *admin:reports_v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *reports* *v1_reports* API can be found at the [official documentation site](https://developers.google.com/admin-sdk/reports/). @@ -110,7 +110,7 @@ let mut req = Channel::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.activities().watch(&req, "userKey", "applicationName") +let result = hub.activities().watch(req, "userKey", "applicationName") .start_time("Stet") .page_token("sed") .max_results(-85) @@ -125,14 +125,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/admin1_reports/src/cmn.rs b/gen/admin1_reports/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/admin1_reports/src/cmn.rs +++ b/gen/admin1_reports/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option, + location: Option +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option, _: Option) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec]) -> Option { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/admin1_reports/src/lib.rs b/gen/admin1_reports/src/lib.rs index a0965e363d..10bcc6ff2b 100644 --- a/gen/admin1_reports/src/lib.rs +++ b/gen/admin1_reports/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *reports* crate version *0.1.5+20150115*, where *20150115* is the exact revision of the *admin:reports_v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *reports* crate version *0.1.6+20150115*, where *20150115* is the exact revision of the *admin:reports_v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *reports* *v1_reports* API can be found at the //! [official documentation site](https://developers.google.com/admin-sdk/reports/). @@ -111,7 +111,7 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.activities().watch(&req, "userKey", "applicationName") +//! let result = hub.activities().watch(req, "userKey", "applicationName") //! .start_time("labore") //! .page_token("sea") //! .max_results(-90) @@ -126,14 +126,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -221,7 +222,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -298,7 +299,7 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.activities().watch(&req, "userKey", "applicationName") +/// let result = hub.activities().watch(req, "userKey", "applicationName") /// .start_time("justo") /// .page_token("et") /// .max_results(-17) @@ -313,14 +314,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -341,7 +343,7 @@ impl<'a, C, A> Reports Reports { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -359,7 +361,7 @@ impl<'a, C, A> Reports } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -746,10 +748,10 @@ impl<'a, C, A> ChannelMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn stop(&self, request: &Channel) -> ChannelStopCall<'a, C, A> { + pub fn stop(&self, request: Channel) -> ChannelStopCall<'a, C, A> { ChannelStopCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -806,10 +808,10 @@ impl<'a, C, A> ActivityMethods<'a, C, A> { /// * `request` - No description provided. /// * `userKey` - Represents the profile id or the user email for which the data should be filtered. When 'all' is specified as the userKey, it returns usageReports for all users. /// * `applicationName` - Application name for which the events are to be retrieved. - pub fn watch(&self, request: &Channel, user_key: &str, application_name: &str) -> ActivityWatchCall<'a, C, A> { + pub fn watch(&self, request: Channel, user_key: &str, application_name: &str) -> ActivityWatchCall<'a, C, A> { ActivityWatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_key: user_key.to_string(), _application_name: application_name.to_string(), _start_time: Default::default(), @@ -1020,7 +1022,7 @@ impl<'a, C, A> UserUsageReportMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.channels().stop(&req) +/// let result = hub.channels().stop(req) /// .doit(); /// # } /// ``` @@ -1121,12 +1123,17 @@ impl<'a, C, A> ChannelStopCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -1143,8 +1150,8 @@ impl<'a, C, A> ChannelStopCall<'a, C, A> where C: BorrowMut, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Channel) -> ChannelStopCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Channel) -> ChannelStopCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -1231,7 +1238,7 @@ impl<'a, C, A> ChannelStopCall<'a, C, A> where C: BorrowMut, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.activities().watch(&req, "userKey", "applicationName") +/// let result = hub.activities().watch(req, "userKey", "applicationName") /// .start_time("Lorem") /// .page_token("eos") /// .max_results(-81) @@ -1401,12 +1408,17 @@ impl<'a, C, A> ActivityWatchCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1415,7 +1427,7 @@ impl<'a, C, A> ActivityWatchCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1433,8 +1445,8 @@ impl<'a, C, A> ActivityWatchCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Channel) -> ActivityWatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Channel) -> ActivityWatchCall<'a, C, A> { + self._request = new_value; self } /// Represents the profile id or the user email for which the data should be filtered. When 'all' is specified as the userKey, it returns usageReports for all users. @@ -1752,12 +1764,17 @@ impl<'a, C, A> ActivityListCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1766,7 +1783,7 @@ impl<'a, C, A> ActivityListCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2067,12 +2084,17 @@ impl<'a, C, A> CustomerUsageReportGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2081,7 +2103,7 @@ impl<'a, C, A> CustomerUsageReportGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2349,12 +2371,17 @@ impl<'a, C, A> UserUsageReportGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2363,7 +2390,7 @@ impl<'a, C, A> UserUsageReportGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/admin2_email_migration-cli/Cargo.toml b/gen/admin2_email_migration-cli/Cargo.toml index 6f392cb62b..ce83971df5 100644 --- a/gen/admin2_email_migration-cli/Cargo.toml +++ b/gen/admin2_email_migration-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-admin2_email_migration-cli" -version = "0.0.1+20150303" +version = "0.1.0+20150303" authors = ["Sebastian Thiel "] description = "A complete library to interact with admin (protocol email_migration_v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/admin2_email_migration-cli" diff --git a/gen/admin2_email_migration-cli/README.md b/gen/admin2_email_migration-cli/README.md index ed6449c3ab..351436dc4b 100644 --- a/gen/admin2_email_migration-cli/README.md +++ b/gen/admin2_email_migration-cli/README.md @@ -1,4 +1,102 @@ -# HELLO ADMIN:EMAIL_MIGRATION_V2 + +The `admin2-email-migration` command-line interface *(CLI)* allows to use most features of the *Google admin* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *admin* API at revision *20150303*. The CLI is at version *0.1.0*. + +```bash + admin2-email-migration [options] mail insert -r ... -u (simple|resumable) [-p ...] + admin2-email-migration --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_admin2_email_migration_cli/index.html + +Configuration: + --scope + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `admin2-email-migration-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/admin2-email-migration-token-.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/admin2-email-migration-secret.json`, assuming that the required *admin* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `admin2-email-migration --debug [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/admin2_email_migration-cli/mkdocs.yml b/gen/admin2_email_migration-cli/mkdocs.yml index c666938a66..d307c18147 100644 --- a/gen/admin2_email_migration-cli/mkdocs.yml +++ b/gen/admin2_email_migration-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: admin v0.0.1+20150303 +site_name: admin v0.1.0+20150303 site_url: http://byron.github.io/google-apis-rs/google-admin2_email_migration-cli site_description: Write integrating applications with bcore diff --git a/gen/admin2_email_migration-cli/src/cmn.rs b/gen/admin2_email_migration-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/admin2_email_migration-cli/src/cmn.rs +++ b/gen/admin2_email_migration-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/admin2_email_migration-cli/src/main.rs b/gen/admin2_email_migration-cli/src/main.rs index 4fd3d63094..14e5747a4b 100644 --- a/gen/admin2_email_migration-cli/src/main.rs +++ b/gen/admin2_email_migration-cli/src/main.rs @@ -19,26 +19,27 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - admin2-email-migration [options] mail insert -r ... -u (simple|resumable) [-p ]... + admin2-email-migration [options] mail insert -r ... -u (simple|resumable) [-p ...] admin2-email-migration --help -All documentation details can be found TODO: +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_admin2_email_migration_cli/index.html Configuration: --scope - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -60,37 +61,24 @@ struct Engine { impl Engine { fn _mail_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::MailItem::default(); - let mut call = self.hub.mail().insert(&request, &self.opt.arg_user_key); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::MailItem::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "is-trash" => { request.is_trash = Some(arg_from_str(value.unwrap_or("false"), err, "is-trash", "boolean")); }, @@ -122,10 +110,32 @@ impl Engine { request.is_deleted = Some(arg_from_str(value.unwrap_or("false"), err, "is-deleted", "boolean")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.mail().insert(request, &self.opt.arg_user_key); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = if self.opt.cmd_simple { "simple" @@ -140,6 +150,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), "resumable" => call.upload_resumable(input_file.unwrap(), mime_type.unwrap()), @@ -232,6 +245,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -239,8 +253,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/admin2_email_migration/Cargo.toml b/gen/admin2_email_migration/Cargo.toml index 30580a4fa8..0822931c86 100644 --- a/gen/admin2_email_migration/Cargo.toml +++ b/gen/admin2_email_migration/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-admin2_email_migration" -version = "0.1.5+20150303" +version = "0.1.6+20150303" authors = ["Sebastian Thiel "] description = "A complete library to interact with admin (protocol email_migration_v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/admin2_email_migration" diff --git a/gen/admin2_email_migration/README.md b/gen/admin2_email_migration/README.md index 7245e0fcde..a51924c4ab 100644 --- a/gen/admin2_email_migration/README.md +++ b/gen/admin2_email_migration/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-admin2_email_migration` library allows access to all features of the *Google admin* service. -This documentation was generated from *admin* crate version *0.1.5+20150303*, where *20150303* is the exact revision of the *admin:email_migration_v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *admin* crate version *0.1.6+20150303*, where *20150303* is the exact revision of the *admin:email_migration_v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *admin* *v2_email_migration* API can be found at the [official documentation site](https://developers.google.com/admin-sdk/email-migration/v2/). @@ -103,21 +103,22 @@ let mut req = MailItem::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `upload(...)`. // Values shown here are possibly random and not representative ! -let result = hub.mail().insert(&req, "userKey") +let result = hub.mail().insert(req, "userKey") .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/admin2_email_migration/src/cmn.rs b/gen/admin2_email_migration/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/admin2_email_migration/src/cmn.rs +++ b/gen/admin2_email_migration/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option, + location: Option +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option, _: Option) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec]) -> Option { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/admin2_email_migration/src/lib.rs b/gen/admin2_email_migration/src/lib.rs index 1328902964..642f00bc00 100644 --- a/gen/admin2_email_migration/src/lib.rs +++ b/gen/admin2_email_migration/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *admin* crate version *0.1.5+20150303*, where *20150303* is the exact revision of the *admin:email_migration_v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *admin* crate version *0.1.6+20150303*, where *20150303* is the exact revision of the *admin:email_migration_v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *admin* *v2_email_migration* API can be found at the //! [official documentation site](https://developers.google.com/admin-sdk/email-migration/v2/). @@ -104,21 +104,22 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `upload(...)`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.mail().insert(&req, "userKey") +//! let result = hub.mail().insert(req, "userKey") //! .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); //! //! match result { //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -206,7 +207,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -280,21 +281,22 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.mail().insert(&req, "userKey") +/// let result = hub.mail().insert(req, "userKey") /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -315,7 +317,7 @@ impl<'a, C, A> Admin Admin { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -324,7 +326,7 @@ impl<'a, C, A> Admin } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -430,10 +432,10 @@ impl<'a, C, A> MailMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `userKey` - The email or immutable id of the user - pub fn insert(&self, request: &MailItem, user_key: &str) -> MailInsertCall<'a, C, A> { + pub fn insert(&self, request: MailItem, user_key: &str) -> MailInsertCall<'a, C, A> { MailInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_key: user_key.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -483,7 +485,7 @@ impl<'a, C, A> MailMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.mail().insert(&req, "userKey") +/// let result = hub.mail().insert(req, "userKey") /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } /// ``` @@ -528,14 +530,15 @@ impl<'a, C, A> MailInsertCall<'a, C, A> where C: BorrowMut, A: oa } - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/email/v2/users/{userKey}/mail".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/email/v2/users/{userKey}/mail".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/email/v2/users/{userKey}/mail".to_string() + ("https://www.googleapis.com/resumable/upload/email/v2/users/{userKey}/mail".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::EmailMigration.as_ref().to_string(), ()); } @@ -654,12 +657,17 @@ impl<'a, C, A> MailInsertCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -669,9 +677,9 @@ impl<'a, C, A> MailInsertCall<'a, C, A> where C: BorrowMut, A: oa } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -681,7 +689,7 @@ impl<'a, C, A> MailInsertCall<'a, C, A> where C: BorrowMut, A: oa auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -746,8 +754,8 @@ impl<'a, C, A> MailInsertCall<'a, C, A> where C: BorrowMut, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &MailItem) -> MailInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: MailItem) -> MailInsertCall<'a, C, A> { + self._request = new_value; self } /// The email or immutable id of the user diff --git a/gen/adsense1d4-cli/Cargo.toml b/gen/adsense1d4-cli/Cargo.toml index 0aeb9b4e39..7538769d4e 100644 --- a/gen/adsense1d4-cli/Cargo.toml +++ b/gen/adsense1d4-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-adsense1d4-cli" -version = "0.0.1+20150326" +version = "0.1.0+20150326" authors = ["Sebastian Thiel "] description = "A complete library to interact with AdSense (protocol v1.4)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/adsense1d4-cli" diff --git a/gen/adsense1d4-cli/README.md b/gen/adsense1d4-cli/README.md index 053e3832cd..c12646f482 100644 --- a/gen/adsense1d4-cli/README.md +++ b/gen/adsense1d4-cli/README.md @@ -1,4 +1,139 @@ -# HELLO ADSENSE:V1.4 + +The `adsense1d4` command-line interface *(CLI)* allows to use most features of the *Google AdSense* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *AdSense* API at revision *20150326*. The CLI is at version *0.1.0*. + +```bash + adsense1d4 [options] accounts adclients-list [-p ...] [-o ] + adsense1d4 [options] accounts adunits-customchannels-list [-p ...] [-o ] + adsense1d4 [options] accounts adunits-get [-p ...] [-o ] + adsense1d4 [options] accounts adunits-get-ad-code [-p ...] [-o ] + adsense1d4 [options] accounts adunits-list [-p ...] [-o ] + adsense1d4 [options] accounts alerts-delete [-p ...] + adsense1d4 [options] accounts alerts-list [-p ...] [-o ] + adsense1d4 [options] accounts customchannels-adunits-list [-p ...] [-o ] + adsense1d4 [options] accounts customchannels-get [-p ...] [-o ] + adsense1d4 [options] accounts customchannels-list [-p ...] [-o ] + adsense1d4 [options] accounts get [-p ...] [-o ] + adsense1d4 [options] accounts list [-p ...] [-o ] + adsense1d4 [options] accounts payments-list [-p ...] [-o ] + adsense1d4 [options] accounts reports-generate [-p ...] [-o ] + adsense1d4 [options] accounts reports-saved-generate [-p ...] [-o ] + adsense1d4 [options] accounts reports-saved-list [-p ...] [-o ] + adsense1d4 [options] accounts savedadstyles-get [-p ...] [-o ] + adsense1d4 [options] accounts savedadstyles-list [-p ...] [-o ] + adsense1d4 [options] accounts urlchannels-list [-p ...] [-o ] + adsense1d4 [options] adclients list [-p ...] [-o ] + adsense1d4 [options] adunits customchannels-list [-p ...] [-o ] + adsense1d4 [options] adunits get [-p ...] [-o ] + adsense1d4 [options] adunits get-ad-code [-p ...] [-o ] + adsense1d4 [options] adunits list [-p ...] [-o ] + adsense1d4 [options] alerts delete [-p ...] + adsense1d4 [options] alerts list [-p ...] [-o ] + adsense1d4 [options] customchannels adunits-list [-p ...] [-o ] + adsense1d4 [options] customchannels get [-p ...] [-o ] + adsense1d4 [options] customchannels list [-p ...] [-o ] + adsense1d4 [options] metadata dimensions-list [-p ...] [-o ] + adsense1d4 [options] metadata metrics-list [-p ...] [-o ] + adsense1d4 [options] payments list [-p ...] [-o ] + adsense1d4 [options] reports generate [-p ...] [-o ] + adsense1d4 [options] reports saved-generate [-p ...] [-o ] + adsense1d4 [options] reports saved-list [-p ...] [-o ] + adsense1d4 [options] savedadstyles get [-p ...] [-o ] + adsense1d4 [options] savedadstyles list [-p ...] [-o ] + adsense1d4 [options] urlchannels list [-p ...] [-o ] + adsense1d4 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_adsense1d4_cli/index.html + +Configuration: + --scope + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `adsense1d4-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/adsense1d4-token-.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/adsense1d4-secret.json`, assuming that the required *adsense* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `adsense1d4 --debug [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/adsense1d4-cli/mkdocs.yml b/gen/adsense1d4-cli/mkdocs.yml index ae9d468ece..5cae7da908 100644 --- a/gen/adsense1d4-cli/mkdocs.yml +++ b/gen/adsense1d4-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: AdSense v0.0.1+20150326 +site_name: AdSense v0.1.0+20150326 site_url: http://byron.github.io/google-apis-rs/google-adsense1d4-cli site_description: Write integrating applications with bcore diff --git a/gen/adsense1d4-cli/src/cmn.rs b/gen/adsense1d4-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/adsense1d4-cli/src/cmn.rs +++ b/gen/adsense1d4-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/adsense1d4-cli/src/main.rs b/gen/adsense1d4-cli/src/main.rs index da6280de6f..413efdcdce 100644 --- a/gen/adsense1d4-cli/src/main.rs +++ b/gen/adsense1d4-cli/src/main.rs @@ -19,63 +19,64 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - adsense1d4 [options] accounts adclients-list [-p ]... [-o ] - adsense1d4 [options] accounts adunits-customchannels-list [-p ]... [-o ] - adsense1d4 [options] accounts adunits-get [-p ]... [-o ] - adsense1d4 [options] accounts adunits-get-ad-code [-p ]... [-o ] - adsense1d4 [options] accounts adunits-list [-p ]... [-o ] - adsense1d4 [options] accounts alerts-delete [-p ]... - adsense1d4 [options] accounts alerts-list [-p ]... [-o ] - adsense1d4 [options] accounts customchannels-adunits-list [-p ]... [-o ] - adsense1d4 [options] accounts customchannels-get [-p ]... [-o ] - adsense1d4 [options] accounts customchannels-list [-p ]... [-o ] - adsense1d4 [options] accounts get [-p ]... [-o ] - adsense1d4 [options] accounts list [-p ]... [-o ] - adsense1d4 [options] accounts payments-list [-p ]... [-o ] - adsense1d4 [options] accounts reports-generate [-p ]... [-o ] - adsense1d4 [options] accounts reports-saved-generate [-p ]... [-o ] - adsense1d4 [options] accounts reports-saved-list [-p ]... [-o ] - adsense1d4 [options] accounts savedadstyles-get [-p ]... [-o ] - adsense1d4 [options] accounts savedadstyles-list [-p ]... [-o ] - adsense1d4 [options] accounts urlchannels-list [-p ]... [-o ] - adsense1d4 [options] adclients list [-p ]... [-o ] - adsense1d4 [options] adunits customchannels-list [-p ]... [-o ] - adsense1d4 [options] adunits get [-p ]... [-o ] - adsense1d4 [options] adunits get-ad-code [-p ]... [-o ] - adsense1d4 [options] adunits list [-p ]... [-o ] - adsense1d4 [options] alerts delete [-p ]... - adsense1d4 [options] alerts list [-p ]... [-o ] - adsense1d4 [options] customchannels adunits-list [-p ]... [-o ] - adsense1d4 [options] customchannels get [-p ]... [-o ] - adsense1d4 [options] customchannels list [-p ]... [-o ] - adsense1d4 [options] metadata dimensions-list [-p ]... [-o ] - adsense1d4 [options] metadata metrics-list [-p ]... [-o ] - adsense1d4 [options] payments list [-p ]... [-o ] - adsense1d4 [options] reports generate [-p ]... [-o ] - adsense1d4 [options] reports saved-generate [-p ]... [-o ] - adsense1d4 [options] reports saved-list [-p ]... [-o ] - adsense1d4 [options] savedadstyles get [-p ]... [-o ] - adsense1d4 [options] savedadstyles list [-p ]... [-o ] - adsense1d4 [options] urlchannels list [-p ]... [-o ] + adsense1d4 [options] accounts adclients-list [-p ...] [-o ] + adsense1d4 [options] accounts adunits-customchannels-list [-p ...] [-o ] + adsense1d4 [options] accounts adunits-get [-p ...] [-o ] + adsense1d4 [options] accounts adunits-get-ad-code [-p ...] [-o ] + adsense1d4 [options] accounts adunits-list [-p ...] [-o ] + adsense1d4 [options] accounts alerts-delete [-p ...] + adsense1d4 [options] accounts alerts-list [-p ...] [-o ] + adsense1d4 [options] accounts customchannels-adunits-list [-p ...] [-o ] + adsense1d4 [options] accounts customchannels-get [-p ...] [-o ] + adsense1d4 [options] accounts customchannels-list [-p ...] [-o ] + adsense1d4 [options] accounts get [-p ...] [-o ] + adsense1d4 [options] accounts list [-p ...] [-o ] + adsense1d4 [options] accounts payments-list [-p ...] [-o ] + adsense1d4 [options] accounts reports-generate [-p ...] [-o ] + adsense1d4 [options] accounts reports-saved-generate [-p ...] [-o ] + adsense1d4 [options] accounts reports-saved-list [-p ...] [-o ] + adsense1d4 [options] accounts savedadstyles-get [-p ...] [-o ] + adsense1d4 [options] accounts savedadstyles-list [-p ...] [-o ] + adsense1d4 [options] accounts urlchannels-list [-p ...] [-o ] + adsense1d4 [options] adclients list [-p ...] [-o ] + adsense1d4 [options] adunits customchannels-list [-p ...] [-o ] + adsense1d4 [options] adunits get [-p ...] [-o ] + adsense1d4 [options] adunits get-ad-code [-p ...] [-o ] + adsense1d4 [options] adunits list [-p ...] [-o ] + adsense1d4 [options] alerts delete [-p ...] + adsense1d4 [options] alerts list [-p ...] [-o ] + adsense1d4 [options] customchannels adunits-list [-p ...] [-o ] + adsense1d4 [options] customchannels get [-p ...] [-o ] + adsense1d4 [options] customchannels list [-p ...] [-o ] + adsense1d4 [options] metadata dimensions-list [-p ...] [-o ] + adsense1d4 [options] metadata metrics-list [-p ...] [-o ] + adsense1d4 [options] payments list [-p ...] [-o ] + adsense1d4 [options] reports generate [-p ...] [-o ] + adsense1d4 [options] reports saved-generate [-p ...] [-o ] + adsense1d4 [options] reports saved-list [-p ...] [-o ] + adsense1d4 [options] savedadstyles get [-p ...] [-o ] + adsense1d4 [options] savedadstyles list [-p ...] [-o ] + adsense1d4 [options] urlchannels list [-p ...] [-o ] adsense1d4 --help -All documentation details can be found TODO: +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_adsense1d4_cli/index.html Configuration: --scope - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -130,6 +131,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -179,6 +183,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -222,6 +229,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -265,6 +275,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -317,6 +330,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -360,6 +376,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -404,6 +423,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -456,6 +478,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -499,6 +524,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -548,6 +576,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -594,6 +625,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -643,6 +677,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -686,6 +723,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -760,6 +800,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -816,6 +859,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -865,6 +911,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -908,6 +957,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -957,6 +1009,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1006,6 +1061,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1055,6 +1113,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1104,6 +1165,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1147,6 +1211,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1190,6 +1257,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1242,6 +1312,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1285,6 +1358,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1329,6 +1405,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1381,6 +1460,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1424,6 +1506,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1473,6 +1558,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1516,6 +1604,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1559,6 +1650,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1602,6 +1696,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1679,6 +1776,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1735,6 +1835,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1784,6 +1887,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1827,6 +1933,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1876,6 +1985,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1925,6 +2037,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2137,6 +2252,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -2144,8 +2260,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/adsense1d4/Cargo.toml b/gen/adsense1d4/Cargo.toml index 494ec452d3..a0772201e8 100644 --- a/gen/adsense1d4/Cargo.toml +++ b/gen/adsense1d4/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-adsense1d4" -version = "0.1.5+20150326" +version = "0.1.6+20150326" authors = ["Sebastian Thiel "] description = "A complete library to interact with AdSense (protocol v1.4)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/adsense1d4" diff --git a/gen/adsense1d4/README.md b/gen/adsense1d4/README.md index a707920a8c..d66bb2f058 100644 --- a/gen/adsense1d4/README.md +++ b/gen/adsense1d4/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-adsense1d4` library allows access to all features of the *Google AdSense* service. -This documentation was generated from *AdSense* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *adsense:v1.4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *AdSense* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *adsense:v1.4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *AdSense* *v1d4* API can be found at the [official documentation site](https://developers.google.com/adsense/management/). @@ -149,14 +149,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/adsense1d4/src/cmn.rs b/gen/adsense1d4/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/adsense1d4/src/cmn.rs +++ b/gen/adsense1d4/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option, + location: Option +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option, _: Option) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec]) -> Option { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/adsense1d4/src/lib.rs b/gen/adsense1d4/src/lib.rs index 6cd8a08cf9..0144ca66d2 100644 --- a/gen/adsense1d4/src/lib.rs +++ b/gen/adsense1d4/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *AdSense* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *adsense:v1.4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *AdSense* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *adsense:v1.4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *AdSense* *v1d4* API can be found at the //! [official documentation site](https://developers.google.com/adsense/management/). @@ -150,14 +150,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -245,7 +246,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -332,14 +333,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -360,7 +362,7 @@ impl<'a, C, A> AdSense AdSense { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -396,7 +398,7 @@ impl<'a, C, A> AdSense } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -2503,12 +2505,17 @@ impl<'a, C, A> UrlchannelListCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2517,7 +2524,7 @@ impl<'a, C, A> UrlchannelListCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2763,12 +2770,17 @@ impl<'a, C, A> AdunitCustomchannelListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2777,7 +2789,7 @@ impl<'a, C, A> AdunitCustomchannelListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3023,12 +3035,17 @@ impl<'a, C, A> AdunitGetCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3037,7 +3054,7 @@ impl<'a, C, A> AdunitGetCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3282,12 +3299,17 @@ impl<'a, C, A> AdunitListCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3296,7 +3318,7 @@ impl<'a, C, A> AdunitListCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3539,12 +3561,17 @@ impl<'a, C, A> AdunitGetAdCodeCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3553,7 +3580,7 @@ impl<'a, C, A> AdunitGetAdCodeCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3767,12 +3794,17 @@ impl<'a, C, A> AdclientListCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3781,7 +3813,7 @@ impl<'a, C, A> AdclientListCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4004,12 +4036,17 @@ impl<'a, C, A> AlertDeleteCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -4207,12 +4244,17 @@ impl<'a, C, A> AlertListCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4221,7 +4263,7 @@ impl<'a, C, A> AlertListCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4422,12 +4464,17 @@ impl<'a, C, A> SavedadstyleListCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4436,7 +4483,7 @@ impl<'a, C, A> SavedadstyleListCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4660,12 +4707,17 @@ impl<'a, C, A> SavedadstyleGetCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4674,7 +4726,7 @@ impl<'a, C, A> SavedadstyleGetCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4878,12 +4930,17 @@ impl<'a, C, A> ReportSavedListCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4892,7 +4949,7 @@ impl<'a, C, A> ReportSavedListCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5185,12 +5242,17 @@ impl<'a, C, A> ReportGenerateCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = if enable_resource_parsing { let mut json_response = String::new(); @@ -5199,7 +5261,7 @@ impl<'a, C, A> ReportGenerateCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } } else { (res, Default::default()) }; @@ -5519,12 +5581,17 @@ impl<'a, C, A> ReportSavedGenerateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5533,7 +5600,7 @@ impl<'a, C, A> ReportSavedGenerateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5775,12 +5842,17 @@ impl<'a, C, A> AccountAlertDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -6014,12 +6086,17 @@ impl<'a, C, A> AccountAlertListCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6028,7 +6105,7 @@ impl<'a, C, A> AccountAlertListCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6272,12 +6349,17 @@ impl<'a, C, A> AccountReportSavedGenerateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6286,7 +6368,7 @@ impl<'a, C, A> AccountReportSavedGenerateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6521,12 +6603,17 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6535,7 +6622,7 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6759,12 +6846,17 @@ impl<'a, C, A> AccountPaymentListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6773,7 +6865,7 @@ impl<'a, C, A> AccountPaymentListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6995,12 +7087,17 @@ impl<'a, C, A> AccountSavedadstyleGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7009,7 +7106,7 @@ impl<'a, C, A> AccountSavedadstyleGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7243,12 +7340,17 @@ impl<'a, C, A> AccountAdunitGetCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7257,7 +7359,7 @@ impl<'a, C, A> AccountAdunitGetCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7501,12 +7603,17 @@ impl<'a, C, A> AccountCustomchannelGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7515,7 +7622,7 @@ impl<'a, C, A> AccountCustomchannelGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7774,12 +7881,17 @@ impl<'a, C, A> AccountCustomchannelAdunitListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7788,7 +7900,7 @@ impl<'a, C, A> AccountCustomchannelAdunitListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8059,12 +8171,17 @@ impl<'a, C, A> AccountReportSavedListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8073,7 +8190,7 @@ impl<'a, C, A> AccountReportSavedListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8319,12 +8436,17 @@ impl<'a, C, A> AccountUrlchannelListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8333,7 +8455,7 @@ impl<'a, C, A> AccountUrlchannelListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8594,12 +8716,17 @@ impl<'a, C, A> AccountAdunitListCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8608,7 +8735,7 @@ impl<'a, C, A> AccountAdunitListCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8945,12 +9072,17 @@ impl<'a, C, A> AccountReportGenerateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = if enable_resource_parsing { let mut json_response = String::new(); @@ -8959,7 +9091,7 @@ impl<'a, C, A> AccountReportGenerateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } } else { (res, Default::default()) }; @@ -9276,12 +9408,17 @@ impl<'a, C, A> AccountAdclientListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9290,7 +9427,7 @@ impl<'a, C, A> AccountAdclientListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9536,12 +9673,17 @@ impl<'a, C, A> AccountCustomchannelListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9550,7 +9692,7 @@ impl<'a, C, A> AccountCustomchannelListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9804,12 +9946,17 @@ impl<'a, C, A> AccountSavedadstyleListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9818,7 +9965,7 @@ impl<'a, C, A> AccountSavedadstyleListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10056,12 +10203,17 @@ impl<'a, C, A> AccountAdunitGetAdCodeCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10070,7 +10222,7 @@ impl<'a, C, A> AccountAdunitGetAdCodeCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10324,12 +10476,17 @@ impl<'a, C, A> AccountAdunitCustomchannelListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10338,7 +10495,7 @@ impl<'a, C, A> AccountAdunitCustomchannelListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10597,12 +10754,17 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10611,7 +10773,7 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10812,12 +10974,17 @@ impl<'a, C, A> PaymentListCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10826,7 +10993,7 @@ impl<'a, C, A> PaymentListCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11010,12 +11177,17 @@ impl<'a, C, A> MetadataDimensionListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11024,7 +11196,7 @@ impl<'a, C, A> MetadataDimensionListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11208,12 +11380,17 @@ impl<'a, C, A> MetadataMetricListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11222,7 +11399,7 @@ impl<'a, C, A> MetadataMetricListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11434,12 +11611,17 @@ impl<'a, C, A> CustomchannelGetCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11448,7 +11630,7 @@ impl<'a, C, A> CustomchannelGetCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11688,12 +11870,17 @@ impl<'a, C, A> CustomchannelListCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11702,7 +11889,7 @@ impl<'a, C, A> CustomchannelListCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11953,12 +12140,17 @@ impl<'a, C, A> CustomchannelAdunitListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11967,7 +12159,7 @@ impl<'a, C, A> CustomchannelAdunitListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/adsensehost4d1-cli/Cargo.toml b/gen/adsensehost4d1-cli/Cargo.toml index 5a681acc51..51fbd8e122 100644 --- a/gen/adsensehost4d1-cli/Cargo.toml +++ b/gen/adsensehost4d1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-adsensehost4d1-cli" -version = "0.0.1+20150307" +version = "0.1.0+20150307" authors = ["Sebastian Thiel "] description = "A complete library to interact with AdSense Host (protocol v4.1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/adsensehost4d1-cli" diff --git a/gen/adsensehost4d1-cli/README.md b/gen/adsensehost4d1-cli/README.md index cc58d0fdf2..a6488ce9f5 100644 --- a/gen/adsensehost4d1-cli/README.md +++ b/gen/adsensehost4d1-cli/README.md @@ -1,4 +1,127 @@ -# HELLO ADSENSEHOST:V4.1 + +The `adsensehost4d1` command-line interface *(CLI)* allows to use most features of the *Google AdSense Host* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *AdSense Host* API at revision *20150307*. The CLI is at version *0.1.0*. + +```bash + adsensehost4d1 [options] accounts adclients-get [-p ...] [-o ] + adsensehost4d1 [options] accounts adclients-list [-p ...] [-o ] + adsensehost4d1 [options] accounts adunits-delete [-p ...] [-o ] + adsensehost4d1 [options] accounts adunits-get [-p ...] [-o ] + adsensehost4d1 [options] accounts adunits-get-ad-code [-p ...] [-o ] + adsensehost4d1 [options] accounts adunits-insert -r ... [-p ...] [-o ] + adsensehost4d1 [options] accounts adunits-list [-p ...] [-o ] + adsensehost4d1 [options] accounts adunits-patch -r ... [-p ...] [-o ] + adsensehost4d1 [options] accounts adunits-update -r ... [-p ...] [-o ] + adsensehost4d1 [options] accounts get [-p ...] [-o ] + adsensehost4d1 [options] accounts list ... [-p ...] [-o ] + adsensehost4d1 [options] accounts reports-generate [-p ...] [-o ] + adsensehost4d1 [options] adclients get [-p ...] [-o ] + adsensehost4d1 [options] adclients list [-p ...] [-o ] + adsensehost4d1 [options] associationsessions start ... [-p ...] [-o ] + adsensehost4d1 [options] associationsessions verify [-p ...] [-o ] + adsensehost4d1 [options] customchannels delete [-p ...] [-o ] + adsensehost4d1 [options] customchannels get [-p ...] [-o ] + adsensehost4d1 [options] customchannels insert -r ... [-p ...] [-o ] + adsensehost4d1 [options] customchannels list [-p ...] [-o ] + adsensehost4d1 [options] customchannels patch -r ... [-p ...] [-o ] + adsensehost4d1 [options] customchannels update -r ... [-p ...] [-o ] + adsensehost4d1 [options] reports generate [-p ...] [-o ] + adsensehost4d1 [options] urlchannels delete [-p ...] [-o ] + adsensehost4d1 [options] urlchannels insert -r ... [-p ...] [-o ] + adsensehost4d1 [options] urlchannels list [-p ...] [-o ] + adsensehost4d1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_adsensehost4d1_cli/index.html + +Configuration: + --scope + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `adsensehost4d1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/adsensehost4d1-token-.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/adsensehost4d1-secret.json`, assuming that the required *adsensehost* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `adsensehost4d1 --debug [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/adsensehost4d1-cli/mkdocs.yml b/gen/adsensehost4d1-cli/mkdocs.yml index d9d584d6d6..ce5a1ae27c 100644 --- a/gen/adsensehost4d1-cli/mkdocs.yml +++ b/gen/adsensehost4d1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: AdSense Host v0.0.1+20150307 +site_name: AdSense Host v0.1.0+20150307 site_url: http://byron.github.io/google-apis-rs/google-adsensehost4d1-cli site_description: Write integrating applications with bcore diff --git a/gen/adsensehost4d1-cli/src/cmn.rs b/gen/adsensehost4d1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/adsensehost4d1-cli/src/cmn.rs +++ b/gen/adsensehost4d1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/adsensehost4d1-cli/src/main.rs b/gen/adsensehost4d1-cli/src/main.rs index 4ec6a5dfc3..575e9c2697 100644 --- a/gen/adsensehost4d1-cli/src/main.rs +++ b/gen/adsensehost4d1-cli/src/main.rs @@ -19,51 +19,52 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - adsensehost4d1 [options] accounts adclients-get [-p ]... [-o ] - adsensehost4d1 [options] accounts adclients-list [-p ]... [-o ] - adsensehost4d1 [options] accounts adunits-delete [-p ]... [-o ] - adsensehost4d1 [options] accounts adunits-get [-p ]... [-o ] - adsensehost4d1 [options] accounts adunits-get-ad-code [-p ]... [-o ] - adsensehost4d1 [options] accounts adunits-insert -r ... [-p ]... [-o ] - adsensehost4d1 [options] accounts adunits-list [-p ]... [-o ] - adsensehost4d1 [options] accounts adunits-patch -r ... [-p ]... [-o ] - adsensehost4d1 [options] accounts adunits-update -r ... [-p ]... [-o ] - adsensehost4d1 [options] accounts get [-p ]... [-o ] - adsensehost4d1 [options] accounts list ... [-p ]... [-o ] - adsensehost4d1 [options] accounts reports-generate [-p ]... [-o ] - adsensehost4d1 [options] adclients get [-p ]... [-o ] - adsensehost4d1 [options] adclients list [-p ]... [-o ] - adsensehost4d1 [options] associationsessions start ... [-p ]... [-o ] - adsensehost4d1 [options] associationsessions verify [-p ]... [-o ] - adsensehost4d1 [options] customchannels delete [-p ]... [-o ] - adsensehost4d1 [options] customchannels get [-p ]... [-o ] - adsensehost4d1 [options] customchannels insert -r ... [-p ]... [-o ] - adsensehost4d1 [options] customchannels list [-p ]... [-o ] - adsensehost4d1 [options] customchannels patch -r ... [-p ]... [-o ] - adsensehost4d1 [options] customchannels update -r ... [-p ]... [-o ] - adsensehost4d1 [options] reports generate [-p ]... [-o ] - adsensehost4d1 [options] urlchannels delete [-p ]... [-o ] - adsensehost4d1 [options] urlchannels insert -r ... [-p ]... [-o ] - adsensehost4d1 [options] urlchannels list [-p ]... [-o ] + adsensehost4d1 [options] accounts adclients-get [-p ...] [-o ] + adsensehost4d1 [options] accounts adclients-list [-p ...] [-o ] + adsensehost4d1 [options] accounts adunits-delete [-p ...] [-o ] + adsensehost4d1 [options] accounts adunits-get [-p ...] [-o ] + adsensehost4d1 [options] accounts adunits-get-ad-code [-p ...] [-o ] + adsensehost4d1 [options] accounts adunits-insert -r ... [-p ...] [-o ] + adsensehost4d1 [options] accounts adunits-list [-p ...] [-o ] + adsensehost4d1 [options] accounts adunits-patch -r ... [-p ...] [-o ] + adsensehost4d1 [options] accounts adunits-update -r ... [-p ...] [-o ] + adsensehost4d1 [options] accounts get [-p ...] [-o ] + adsensehost4d1 [options] accounts list ... [-p ...] [-o ] + adsensehost4d1 [options] accounts reports-generate [-p ...] [-o ] + adsensehost4d1 [options] adclients get [-p ...] [-o ] + adsensehost4d1 [options] adclients list [-p ...] [-o ] + adsensehost4d1 [options] associationsessions start ... [-p ...] [-o ] + adsensehost4d1 [options] associationsessions verify [-p ...] [-o ] + adsensehost4d1 [options] customchannels delete [-p ...] [-o ] + adsensehost4d1 [options] customchannels get [-p ...] [-o ] + adsensehost4d1 [options] customchannels insert -r ... [-p ...] [-o ] + adsensehost4d1 [options] customchannels list [-p ...] [-o ] + adsensehost4d1 [options] customchannels patch -r ... [-p ...] [-o ] + adsensehost4d1 [options] customchannels update -r ... [-p ...] [-o ] + adsensehost4d1 [options] reports generate [-p ...] [-o ] + adsensehost4d1 [options] urlchannels delete [-p ...] [-o ] + adsensehost4d1 [options] urlchannels insert -r ... [-p ...] [-o ] + adsensehost4d1 [options] urlchannels list [-p ...] [-o ] adsensehost4d1 --help -All documentation details can be found TODO: +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_adsensehost4d1_cli/index.html Configuration: --scope - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -112,6 +113,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -161,6 +165,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -204,6 +211,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -247,6 +257,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -293,6 +306,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -309,36 +325,23 @@ impl Engine { fn _accounts_adunits_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::AdUnit::default(); - let mut call = self.hub.accounts().adunits_insert(&request, &self.opt.arg_account_id, &self.opt.arg_ad_client_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::AdUnit::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_content_ads_settings_backup_option_init(request: &mut api::AdUnit) { request_content_ads_settings_init(request); if request.content_ads_settings.as_mut().unwrap().backup_option.is_none() { @@ -378,7 +381,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -468,15 +471,40 @@ impl Engine { request.custom_style.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.accounts().adunits_insert(request, &self.opt.arg_account_id, &self.opt.arg_ad_client_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -529,6 +557,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -545,36 +576,23 @@ impl Engine { fn _accounts_adunits_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::AdUnit::default(); - let mut call = self.hub.accounts().adunits_patch(&request, &self.opt.arg_account_id, &self.opt.arg_ad_client_id, &self.opt.arg_ad_unit_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::AdUnit::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_content_ads_settings_backup_option_init(request: &mut api::AdUnit) { request_content_ads_settings_init(request); if request.content_ads_settings.as_mut().unwrap().backup_option.is_none() { @@ -614,7 +632,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -704,15 +722,40 @@ impl Engine { request.custom_style.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.accounts().adunits_patch(request, &self.opt.arg_account_id, &self.opt.arg_ad_client_id, &self.opt.arg_ad_unit_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -729,36 +772,23 @@ impl Engine { fn _accounts_adunits_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::AdUnit::default(); - let mut call = self.hub.accounts().adunits_update(&request, &self.opt.arg_account_id, &self.opt.arg_ad_client_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::AdUnit::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_content_ads_settings_backup_option_init(request: &mut api::AdUnit) { request_content_ads_settings_init(request); if request.content_ads_settings.as_mut().unwrap().backup_option.is_none() { @@ -798,7 +828,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -888,15 +918,40 @@ impl Engine { request.custom_style.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.accounts().adunits_update(request, &self.opt.arg_account_id, &self.opt.arg_ad_client_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -940,6 +995,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -983,6 +1041,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1047,6 +1108,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1090,6 +1154,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1139,6 +1206,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1188,6 +1258,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1231,6 +1304,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1274,6 +1350,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1317,6 +1396,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1333,8 +1415,42 @@ impl Engine { fn _customchannels_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::CustomChannel::default(); - let mut call = self.hub.customchannels().insert(&request, &self.opt.arg_ad_client_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "code" => { + request.code = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.customchannels().insert(request, &self.opt.arg_ad_client_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1356,36 +1472,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "code" => { - request.code = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1435,6 +1529,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1451,8 +1548,42 @@ impl Engine { fn _customchannels_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::CustomChannel::default(); - let mut call = self.hub.customchannels().patch(&request, &self.opt.arg_ad_client_id, &self.opt.arg_custom_channel_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "code" => { + request.code = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.customchannels().patch(request, &self.opt.arg_ad_client_id, &self.opt.arg_custom_channel_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1474,36 +1605,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "code" => { - request.code = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1520,8 +1629,42 @@ impl Engine { fn _customchannels_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::CustomChannel::default(); - let mut call = self.hub.customchannels().update(&request, &self.opt.arg_ad_client_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "code" => { + request.code = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.customchannels().update(request, &self.opt.arg_ad_client_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1543,36 +1686,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "code" => { - request.code = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1637,6 +1758,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1680,6 +1804,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1696,8 +1823,39 @@ impl Engine { fn _urlchannels_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::UrlChannel::default(); - let mut call = self.hub.urlchannels().insert(&request, &self.opt.arg_ad_client_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "url-pattern" => { + request.url_pattern = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.urlchannels().insert(request, &self.opt.arg_ad_client_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1719,33 +1877,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "url-pattern" => { - request.url_pattern = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1795,6 +1934,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1963,6 +2105,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -1970,8 +2113,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/adsensehost4d1/Cargo.toml b/gen/adsensehost4d1/Cargo.toml index c9ff5ea58d..7256b4aab0 100644 --- a/gen/adsensehost4d1/Cargo.toml +++ b/gen/adsensehost4d1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-adsensehost4d1" -version = "0.1.5+20150307" +version = "0.1.6+20150307" authors = ["Sebastian Thiel "] description = "A complete library to interact with AdSense Host (protocol v4.1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/adsensehost4d1" diff --git a/gen/adsensehost4d1/README.md b/gen/adsensehost4d1/README.md index 99c90bc8f0..598a745ace 100644 --- a/gen/adsensehost4d1/README.md +++ b/gen/adsensehost4d1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-adsensehost4d1` library allows access to all features of the *Google AdSense Host* service. -This documentation was generated from *AdSense Host* crate version *0.1.5+20150307*, where *20150307* is the exact revision of the *adsensehost:v4.1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *AdSense Host* crate version *0.1.6+20150307*, where *20150307* is the exact revision of the *adsensehost:v4.1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *AdSense Host* *v4d1* API can be found at the [official documentation site](https://developers.google.com/adsense/host/). @@ -127,14 +127,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/adsensehost4d1/src/cmn.rs b/gen/adsensehost4d1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/adsensehost4d1/src/cmn.rs +++ b/gen/adsensehost4d1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option, + location: Option +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option, _: Option) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec]) -> Option { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/adsensehost4d1/src/lib.rs b/gen/adsensehost4d1/src/lib.rs index 3d6a6d5da7..d54e075600 100644 --- a/gen/adsensehost4d1/src/lib.rs +++ b/gen/adsensehost4d1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *AdSense Host* crate version *0.1.5+20150307*, where *20150307* is the exact revision of the *adsensehost:v4.1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *AdSense Host* crate version *0.1.6+20150307*, where *20150307* is the exact revision of the *adsensehost:v4.1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *AdSense Host* *v4d1* API can be found at the //! [official documentation site](https://developers.google.com/adsense/host/). @@ -128,14 +128,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -223,7 +224,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -304,14 +305,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -332,7 +334,7 @@ impl<'a, C, A> AdSenseHost AdSenseHost { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -356,7 +358,7 @@ impl<'a, C, A> AdSenseHost } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -946,10 +948,10 @@ impl<'a, C, A> UrlchannelMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `adClientId` - Ad client to which the new URL channel will be added. - pub fn insert(&self, request: &UrlChannel, ad_client_id: &str) -> UrlchannelInsertCall<'a, C, A> { + pub fn insert(&self, request: UrlChannel, ad_client_id: &str) -> UrlchannelInsertCall<'a, C, A> { UrlchannelInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _ad_client_id: ad_client_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1393,10 +1395,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// * `accountId` - Account which contains the ad client. /// * `adClientId` - Ad client which contains the ad unit. /// * `adUnitId` - Ad unit to get. - pub fn adunits_patch(&self, request: &AdUnit, account_id: &str, ad_client_id: &str, ad_unit_id: &str) -> AccountAdunitPatchCall<'a, C, A> { + pub fn adunits_patch(&self, request: AdUnit, account_id: &str, ad_client_id: &str, ad_unit_id: &str) -> AccountAdunitPatchCall<'a, C, A> { AccountAdunitPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _ad_client_id: ad_client_id.to_string(), _ad_unit_id: ad_unit_id.to_string(), @@ -1451,10 +1453,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// * `request` - No description provided. /// * `accountId` - Account which will contain the ad unit. /// * `adClientId` - Ad client into which to insert the ad unit. - pub fn adunits_insert(&self, request: &AdUnit, account_id: &str, ad_client_id: &str) -> AccountAdunitInsertCall<'a, C, A> { + pub fn adunits_insert(&self, request: AdUnit, account_id: &str, ad_client_id: &str) -> AccountAdunitInsertCall<'a, C, A> { AccountAdunitInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _ad_client_id: ad_client_id.to_string(), _delegate: Default::default(), @@ -1493,10 +1495,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// * `request` - No description provided. /// * `accountId` - Account which contains the ad client. /// * `adClientId` - Ad client which contains the ad unit. - pub fn adunits_update(&self, request: &AdUnit, account_id: &str, ad_client_id: &str) -> AccountAdunitUpdateCall<'a, C, A> { + pub fn adunits_update(&self, request: AdUnit, account_id: &str, ad_client_id: &str) -> AccountAdunitUpdateCall<'a, C, A> { AccountAdunitUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _ad_client_id: ad_client_id.to_string(), _delegate: Default::default(), @@ -1592,10 +1594,10 @@ impl<'a, C, A> CustomchannelMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `adClientId` - Ad client in which the custom channel will be updated. - pub fn update(&self, request: &CustomChannel, ad_client_id: &str) -> CustomchannelUpdateCall<'a, C, A> { + pub fn update(&self, request: CustomChannel, ad_client_id: &str) -> CustomchannelUpdateCall<'a, C, A> { CustomchannelUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _ad_client_id: ad_client_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1631,10 +1633,10 @@ impl<'a, C, A> CustomchannelMethods<'a, C, A> { /// * `request` - No description provided. /// * `adClientId` - Ad client in which the custom channel will be updated. /// * `customChannelId` - Custom channel to get. - pub fn patch(&self, request: &CustomChannel, ad_client_id: &str, custom_channel_id: &str) -> CustomchannelPatchCall<'a, C, A> { + pub fn patch(&self, request: CustomChannel, ad_client_id: &str, custom_channel_id: &str) -> CustomchannelPatchCall<'a, C, A> { CustomchannelPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _ad_client_id: ad_client_id.to_string(), _custom_channel_id: custom_channel_id.to_string(), _delegate: Default::default(), @@ -1651,10 +1653,10 @@ impl<'a, C, A> CustomchannelMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `adClientId` - Ad client to which the new custom channel will be added. - pub fn insert(&self, request: &CustomChannel, ad_client_id: &str) -> CustomchannelInsertCall<'a, C, A> { + pub fn insert(&self, request: CustomChannel, ad_client_id: &str) -> CustomchannelInsertCall<'a, C, A> { CustomchannelInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _ad_client_id: ad_client_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1703,7 +1705,7 @@ impl<'a, C, A> CustomchannelMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.urlchannels().insert(&req, "adClientId") +/// let result = hub.urlchannels().insert(req, "adClientId") /// .doit(); /// # } /// ``` @@ -1831,12 +1833,17 @@ impl<'a, C, A> UrlchannelInsertCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1845,7 +1852,7 @@ impl<'a, C, A> UrlchannelInsertCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1863,8 +1870,8 @@ impl<'a, C, A> UrlchannelInsertCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &UrlChannel) -> UrlchannelInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: UrlChannel) -> UrlchannelInsertCall<'a, C, A> { + self._request = new_value; self } /// Ad client to which the new URL channel will be added. @@ -2076,12 +2083,17 @@ impl<'a, C, A> UrlchannelDeleteCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2090,7 +2102,7 @@ impl<'a, C, A> UrlchannelDeleteCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2330,12 +2342,17 @@ impl<'a, C, A> UrlchannelListCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2344,7 +2361,7 @@ impl<'a, C, A> UrlchannelListCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2562,12 +2579,17 @@ impl<'a, C, A> AdclientListCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2576,7 +2598,7 @@ impl<'a, C, A> AdclientListCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2800,12 +2822,17 @@ impl<'a, C, A> AdclientGetCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2814,7 +2841,7 @@ impl<'a, C, A> AdclientGetCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3028,12 +3055,17 @@ impl<'a, C, A> AssociationsessionStartCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3042,7 +3074,7 @@ impl<'a, C, A> AssociationsessionStartCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3263,12 +3295,17 @@ impl<'a, C, A> AssociationsessionVerifyCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3277,7 +3314,7 @@ impl<'a, C, A> AssociationsessionVerifyCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3526,12 +3563,17 @@ impl<'a, C, A> ReportGenerateCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3540,7 +3582,7 @@ impl<'a, C, A> ReportGenerateCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3840,12 +3882,17 @@ impl<'a, C, A> AccountAdunitListCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3854,7 +3901,7 @@ impl<'a, C, A> AccountAdunitListCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4087,12 +4134,17 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4101,7 +4153,7 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4335,12 +4387,17 @@ impl<'a, C, A> AccountAdunitGetAdCodeCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4349,7 +4406,7 @@ impl<'a, C, A> AccountAdunitGetAdCodeCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4652,12 +4709,17 @@ impl<'a, C, A> AccountReportGenerateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4666,7 +4728,7 @@ impl<'a, C, A> AccountReportGenerateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4963,12 +5025,17 @@ impl<'a, C, A> AccountAdunitDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4977,7 +5044,7 @@ impl<'a, C, A> AccountAdunitDeleteCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5227,12 +5294,17 @@ impl<'a, C, A> AccountAdclientListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5241,7 +5313,7 @@ impl<'a, C, A> AccountAdclientListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5362,7 +5434,7 @@ impl<'a, C, A> AccountAdclientListCall<'a, C, A> where C: BorrowMut AccountAdunitPatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5508,7 +5585,7 @@ impl<'a, C, A> AccountAdunitPatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5526,8 +5603,8 @@ impl<'a, C, A> AccountAdunitPatchCall<'a, C, A> where C: BorrowMut AccountAdunitPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AdUnit) -> AccountAdunitPatchCall<'a, C, A> { + self._request = new_value; self } /// Account which contains the ad client. @@ -5759,12 +5836,17 @@ impl<'a, C, A> AccountAdclientGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5773,7 +5855,7 @@ impl<'a, C, A> AccountAdclientGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6003,12 +6085,17 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6017,7 +6104,7 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6124,7 +6211,7 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().adunits_insert(&req, "accountId", "adClientId") +/// let result = hub.accounts().adunits_insert(req, "accountId", "adClientId") /// .doit(); /// # } /// ``` @@ -6254,12 +6341,17 @@ impl<'a, C, A> AccountAdunitInsertCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6268,7 +6360,7 @@ impl<'a, C, A> AccountAdunitInsertCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6286,8 +6378,8 @@ impl<'a, C, A> AccountAdunitInsertCall<'a, C, A> where C: BorrowMut AccountAdunitInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AdUnit) -> AccountAdunitInsertCall<'a, C, A> { + self._request = new_value; self } /// Account which will contain the ad unit. @@ -6511,12 +6603,17 @@ impl<'a, C, A> AccountAdunitGetCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6525,7 +6622,7 @@ impl<'a, C, A> AccountAdunitGetCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6652,7 +6749,7 @@ impl<'a, C, A> AccountAdunitGetCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().adunits_update(&req, "accountId", "adClientId") +/// let result = hub.accounts().adunits_update(req, "accountId", "adClientId") /// .doit(); /// # } /// ``` @@ -6782,12 +6879,17 @@ impl<'a, C, A> AccountAdunitUpdateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6796,7 +6898,7 @@ impl<'a, C, A> AccountAdunitUpdateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6814,8 +6916,8 @@ impl<'a, C, A> AccountAdunitUpdateCall<'a, C, A> where C: BorrowMut AccountAdunitUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AdUnit) -> AccountAdunitUpdateCall<'a, C, A> { + self._request = new_value; self } /// Account which contains the ad client. @@ -7037,12 +7139,17 @@ impl<'a, C, A> CustomchannelGetCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7051,7 +7158,7 @@ impl<'a, C, A> CustomchannelGetCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7283,12 +7390,17 @@ impl<'a, C, A> CustomchannelDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7297,7 +7409,7 @@ impl<'a, C, A> CustomchannelDeleteCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7414,7 +7526,7 @@ impl<'a, C, A> CustomchannelDeleteCall<'a, C, A> where C: BorrowMut CustomchannelUpdateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7556,7 +7673,7 @@ impl<'a, C, A> CustomchannelUpdateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7574,8 +7691,8 @@ impl<'a, C, A> CustomchannelUpdateCall<'a, C, A> where C: BorrowMut CustomchannelUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CustomChannel) -> CustomchannelUpdateCall<'a, C, A> { + self._request = new_value; self } /// Ad client in which the custom channel will be updated. @@ -7795,12 +7912,17 @@ impl<'a, C, A> CustomchannelListCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7809,7 +7931,7 @@ impl<'a, C, A> CustomchannelListCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7930,7 +8052,7 @@ impl<'a, C, A> CustomchannelListCall<'a, C, A> where C: BorrowMut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.customchannels().patch(&req, "adClientId", "customChannelId") +/// let result = hub.customchannels().patch(req, "adClientId", "customChannelId") /// .doit(); /// # } /// ``` @@ -8060,12 +8182,17 @@ impl<'a, C, A> CustomchannelPatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8074,7 +8201,7 @@ impl<'a, C, A> CustomchannelPatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8092,8 +8219,8 @@ impl<'a, C, A> CustomchannelPatchCall<'a, C, A> where C: BorrowMut CustomchannelPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CustomChannel) -> CustomchannelPatchCall<'a, C, A> { + self._request = new_value; self } /// Ad client in which the custom channel will be updated. @@ -8200,7 +8327,7 @@ impl<'a, C, A> CustomchannelPatchCall<'a, C, A> where C: BorrowMut CustomchannelInsertCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8342,7 +8474,7 @@ impl<'a, C, A> CustomchannelInsertCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8360,8 +8492,8 @@ impl<'a, C, A> CustomchannelInsertCall<'a, C, A> where C: BorrowMut CustomchannelInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CustomChannel) -> CustomchannelInsertCall<'a, C, A> { + self._request = new_value; self } /// Ad client to which the new custom channel will be added. diff --git a/gen/analytics3-cli/Cargo.toml b/gen/analytics3-cli/Cargo.toml index 5c527e477e..acf73e4edd 100644 --- a/gen/analytics3-cli/Cargo.toml +++ b/gen/analytics3-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-analytics3-cli" -version = "0.0.1+20150305" +version = "0.1.0+20150305" authors = ["Sebastian Thiel "] description = "A complete library to interact with analytics (protocol v3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/analytics3-cli" diff --git a/gen/analytics3-cli/README.md b/gen/analytics3-cli/README.md index d68546a480..f439aede30 100644 --- a/gen/analytics3-cli/README.md +++ b/gen/analytics3-cli/README.md @@ -1,4 +1,179 @@ -# HELLO ANALYTICS:V3 + +The `analytics3` command-line interface *(CLI)* allows to use most features of the *Google analytics* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *analytics* API at revision *20150305*. The CLI is at version *0.1.0*. + +```bash + analytics3 [options] data ga-get [-p ...] [-o ] + analytics3 [options] data mcf-get [-p ...] [-o ] + analytics3 [options] data realtime-get [-p ...] [-o ] + analytics3 [options] management account-summaries-list [-p ...] [-o ] + analytics3 [options] management account-user-links-delete [-p ...] + analytics3 [options] management account-user-links-insert -r ... [-p ...] [-o ] + analytics3 [options] management account-user-links-list [-p ...] [-o ] + analytics3 [options] management account-user-links-update -r ... [-p ...] [-o ] + analytics3 [options] management accounts-list [-p ...] [-o ] + analytics3 [options] management custom-data-sources-list [-p ...] [-o ] + analytics3 [options] management custom-dimensions-get [-p ...] [-o ] + analytics3 [options] management custom-dimensions-insert -r ... [-p ...] [-o ] + analytics3 [options] management custom-dimensions-list [-p ...] [-o ] + analytics3 [options] management custom-dimensions-patch -r ... [-p ...] [-o ] + analytics3 [options] management custom-dimensions-update -r ... [-p ...] [-o ] + analytics3 [options] management custom-metrics-get [-p ...] [-o ] + analytics3 [options] management custom-metrics-insert -r ... [-p ...] [-o ] + analytics3 [options] management custom-metrics-list [-p ...] [-o ] + analytics3 [options] management custom-metrics-patch -r ... [-p ...] [-o ] + analytics3 [options] management custom-metrics-update -r ... [-p ...] [-o ] + analytics3 [options] management experiments-delete [-p ...] + analytics3 [options] management experiments-get [-p ...] [-o ] + analytics3 [options] management experiments-insert -r ... [-p ...] [-o ] + analytics3 [options] management experiments-list [-p ...] [-o ] + analytics3 [options] management experiments-patch -r ... [-p ...] [-o ] + analytics3 [options] management experiments-update -r ... [-p ...] [-o ] + analytics3 [options] management filters-delete [-p ...] [-o ] + analytics3 [options] management filters-get [-p ...] [-o ] + analytics3 [options] management filters-insert -r ... [-p ...] [-o ] + analytics3 [options] management filters-list [-p ...] [-o ] + analytics3 [options] management filters-patch -r ... [-p ...] [-o ] + analytics3 [options] management filters-update -r ... [-p ...] [-o ] + analytics3 [options] management goals-get [-p ...] [-o ] + analytics3 [options] management goals-insert -r ... [-p ...] [-o ] + analytics3 [options] management goals-list [-p ...] [-o ] + analytics3 [options] management goals-patch -r ... [-p ...] [-o ] + analytics3 [options] management goals-update -r ... [-p ...] [-o ] + analytics3 [options] management profile-filter-links-delete [-p ...] + analytics3 [options] management profile-filter-links-get [-p ...] [-o ] + analytics3 [options] management profile-filter-links-insert -r ... [-p ...] [-o ] + analytics3 [options] management profile-filter-links-list [-p ...] [-o ] + analytics3 [options] management profile-filter-links-patch -r ... [-p ...] [-o ] + analytics3 [options] management profile-filter-links-update -r ... [-p ...] [-o ] + analytics3 [options] management profile-user-links-delete [-p ...] + analytics3 [options] management profile-user-links-insert -r ... [-p ...] [-o ] + analytics3 [options] management profile-user-links-list [-p ...] [-o ] + analytics3 [options] management profile-user-links-update -r ... [-p ...] [-o ] + analytics3 [options] management profiles-delete [-p ...] + analytics3 [options] management profiles-get [-p ...] [-o ] + analytics3 [options] management profiles-insert -r ... [-p ...] [-o ] + analytics3 [options] management profiles-list [-p ...] [-o ] + analytics3 [options] management profiles-patch -r ... [-p ...] [-o ] + analytics3 [options] management profiles-update -r ... [-p ...] [-o ] + analytics3 [options] management segments-list [-p ...] [-o ] + analytics3 [options] management unsampled-reports-get [-p ...] [-o ] + analytics3 [options] management unsampled-reports-insert -r ... [-p ...] [-o ] + analytics3 [options] management unsampled-reports-list [-p ...] [-o ] + analytics3 [options] management uploads-delete-upload-data -r ... [-p ...] + analytics3 [options] management uploads-get [-p ...] [-o ] + analytics3 [options] management uploads-list [-p ...] [-o ] + analytics3 [options] management uploads-upload-data -u (simple|resumable) [-p ...] [-o ] + analytics3 [options] management web-property-ad-words-links-delete [-p ...] + analytics3 [options] management web-property-ad-words-links-get [-p ...] [-o ] + analytics3 [options] management web-property-ad-words-links-insert -r ... [-p ...] [-o ] + analytics3 [options] management web-property-ad-words-links-list [-p ...] [-o ] + analytics3 [options] management web-property-ad-words-links-patch -r ... [-p ...] [-o ] + analytics3 [options] management web-property-ad-words-links-update -r ... [-p ...] [-o ] + analytics3 [options] management webproperties-get [-p ...] [-o ] + analytics3 [options] management webproperties-insert -r ... [-p ...] [-o ] + analytics3 [options] management webproperties-list [-p ...] [-o ] + analytics3 [options] management webproperties-patch -r ... [-p ...] [-o ] + analytics3 [options] management webproperties-update -r ... [-p ...] [-o ] + analytics3 [options] management webproperty-user-links-delete [-p ...] + analytics3 [options] management webproperty-user-links-insert -r ... [-p ...] [-o ] + analytics3 [options] management webproperty-user-links-list [-p ...] [-o ] + analytics3 [options] management webproperty-user-links-update -r ... [-p ...] [-o ] + analytics3 [options] metadata columns-list [-p ...] [-o ] + analytics3 [options] provisioning create-account-ticket -r ... [-p ...] [-o ] + analytics3 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_analytics3_cli/index.html + +Configuration: + --scope + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `analytics3-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/analytics3-token-.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/analytics3-secret.json`, assuming that the required *analytics* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `analytics3 --debug [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/analytics3-cli/mkdocs.yml b/gen/analytics3-cli/mkdocs.yml index 45e39ee2b2..49d293021f 100644 --- a/gen/analytics3-cli/mkdocs.yml +++ b/gen/analytics3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: analytics v0.0.1+20150305 +site_name: analytics v0.1.0+20150305 site_url: http://byron.github.io/google-apis-rs/google-analytics3-cli site_description: Write integrating applications with bcore diff --git a/gen/analytics3-cli/src/cmn.rs b/gen/analytics3-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/analytics3-cli/src/cmn.rs +++ b/gen/analytics3-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/analytics3-cli/src/main.rs b/gen/analytics3-cli/src/main.rs index 8e028baeef..34c265db23 100644 --- a/gen/analytics3-cli/src/main.rs +++ b/gen/analytics3-cli/src/main.rs @@ -19,103 +19,104 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - analytics3 [options] data ga-get [-p ]... [-o ] - analytics3 [options] data mcf-get [-p ]... [-o ] - analytics3 [options] data realtime-get [-p ]... [-o ] - analytics3 [options] management account-summaries-list [-p ]... [-o ] - analytics3 [options] management account-user-links-delete [-p ]... - analytics3 [options] management account-user-links-insert -r ... [-p ]... [-o ] - analytics3 [options] management account-user-links-list [-p ]... [-o ] - analytics3 [options] management account-user-links-update -r ... [-p ]... [-o ] - analytics3 [options] management accounts-list [-p ]... [-o ] - analytics3 [options] management custom-data-sources-list [-p ]... [-o ] - analytics3 [options] management custom-dimensions-get [-p ]... [-o ] - analytics3 [options] management custom-dimensions-insert -r ... [-p ]... [-o ] - analytics3 [options] management custom-dimensions-list [-p ]... [-o ] - analytics3 [options] management custom-dimensions-patch -r ... [-p ]... [-o ] - analytics3 [options] management custom-dimensions-update -r ... [-p ]... [-o ] - analytics3 [options] management custom-metrics-get [-p ]... [-o ] - analytics3 [options] management custom-metrics-insert -r ... [-p ]... [-o ] - analytics3 [options] management custom-metrics-list [-p ]... [-o ] - analytics3 [options] management custom-metrics-patch -r ... [-p ]... [-o ] - analytics3 [options] management custom-metrics-update -r ... [-p ]... [-o ] - analytics3 [options] management experiments-delete [-p ]... - analytics3 [options] management experiments-get [-p ]... [-o ] - analytics3 [options] management experiments-insert -r ... [-p ]... [-o ] - analytics3 [options] management experiments-list [-p ]... [-o ] - analytics3 [options] management experiments-patch -r ... [-p ]... [-o ] - analytics3 [options] management experiments-update -r ... [-p ]... [-o ] - analytics3 [options] management filters-delete [-p ]... [-o ] - analytics3 [options] management filters-get [-p ]... [-o ] - analytics3 [options] management filters-insert -r ... [-p ]... [-o ] - analytics3 [options] management filters-list [-p ]... [-o ] - analytics3 [options] management filters-patch -r ... [-p ]... [-o ] - analytics3 [options] management filters-update -r ... [-p ]... [-o ] - analytics3 [options] management goals-get [-p ]... [-o ] - analytics3 [options] management goals-insert -r ... [-p ]... [-o ] - analytics3 [options] management goals-list [-p ]... [-o ] - analytics3 [options] management goals-patch -r ... [-p ]... [-o ] - analytics3 [options] management goals-update -r ... [-p ]... [-o ] - analytics3 [options] management profile-filter-links-delete [-p ]... - analytics3 [options] management profile-filter-links-get [-p ]... [-o ] - analytics3 [options] management profile-filter-links-insert -r ... [-p ]... [-o ] - analytics3 [options] management profile-filter-links-list [-p ]... [-o ] - analytics3 [options] management profile-filter-links-patch -r ... [-p ]... [-o ] - analytics3 [options] management profile-filter-links-update -r ... [-p ]... [-o ] - analytics3 [options] management profile-user-links-delete [-p ]... - analytics3 [options] management profile-user-links-insert -r ... [-p ]... [-o ] - analytics3 [options] management profile-user-links-list [-p ]... [-o ] - analytics3 [options] management profile-user-links-update -r ... [-p ]... [-o ] - analytics3 [options] management profiles-delete [-p ]... - analytics3 [options] management profiles-get [-p ]... [-o ] - analytics3 [options] management profiles-insert -r ... [-p ]... [-o ] - analytics3 [options] management profiles-list [-p ]... [-o ] - analytics3 [options] management profiles-patch -r ... [-p ]... [-o ] - analytics3 [options] management profiles-update -r ... [-p ]... [-o ] - analytics3 [options] management segments-list [-p ]... [-o ] - analytics3 [options] management unsampled-reports-get [-p ]... [-o ] - analytics3 [options] management unsampled-reports-insert -r ... [-p ]... [-o ] - analytics3 [options] management unsampled-reports-list [-p ]... [-o ] - analytics3 [options] management uploads-delete-upload-data -r ... [-p ]... - analytics3 [options] management uploads-get [-p ]... [-o ] - analytics3 [options] management uploads-list [-p ]... [-o ] - analytics3 [options] management uploads-upload-data -u (simple|resumable) [-p ]... [-o ] - analytics3 [options] management web-property-ad-words-links-delete [-p ]... - analytics3 [options] management web-property-ad-words-links-get [-p ]... [-o ] - analytics3 [options] management web-property-ad-words-links-insert -r ... [-p ]... [-o ] - analytics3 [options] management web-property-ad-words-links-list [-p ]... [-o ] - analytics3 [options] management web-property-ad-words-links-patch -r ... [-p ]... [-o ] - analytics3 [options] management web-property-ad-words-links-update -r ... [-p ]... [-o ] - analytics3 [options] management webproperties-get [-p ]... [-o ] - analytics3 [options] management webproperties-insert -r ... [-p ]... [-o ] - analytics3 [options] management webproperties-list [-p ]... [-o ] - analytics3 [options] management webproperties-patch -r ... [-p ]... [-o ] - analytics3 [options] management webproperties-update -r ... [-p ]... [-o ] - analytics3 [options] management webproperty-user-links-delete [-p ]... - analytics3 [options] management webproperty-user-links-insert -r ... [-p ]... [-o ] - analytics3 [options] management webproperty-user-links-list [-p ]... [-o ] - analytics3 [options] management webproperty-user-links-update -r ... [-p ]... [-o ] - analytics3 [options] metadata columns-list [-p ]... [-o ] - analytics3 [options] provisioning create-account-ticket -r ... [-p ]... [-o ] + analytics3 [options] data ga-get [-p ...] [-o ] + analytics3 [options] data mcf-get [-p ...] [-o ] + analytics3 [options] data realtime-get [-p ...] [-o ] + analytics3 [options] management account-summaries-list [-p ...] [-o ] + analytics3 [options] management account-user-links-delete [-p ...] + analytics3 [options] management account-user-links-insert -r ... [-p ...] [-o ] + analytics3 [options] management account-user-links-list [-p ...] [-o ] + analytics3 [options] management account-user-links-update -r ... [-p ...] [-o ] + analytics3 [options] management accounts-list [-p ...] [-o ] + analytics3 [options] management custom-data-sources-list [-p ...] [-o ] + analytics3 [options] management custom-dimensions-get [-p ...] [-o ] + analytics3 [options] management custom-dimensions-insert -r ... [-p ...] [-o ] + analytics3 [options] management custom-dimensions-list [-p ...] [-o ] + analytics3 [options] management custom-dimensions-patch -r ... [-p ...] [-o ] + analytics3 [options] management custom-dimensions-update -r ... [-p ...] [-o ] + analytics3 [options] management custom-metrics-get [-p ...] [-o ] + analytics3 [options] management custom-metrics-insert -r ... [-p ...] [-o ] + analytics3 [options] management custom-metrics-list [-p ...] [-o ] + analytics3 [options] management custom-metrics-patch -r ... [-p ...] [-o ] + analytics3 [options] management custom-metrics-update -r ... [-p ...] [-o ] + analytics3 [options] management experiments-delete [-p ...] + analytics3 [options] management experiments-get [-p ...] [-o ] + analytics3 [options] management experiments-insert -r ... [-p ...] [-o ] + analytics3 [options] management experiments-list [-p ...] [-o ] + analytics3 [options] management experiments-patch -r ... [-p ...] [-o ] + analytics3 [options] management experiments-update -r ... [-p ...] [-o ] + analytics3 [options] management filters-delete [-p ...] [-o ] + analytics3 [options] management filters-get [-p ...] [-o ] + analytics3 [options] management filters-insert -r ... [-p ...] [-o ] + analytics3 [options] management filters-list [-p ...] [-o ] + analytics3 [options] management filters-patch -r ... [-p ...] [-o ] + analytics3 [options] management filters-update -r ... [-p ...] [-o ] + analytics3 [options] management goals-get [-p ...] [-o ] + analytics3 [options] management goals-insert -r ... [-p ...] [-o ] + analytics3 [options] management goals-list [-p ...] [-o ] + analytics3 [options] management goals-patch -r ... [-p ...] [-o ] + analytics3 [options] management goals-update -r ... [-p ...] [-o ] + analytics3 [options] management profile-filter-links-delete [-p ...] + analytics3 [options] management profile-filter-links-get [-p ...] [-o ] + analytics3 [options] management profile-filter-links-insert -r ... [-p ...] [-o ] + analytics3 [options] management profile-filter-links-list [-p ...] [-o ] + analytics3 [options] management profile-filter-links-patch -r ... [-p ...] [-o ] + analytics3 [options] management profile-filter-links-update -r ... [-p ...] [-o ] + analytics3 [options] management profile-user-links-delete [-p ...] + analytics3 [options] management profile-user-links-insert -r ... [-p ...] [-o ] + analytics3 [options] management profile-user-links-list [-p ...] [-o ] + analytics3 [options] management profile-user-links-update -r ... [-p ...] [-o ] + analytics3 [options] management profiles-delete [-p ...] + analytics3 [options] management profiles-get [-p ...] [-o ] + analytics3 [options] management profiles-insert -r ... [-p ...] [-o ] + analytics3 [options] management profiles-list [-p ...] [-o ] + analytics3 [options] management profiles-patch -r ... [-p ...] [-o ] + analytics3 [options] management profiles-update -r ... [-p ...] [-o ] + analytics3 [options] management segments-list [-p ...] [-o ] + analytics3 [options] management unsampled-reports-get [-p ...] [-o ] + analytics3 [options] management unsampled-reports-insert -r ... [-p ...] [-o ] + analytics3 [options] management unsampled-reports-list [-p ...] [-o ] + analytics3 [options] management uploads-delete-upload-data -r ... [-p ...] + analytics3 [options] management uploads-get [-p ...] [-o ] + analytics3 [options] management uploads-list [-p ...] [-o ] + analytics3 [options] management uploads-upload-data -u (simple|resumable) [-p ...] [-o ] + analytics3 [options] management web-property-ad-words-links-delete [-p ...] + analytics3 [options] management web-property-ad-words-links-get [-p ...] [-o ] + analytics3 [options] management web-property-ad-words-links-insert -r ... [-p ...] [-o ] + analytics3 [options] management web-property-ad-words-links-list [-p ...] [-o ] + analytics3 [options] management web-property-ad-words-links-patch -r ... [-p ...] [-o ] + analytics3 [options] management web-property-ad-words-links-update -r ... [-p ...] [-o ] + analytics3 [options] management webproperties-get [-p ...] [-o ] + analytics3 [options] management webproperties-insert -r ... [-p ...] [-o ] + analytics3 [options] management webproperties-list [-p ...] [-o ] + analytics3 [options] management webproperties-patch -r ... [-p ...] [-o ] + analytics3 [options] management webproperties-update -r ... [-p ...] [-o ] + analytics3 [options] management webproperty-user-links-delete [-p ...] + analytics3 [options] management webproperty-user-links-insert -r ... [-p ...] [-o ] + analytics3 [options] management webproperty-user-links-list [-p ...] [-o ] + analytics3 [options] management webproperty-user-links-update -r ... [-p ...] [-o ] + analytics3 [options] metadata columns-list [-p ...] [-o ] + analytics3 [options] provisioning create-account-ticket -r ... [-p ...] [-o ] analytics3 --help -All documentation details can be found TODO: +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_analytics3_cli/index.html Configuration: --scope - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -188,6 +189,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -249,6 +253,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -304,6 +311,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -353,6 +363,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -396,6 +409,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -410,36 +426,23 @@ impl Engine { fn _management_account_user_links_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::EntityUserLink::default(); - let mut call = self.hub.management().account_user_links_insert(&request, &self.opt.arg_account_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::EntityUserLink::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_entity_account_ref_init(request: &mut api::EntityUserLink) { request_entity_init(request); if request.entity.as_mut().unwrap().account_ref.is_none() { @@ -479,7 +482,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -586,15 +589,40 @@ impl Engine { request.permissions.as_mut().unwrap().effective.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().account_user_links_insert(request, &self.opt.arg_account_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -644,6 +672,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -660,36 +691,23 @@ impl Engine { fn _management_account_user_links_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::EntityUserLink::default(); - let mut call = self.hub.management().account_user_links_update(&request, &self.opt.arg_account_id, &self.opt.arg_link_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::EntityUserLink::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_entity_account_ref_init(request: &mut api::EntityUserLink) { request_entity_init(request); if request.entity.as_mut().unwrap().account_ref.is_none() { @@ -729,7 +747,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -836,15 +854,40 @@ impl Engine { request.permissions.as_mut().unwrap().effective.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().account_user_links_update(request, &self.opt.arg_account_id, &self.opt.arg_link_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -894,6 +937,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -943,6 +989,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -986,6 +1035,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1002,43 +1054,30 @@ impl Engine { fn _management_custom_dimensions_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::CustomDimension::default(); - let mut call = self.hub.management().custom_dimensions_insert(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::CustomDimension::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_parent_link_init(request: &mut api::CustomDimension) { if request.parent_link.is_none() { request.parent_link = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "index" => { request.index = Some(arg_from_str(value.unwrap_or("-0"), err, "index", "integer")); }, @@ -1084,15 +1123,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().custom_dimensions_insert(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1142,6 +1206,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1158,46 +1225,30 @@ impl Engine { fn _management_custom_dimensions_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::CustomDimension::default(); - let mut call = self.hub.management().custom_dimensions_patch(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_custom_dimension_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "ignore-custom-data-source-links" => { - call = call.ignore_custom_data_source_links(arg_from_str(value.unwrap_or("false"), err, "ignore-custom-data-source-links", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::CustomDimension::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_parent_link_init(request: &mut api::CustomDimension) { if request.parent_link.is_none() { request.parent_link = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "index" => { request.index = Some(arg_from_str(value.unwrap_or("-0"), err, "index", "integer")); }, @@ -1243,15 +1294,43 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().custom_dimensions_patch(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_custom_dimension_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "ignore-custom-data-source-links" => { + call = call.ignore_custom_data_source_links(arg_from_str(value.unwrap_or("false"), err, "ignore-custom-data-source-links", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1268,46 +1347,30 @@ impl Engine { fn _management_custom_dimensions_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::CustomDimension::default(); - let mut call = self.hub.management().custom_dimensions_update(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_custom_dimension_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "ignore-custom-data-source-links" => { - call = call.ignore_custom_data_source_links(arg_from_str(value.unwrap_or("false"), err, "ignore-custom-data-source-links", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::CustomDimension::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_parent_link_init(request: &mut api::CustomDimension) { if request.parent_link.is_none() { request.parent_link = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "index" => { request.index = Some(arg_from_str(value.unwrap_or("-0"), err, "index", "integer")); }, @@ -1353,15 +1416,43 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().custom_dimensions_update(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_custom_dimension_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "ignore-custom-data-source-links" => { + call = call.ignore_custom_data_source_links(arg_from_str(value.unwrap_or("false"), err, "ignore-custom-data-source-links", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1405,6 +1496,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1421,43 +1515,30 @@ impl Engine { fn _management_custom_metrics_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::CustomMetric::default(); - let mut call = self.hub.management().custom_metrics_insert(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::CustomMetric::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_parent_link_init(request: &mut api::CustomMetric) { if request.parent_link.is_none() { request.parent_link = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "index" => { request.index = Some(arg_from_str(value.unwrap_or("-0"), err, "index", "integer")); }, @@ -1513,15 +1594,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().custom_metrics_insert(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1571,6 +1677,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1587,46 +1696,30 @@ impl Engine { fn _management_custom_metrics_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::CustomMetric::default(); - let mut call = self.hub.management().custom_metrics_patch(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_custom_metric_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "ignore-custom-data-source-links" => { - call = call.ignore_custom_data_source_links(arg_from_str(value.unwrap_or("false"), err, "ignore-custom-data-source-links", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::CustomMetric::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_parent_link_init(request: &mut api::CustomMetric) { if request.parent_link.is_none() { request.parent_link = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "index" => { request.index = Some(arg_from_str(value.unwrap_or("-0"), err, "index", "integer")); }, @@ -1682,15 +1775,43 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().custom_metrics_patch(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_custom_metric_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "ignore-custom-data-source-links" => { + call = call.ignore_custom_data_source_links(arg_from_str(value.unwrap_or("false"), err, "ignore-custom-data-source-links", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1707,46 +1828,30 @@ impl Engine { fn _management_custom_metrics_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::CustomMetric::default(); - let mut call = self.hub.management().custom_metrics_update(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_custom_metric_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "ignore-custom-data-source-links" => { - call = call.ignore_custom_data_source_links(arg_from_str(value.unwrap_or("false"), err, "ignore-custom-data-source-links", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::CustomMetric::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_parent_link_init(request: &mut api::CustomMetric) { if request.parent_link.is_none() { request.parent_link = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "index" => { request.index = Some(arg_from_str(value.unwrap_or("-0"), err, "index", "integer")); }, @@ -1802,15 +1907,43 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().custom_metrics_update(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_custom_metric_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "ignore-custom-data-source-links" => { + call = call.ignore_custom_data_source_links(arg_from_str(value.unwrap_or("false"), err, "ignore-custom-data-source-links", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1854,6 +1987,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1895,6 +2031,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1911,43 +2050,30 @@ impl Engine { fn _management_experiments_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Experiment::default(); - let mut call = self.hub.management().experiments_insert(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Experiment::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_parent_link_init(request: &mut api::Experiment) { if request.parent_link.is_none() { request.parent_link = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "traffic-coverage" => { request.traffic_coverage = Some(arg_from_str(value.unwrap_or("0.0"), err, "traffic-coverage", "number")); }, @@ -2037,15 +2163,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().experiments_insert(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2095,6 +2246,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2111,43 +2265,30 @@ impl Engine { fn _management_experiments_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Experiment::default(); - let mut call = self.hub.management().experiments_patch(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id, &self.opt.arg_experiment_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Experiment::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_parent_link_init(request: &mut api::Experiment) { if request.parent_link.is_none() { request.parent_link = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "traffic-coverage" => { request.traffic_coverage = Some(arg_from_str(value.unwrap_or("0.0"), err, "traffic-coverage", "number")); }, @@ -2237,15 +2378,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().experiments_patch(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id, &self.opt.arg_experiment_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2262,43 +2428,30 @@ impl Engine { fn _management_experiments_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Experiment::default(); - let mut call = self.hub.management().experiments_update(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id, &self.opt.arg_experiment_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Experiment::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_parent_link_init(request: &mut api::Experiment) { if request.parent_link.is_none() { request.parent_link = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "traffic-coverage" => { request.traffic_coverage = Some(arg_from_str(value.unwrap_or("0.0"), err, "traffic-coverage", "number")); }, @@ -2388,15 +2541,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().experiments_update(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id, &self.opt.arg_experiment_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2440,6 +2618,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2483,6 +2664,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2499,36 +2683,23 @@ impl Engine { fn _management_filters_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Filter::default(); - let mut call = self.hub.management().filters_insert(&request, &self.opt.arg_account_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Filter::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advanced_details_init(request: &mut api::Filter) { if request.advanced_details.is_none() { request.advanced_details = Some(Default::default()); @@ -2571,7 +2742,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -2714,15 +2885,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().filters_insert(request, &self.opt.arg_account_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2772,6 +2968,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2788,36 +2987,23 @@ impl Engine { fn _management_filters_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Filter::default(); - let mut call = self.hub.management().filters_patch(&request, &self.opt.arg_account_id, &self.opt.arg_filter_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Filter::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advanced_details_init(request: &mut api::Filter) { if request.advanced_details.is_none() { request.advanced_details = Some(Default::default()); @@ -2860,7 +3046,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -3003,15 +3189,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().filters_patch(request, &self.opt.arg_account_id, &self.opt.arg_filter_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3028,36 +3239,23 @@ impl Engine { fn _management_filters_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Filter::default(); - let mut call = self.hub.management().filters_update(&request, &self.opt.arg_account_id, &self.opt.arg_filter_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Filter::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advanced_details_init(request: &mut api::Filter) { if request.advanced_details.is_none() { request.advanced_details = Some(Default::default()); @@ -3100,7 +3298,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -3243,15 +3441,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().filters_update(request, &self.opt.arg_account_id, &self.opt.arg_filter_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3295,6 +3518,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3311,36 +3537,23 @@ impl Engine { fn _management_goals_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Goal::default(); - let mut call = self.hub.management().goals_insert(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Goal::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_event_details_init(request: &mut api::Goal) { if request.event_details.is_none() { request.event_details = Some(Default::default()); @@ -3371,7 +3584,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "updated" => { request.updated = Some(value.unwrap_or("").to_string()); }, @@ -3468,15 +3681,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().goals_insert(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3526,6 +3764,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3542,36 +3783,23 @@ impl Engine { fn _management_goals_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Goal::default(); - let mut call = self.hub.management().goals_patch(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id, &self.opt.arg_goal_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Goal::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_event_details_init(request: &mut api::Goal) { if request.event_details.is_none() { request.event_details = Some(Default::default()); @@ -3602,7 +3830,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "updated" => { request.updated = Some(value.unwrap_or("").to_string()); }, @@ -3699,15 +3927,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().goals_patch(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id, &self.opt.arg_goal_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3724,36 +3977,23 @@ impl Engine { fn _management_goals_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Goal::default(); - let mut call = self.hub.management().goals_update(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id, &self.opt.arg_goal_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Goal::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_event_details_init(request: &mut api::Goal) { if request.event_details.is_none() { request.event_details = Some(Default::default()); @@ -3784,7 +4024,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "updated" => { request.updated = Some(value.unwrap_or("").to_string()); }, @@ -3881,15 +4121,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().goals_update(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id, &self.opt.arg_goal_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3933,6 +4198,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -3974,6 +4242,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3990,36 +4261,23 @@ impl Engine { fn _management_profile_filter_links_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::ProfileFilterLink::default(); - let mut call = self.hub.management().profile_filter_links_insert(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ProfileFilterLink::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_filter_ref_init(request: &mut api::ProfileFilterLink) { if request.filter_ref.is_none() { request.filter_ref = Some(Default::default()); @@ -4032,7 +4290,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -4096,15 +4354,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().profile_filter_links_insert(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4154,6 +4437,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4170,36 +4456,23 @@ impl Engine { fn _management_profile_filter_links_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::ProfileFilterLink::default(); - let mut call = self.hub.management().profile_filter_links_patch(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id, &self.opt.arg_link_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ProfileFilterLink::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_filter_ref_init(request: &mut api::ProfileFilterLink) { if request.filter_ref.is_none() { request.filter_ref = Some(Default::default()); @@ -4212,7 +4485,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -4276,15 +4549,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().profile_filter_links_patch(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id, &self.opt.arg_link_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4301,36 +4599,23 @@ impl Engine { fn _management_profile_filter_links_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::ProfileFilterLink::default(); - let mut call = self.hub.management().profile_filter_links_update(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id, &self.opt.arg_link_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ProfileFilterLink::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_filter_ref_init(request: &mut api::ProfileFilterLink) { if request.filter_ref.is_none() { request.filter_ref = Some(Default::default()); @@ -4343,7 +4628,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -4407,15 +4692,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().profile_filter_links_update(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id, &self.opt.arg_link_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4459,6 +4769,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -4473,36 +4786,23 @@ impl Engine { fn _management_profile_user_links_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::EntityUserLink::default(); - let mut call = self.hub.management().profile_user_links_insert(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::EntityUserLink::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_entity_account_ref_init(request: &mut api::EntityUserLink) { request_entity_init(request); if request.entity.as_mut().unwrap().account_ref.is_none() { @@ -4542,7 +4842,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -4649,15 +4949,40 @@ impl Engine { request.permissions.as_mut().unwrap().effective.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().profile_user_links_insert(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4707,6 +5032,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4723,36 +5051,23 @@ impl Engine { fn _management_profile_user_links_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::EntityUserLink::default(); - let mut call = self.hub.management().profile_user_links_update(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id, &self.opt.arg_link_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::EntityUserLink::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_entity_account_ref_init(request: &mut api::EntityUserLink) { request_entity_init(request); if request.entity.as_mut().unwrap().account_ref.is_none() { @@ -4792,7 +5107,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -4899,15 +5214,40 @@ impl Engine { request.permissions.as_mut().unwrap().effective.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().profile_user_links_update(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id, &self.opt.arg_link_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4951,6 +5291,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -4992,6 +5335,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5008,36 +5354,23 @@ impl Engine { fn _management_profiles_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Profile::default(); - let mut call = self.hub.management().profiles_insert(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Profile::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_child_link_init(request: &mut api::Profile) { if request.child_link.is_none() { request.child_link = Some(Default::default()); @@ -5056,7 +5389,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "currency" => { request.currency = Some(value.unwrap_or("").to_string()); }, @@ -5153,15 +5486,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().profiles_insert(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5211,6 +5569,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5227,36 +5588,23 @@ impl Engine { fn _management_profiles_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Profile::default(); - let mut call = self.hub.management().profiles_patch(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Profile::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_child_link_init(request: &mut api::Profile) { if request.child_link.is_none() { request.child_link = Some(Default::default()); @@ -5275,7 +5623,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "currency" => { request.currency = Some(value.unwrap_or("").to_string()); }, @@ -5372,15 +5720,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().profiles_patch(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5397,36 +5770,23 @@ impl Engine { fn _management_profiles_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Profile::default(); - let mut call = self.hub.management().profiles_update(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Profile::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_child_link_init(request: &mut api::Profile) { if request.child_link.is_none() { request.child_link = Some(Default::default()); @@ -5445,7 +5805,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "currency" => { request.currency = Some(value.unwrap_or("").to_string()); }, @@ -5542,15 +5902,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().profiles_update(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5600,6 +5985,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5643,6 +6031,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5659,36 +6050,23 @@ impl Engine { fn _management_unsampled_reports_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::UnsampledReport::default(); - let mut call = self.hub.management().unsampled_reports_insert(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::UnsampledReport::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_cloud_storage_download_details_init(request: &mut api::UnsampledReport) { if request.cloud_storage_download_details.is_none() { request.cloud_storage_download_details = Some(Default::default()); @@ -5701,7 +6079,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -5781,15 +6159,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().unsampled_reports_insert(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5839,6 +6242,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5855,8 +6261,36 @@ impl Engine { fn _management_uploads_delete_upload_data(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::AnalyticsDataimportDeleteUploadDataRequest::default(); - let mut call = self.hub.management().uploads_delete_upload_data(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_custom_data_source_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "custom-data-import-uids" => { + if request.custom_data_import_uids.is_none() { + request.custom_data_import_uids = Some(Default::default()); + } + request.custom_data_import_uids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.management().uploads_delete_upload_data(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_custom_data_source_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -5878,30 +6312,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "custom-data-import-uids" => { - if request.custom_data_import_uids.is_none() { - request.custom_data_import_uids = Some(Default::default()); - } - request.custom_data_import_uids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -5943,6 +6361,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5992,6 +6413,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6044,6 +6468,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -6088,6 +6515,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -6129,6 +6559,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6145,36 +6578,23 @@ impl Engine { fn _management_web_property_ad_words_links_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::EntityAdWordsLink::default(); - let mut call = self.hub.management().web_property_ad_words_links_insert(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::EntityAdWordsLink::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_entity_init(request: &mut api::EntityAdWordsLink) { if request.entity.is_none() { request.entity = Some(Default::default()); @@ -6188,7 +6608,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -6234,15 +6654,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().web_property_ad_words_links_insert(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6292,6 +6737,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6308,36 +6756,23 @@ impl Engine { fn _management_web_property_ad_words_links_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::EntityAdWordsLink::default(); - let mut call = self.hub.management().web_property_ad_words_links_patch(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_web_property_ad_words_link_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::EntityAdWordsLink::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_entity_init(request: &mut api::EntityAdWordsLink) { if request.entity.is_none() { request.entity = Some(Default::default()); @@ -6351,7 +6786,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -6397,15 +6832,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().web_property_ad_words_links_patch(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_web_property_ad_words_link_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6422,36 +6882,23 @@ impl Engine { fn _management_web_property_ad_words_links_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::EntityAdWordsLink::default(); - let mut call = self.hub.management().web_property_ad_words_links_update(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_web_property_ad_words_link_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::EntityAdWordsLink::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_entity_init(request: &mut api::EntityAdWordsLink) { if request.entity.is_none() { request.entity = Some(Default::default()); @@ -6465,7 +6912,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -6511,15 +6958,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().web_property_ad_words_links_update(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_web_property_ad_words_link_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6563,6 +7035,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6579,36 +7054,23 @@ impl Engine { fn _management_webproperties_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Webproperty::default(); - let mut call = self.hub.management().webproperties_insert(&request, &self.opt.arg_account_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Webproperty::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_child_link_init(request: &mut api::Webproperty) { if request.child_link.is_none() { request.child_link = Some(Default::default()); @@ -6627,7 +7089,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "website-url" => { request.website_url = Some(value.unwrap_or("").to_string()); }, @@ -6695,15 +7157,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().webproperties_insert(request, &self.opt.arg_account_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6753,6 +7240,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6769,36 +7259,23 @@ impl Engine { fn _management_webproperties_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Webproperty::default(); - let mut call = self.hub.management().webproperties_patch(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Webproperty::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_child_link_init(request: &mut api::Webproperty) { if request.child_link.is_none() { request.child_link = Some(Default::default()); @@ -6817,7 +7294,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "website-url" => { request.website_url = Some(value.unwrap_or("").to_string()); }, @@ -6885,15 +7362,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().webproperties_patch(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6910,36 +7412,23 @@ impl Engine { fn _management_webproperties_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Webproperty::default(); - let mut call = self.hub.management().webproperties_update(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Webproperty::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_child_link_init(request: &mut api::Webproperty) { if request.child_link.is_none() { request.child_link = Some(Default::default()); @@ -6958,7 +7447,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "website-url" => { request.website_url = Some(value.unwrap_or("").to_string()); }, @@ -7026,15 +7515,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().webproperties_update(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7078,6 +7592,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -7092,36 +7609,23 @@ impl Engine { fn _management_webproperty_user_links_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::EntityUserLink::default(); - let mut call = self.hub.management().webproperty_user_links_insert(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::EntityUserLink::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_entity_account_ref_init(request: &mut api::EntityUserLink) { request_entity_init(request); if request.entity.as_mut().unwrap().account_ref.is_none() { @@ -7161,7 +7665,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -7268,15 +7772,40 @@ impl Engine { request.permissions.as_mut().unwrap().effective.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().webproperty_user_links_insert(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7326,6 +7855,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7342,36 +7874,23 @@ impl Engine { fn _management_webproperty_user_links_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::EntityUserLink::default(); - let mut call = self.hub.management().webproperty_user_links_update(&request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_link_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::EntityUserLink::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_entity_account_ref_init(request: &mut api::EntityUserLink) { request_entity_init(request); if request.entity.as_mut().unwrap().account_ref.is_none() { @@ -7411,7 +7930,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -7518,15 +8037,40 @@ impl Engine { request.permissions.as_mut().unwrap().effective.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.management().webproperty_user_links_update(request, &self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_link_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7570,6 +8114,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7586,36 +8133,23 @@ impl Engine { fn _provisioning_create_account_ticket(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::AccountTicket::default(); - let mut call = self.hub.provisioning().create_account_ticket(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::AccountTicket::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_account_child_link_init(request: &mut api::AccountTicket) { request_account_init(request); if request.account.as_mut().unwrap().child_link.is_none() { @@ -7690,7 +8224,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "profile.currency" => { request_profile_init(&mut request); request.profile.as_mut().unwrap().currency = Some(value.unwrap_or("").to_string()); @@ -7925,15 +8459,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.provisioning().create_account_ticket(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -8196,6 +8755,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -8203,8 +8763,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/analytics3/Cargo.toml b/gen/analytics3/Cargo.toml index 9e2cd4129b..f871077765 100644 --- a/gen/analytics3/Cargo.toml +++ b/gen/analytics3/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-analytics3" -version = "0.1.5+20150305" +version = "0.1.6+20150305" authors = ["Sebastian Thiel "] description = "A complete library to interact with analytics (protocol v3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/analytics3" diff --git a/gen/analytics3/README.md b/gen/analytics3/README.md index 92bfae65cd..663029404c 100644 --- a/gen/analytics3/README.md +++ b/gen/analytics3/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-analytics3` library allows access to all features of the *Google analytics* service. -This documentation was generated from *analytics* crate version *0.1.5+20150305*, where *20150305* is the exact revision of the *analytics:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *analytics* crate version *0.1.6+20150305*, where *20150305* is the exact revision of the *analytics:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *analytics* *v3* API can be found at the [official documentation site](https://developers.google.com/analytics/). @@ -113,21 +113,22 @@ let mut req = EntityUserLink::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.management().profile_user_links_update(&req, "accountId", "webPropertyId", "profileId", "linkId") +let result = hub.management().profile_user_links_update(req, "accountId", "webPropertyId", "profileId", "linkId") .doit(); match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/analytics3/src/cmn.rs b/gen/analytics3/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/analytics3/src/cmn.rs +++ b/gen/analytics3/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option, + location: Option +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option, _: Option) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec]) -> Option { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/analytics3/src/lib.rs b/gen/analytics3/src/lib.rs index b56818890b..614969a678 100644 --- a/gen/analytics3/src/lib.rs +++ b/gen/analytics3/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *analytics* crate version *0.1.5+20150305*, where *20150305* is the exact revision of the *analytics:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *analytics* crate version *0.1.6+20150305*, where *20150305* is the exact revision of the *analytics:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *analytics* *v3* API can be found at the //! [official documentation site](https://developers.google.com/analytics/). @@ -114,21 +114,22 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.management().profile_user_links_update(&req, "accountId", "webPropertyId", "profileId", "linkId") +//! let result = hub.management().profile_user_links_update(req, "accountId", "webPropertyId", "profileId", "linkId") //! .doit(); //! //! match result { //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -216,7 +217,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -309,21 +310,22 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.management().profile_user_links_update(&req, "accountId", "webPropertyId", "profileId", "linkId") +/// let result = hub.management().profile_user_links_update(req, "accountId", "webPropertyId", "profileId", "linkId") /// .doit(); /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -344,7 +346,7 @@ impl<'a, C, A> Analytics Analytics { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -362,7 +364,7 @@ impl<'a, C, A> Analytics } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -3283,10 +3285,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `accountId` - Account ID to create the web property for. - pub fn webproperties_insert(&self, request: &Webproperty, account_id: &str) -> ManagementWebpropertyInsertCall<'a, C, A> { + pub fn webproperties_insert(&self, request: Webproperty, account_id: &str) -> ManagementWebpropertyInsertCall<'a, C, A> { ManagementWebpropertyInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3340,10 +3342,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `webPropertyId` - Web property Id to which profile filter link belongs /// * `profileId` - Profile ID to which filter link belongs /// * `linkId` - ID of the profile filter link to be updated. - pub fn profile_filter_links_patch(&self, request: &ProfileFilterLink, account_id: &str, web_property_id: &str, profile_id: &str, link_id: &str) -> ManagementProfileFilterLinkPatchCall<'a, C, A> { + pub fn profile_filter_links_patch(&self, request: ProfileFilterLink, account_id: &str, web_property_id: &str, profile_id: &str, link_id: &str) -> ManagementProfileFilterLinkPatchCall<'a, C, A> { ManagementProfileFilterLinkPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _profile_id: profile_id.to_string(), @@ -3409,10 +3411,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `webPropertyId` - Web Property ID to update the user link for. /// * `profileId` - View (Profile ID) to update the user link for. /// * `linkId` - Link ID to update the user link for. - pub fn profile_user_links_update(&self, request: &EntityUserLink, account_id: &str, web_property_id: &str, profile_id: &str, link_id: &str) -> ManagementProfileUserLinkUpdateCall<'a, C, A> { + pub fn profile_user_links_update(&self, request: EntityUserLink, account_id: &str, web_property_id: &str, profile_id: &str, link_id: &str) -> ManagementProfileUserLinkUpdateCall<'a, C, A> { ManagementProfileUserLinkUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _profile_id: profile_id.to_string(), @@ -3431,10 +3433,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `accountId` - Account ID to create filter for. - pub fn filters_insert(&self, request: &Filter, account_id: &str) -> ManagementFilterInsertCall<'a, C, A> { + pub fn filters_insert(&self, request: Filter, account_id: &str) -> ManagementFilterInsertCall<'a, C, A> { ManagementFilterInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3451,10 +3453,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `request` - No description provided. /// * `accountId` - Account ID to update the account-user link for. /// * `linkId` - Link ID to update the account-user link for. - pub fn account_user_links_update(&self, request: &EntityUserLink, account_id: &str, link_id: &str) -> ManagementAccountUserLinkUpdateCall<'a, C, A> { + pub fn account_user_links_update(&self, request: EntityUserLink, account_id: &str, link_id: &str) -> ManagementAccountUserLinkUpdateCall<'a, C, A> { ManagementAccountUserLinkUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _link_id: link_id.to_string(), _delegate: Default::default(), @@ -3472,10 +3474,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `request` - No description provided. /// * `accountId` - Account ID to which the web property belongs /// * `webPropertyId` - Web property ID - pub fn webproperties_update(&self, request: &Webproperty, account_id: &str, web_property_id: &str) -> ManagementWebpropertyUpdateCall<'a, C, A> { + pub fn webproperties_update(&self, request: Webproperty, account_id: &str, web_property_id: &str) -> ManagementWebpropertyUpdateCall<'a, C, A> { ManagementWebpropertyUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _delegate: Default::default(), @@ -3494,10 +3496,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `accountId` - Account ID to update the account-user link for. /// * `webPropertyId` - Web property ID to update the account-user link for. /// * `linkId` - Link ID to update the account-user link for. - pub fn webproperty_user_links_update(&self, request: &EntityUserLink, account_id: &str, web_property_id: &str, link_id: &str) -> ManagementWebpropertyUserLinkUpdateCall<'a, C, A> { + pub fn webproperty_user_links_update(&self, request: EntityUserLink, account_id: &str, web_property_id: &str, link_id: &str) -> ManagementWebpropertyUserLinkUpdateCall<'a, C, A> { ManagementWebpropertyUserLinkUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _link_id: link_id.to_string(), @@ -3517,10 +3519,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `accountId` - Account ID to create the unsampled report for. /// * `webPropertyId` - Web property ID to create the unsampled report for. /// * `profileId` - View (Profile) ID to create the unsampled report for. - pub fn unsampled_reports_insert(&self, request: &UnsampledReport, account_id: &str, web_property_id: &str, profile_id: &str) -> ManagementUnsampledReportInsertCall<'a, C, A> { + pub fn unsampled_reports_insert(&self, request: UnsampledReport, account_id: &str, web_property_id: &str, profile_id: &str) -> ManagementUnsampledReportInsertCall<'a, C, A> { ManagementUnsampledReportInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _profile_id: profile_id.to_string(), @@ -3627,10 +3629,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `webPropertyId` - Web property Id to which profile filter link belongs /// * `profileId` - Profile ID to which filter link belongs /// * `linkId` - ID of the profile filter link to be updated. - pub fn profile_filter_links_update(&self, request: &ProfileFilterLink, account_id: &str, web_property_id: &str, profile_id: &str, link_id: &str) -> ManagementProfileFilterLinkUpdateCall<'a, C, A> { + pub fn profile_filter_links_update(&self, request: ProfileFilterLink, account_id: &str, web_property_id: &str, profile_id: &str, link_id: &str) -> ManagementProfileFilterLinkUpdateCall<'a, C, A> { ManagementProfileFilterLinkUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _profile_id: profile_id.to_string(), @@ -3674,10 +3676,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `accountId` - Account ID for the custom dimension to update. /// * `webPropertyId` - Web property ID for the custom dimension to update. /// * `customDimensionId` - Custom dimension ID for the custom dimension to update. - pub fn custom_dimensions_update(&self, request: &CustomDimension, account_id: &str, web_property_id: &str, custom_dimension_id: &str) -> ManagementCustomDimensionUpdateCall<'a, C, A> { + pub fn custom_dimensions_update(&self, request: CustomDimension, account_id: &str, web_property_id: &str, custom_dimension_id: &str) -> ManagementCustomDimensionUpdateCall<'a, C, A> { ManagementCustomDimensionUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _custom_dimension_id: custom_dimension_id.to_string(), @@ -3721,10 +3723,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `accountId` - Account ID to create profile filter link for. /// * `webPropertyId` - Web property Id to create profile filter link for. /// * `profileId` - Profile ID to create filter link for. - pub fn profile_filter_links_insert(&self, request: &ProfileFilterLink, account_id: &str, web_property_id: &str, profile_id: &str) -> ManagementProfileFilterLinkInsertCall<'a, C, A> { + pub fn profile_filter_links_insert(&self, request: ProfileFilterLink, account_id: &str, web_property_id: &str, profile_id: &str) -> ManagementProfileFilterLinkInsertCall<'a, C, A> { ManagementProfileFilterLinkInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _profile_id: profile_id.to_string(), @@ -3743,10 +3745,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `request` - No description provided. /// * `accountId` - Account ID to which the filter belongs. /// * `filterId` - ID of the filter to be updated. - pub fn filters_update(&self, request: &Filter, account_id: &str, filter_id: &str) -> ManagementFilterUpdateCall<'a, C, A> { + pub fn filters_update(&self, request: Filter, account_id: &str, filter_id: &str) -> ManagementFilterUpdateCall<'a, C, A> { ManagementFilterUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _filter_id: filter_id.to_string(), _delegate: Default::default(), @@ -3824,10 +3826,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `webPropertyId` - Web property ID to update the goal. /// * `profileId` - View (Profile) ID to update the goal. /// * `goalId` - Index of the goal to be updated. - pub fn goals_patch(&self, request: &Goal, account_id: &str, web_property_id: &str, profile_id: &str, goal_id: &str) -> ManagementGoalPatchCall<'a, C, A> { + pub fn goals_patch(&self, request: Goal, account_id: &str, web_property_id: &str, profile_id: &str, goal_id: &str) -> ManagementGoalPatchCall<'a, C, A> { ManagementGoalPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _profile_id: profile_id.to_string(), @@ -3848,10 +3850,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `accountId` - Account ID for the custom dimension to update. /// * `webPropertyId` - Web property ID for the custom dimension to update. /// * `customDimensionId` - Custom dimension ID for the custom dimension to update. - pub fn custom_dimensions_patch(&self, request: &CustomDimension, account_id: &str, web_property_id: &str, custom_dimension_id: &str) -> ManagementCustomDimensionPatchCall<'a, C, A> { + pub fn custom_dimensions_patch(&self, request: CustomDimension, account_id: &str, web_property_id: &str, custom_dimension_id: &str) -> ManagementCustomDimensionPatchCall<'a, C, A> { ManagementCustomDimensionPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _custom_dimension_id: custom_dimension_id.to_string(), @@ -3873,10 +3875,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `webPropertyId` - Web property ID of the experiment to update. /// * `profileId` - View (Profile) ID of the experiment to update. /// * `experimentId` - Experiment ID of the experiment to update. - pub fn experiments_patch(&self, request: &Experiment, account_id: &str, web_property_id: &str, profile_id: &str, experiment_id: &str) -> ManagementExperimentPatchCall<'a, C, A> { + pub fn experiments_patch(&self, request: Experiment, account_id: &str, web_property_id: &str, profile_id: &str, experiment_id: &str) -> ManagementExperimentPatchCall<'a, C, A> { ManagementExperimentPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _profile_id: profile_id.to_string(), @@ -3964,10 +3966,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `accountId` - Account ID to create the goal for. /// * `webPropertyId` - Web property ID to create the goal for. /// * `profileId` - View (Profile) ID to create the goal for. - pub fn goals_insert(&self, request: &Goal, account_id: &str, web_property_id: &str, profile_id: &str) -> ManagementGoalInsertCall<'a, C, A> { + pub fn goals_insert(&self, request: Goal, account_id: &str, web_property_id: &str, profile_id: &str) -> ManagementGoalInsertCall<'a, C, A> { ManagementGoalInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _profile_id: profile_id.to_string(), @@ -3987,10 +3989,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `accountId` - Account ID for the custom metric to update. /// * `webPropertyId` - Web property ID for the custom metric to update. /// * `customMetricId` - Custom metric ID for the custom metric to update. - pub fn custom_metrics_patch(&self, request: &CustomMetric, account_id: &str, web_property_id: &str, custom_metric_id: &str) -> ManagementCustomMetricPatchCall<'a, C, A> { + pub fn custom_metrics_patch(&self, request: CustomMetric, account_id: &str, web_property_id: &str, custom_metric_id: &str) -> ManagementCustomMetricPatchCall<'a, C, A> { ManagementCustomMetricPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _custom_metric_id: custom_metric_id.to_string(), @@ -4030,10 +4032,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `accountId` - Account ID to create the user link for. - pub fn account_user_links_insert(&self, request: &EntityUserLink, account_id: &str) -> ManagementAccountUserLinkInsertCall<'a, C, A> { + pub fn account_user_links_insert(&self, request: EntityUserLink, account_id: &str) -> ManagementAccountUserLinkInsertCall<'a, C, A> { ManagementAccountUserLinkInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -4050,10 +4052,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `request` - No description provided. /// * `accountId` - Account ID to create the user link for. /// * `webPropertyId` - Web Property ID to create the user link for. - pub fn webproperty_user_links_insert(&self, request: &EntityUserLink, account_id: &str, web_property_id: &str) -> ManagementWebpropertyUserLinkInsertCall<'a, C, A> { + pub fn webproperty_user_links_insert(&self, request: EntityUserLink, account_id: &str, web_property_id: &str) -> ManagementWebpropertyUserLinkInsertCall<'a, C, A> { ManagementWebpropertyUserLinkInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _delegate: Default::default(), @@ -4095,10 +4097,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `accountId` - Account ID to which the view (profile) belongs /// * `webPropertyId` - Web property ID to which the view (profile) belongs /// * `profileId` - ID of the view (profile) to be updated. - pub fn profiles_patch(&self, request: &Profile, account_id: &str, web_property_id: &str, profile_id: &str) -> ManagementProfilePatchCall<'a, C, A> { + pub fn profiles_patch(&self, request: Profile, account_id: &str, web_property_id: &str, profile_id: &str) -> ManagementProfilePatchCall<'a, C, A> { ManagementProfilePatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _profile_id: profile_id.to_string(), @@ -4258,10 +4260,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `accountId` - Account ID for the custom metric to update. /// * `webPropertyId` - Web property ID for the custom metric to update. /// * `customMetricId` - Custom metric ID for the custom metric to update. - pub fn custom_metrics_update(&self, request: &CustomMetric, account_id: &str, web_property_id: &str, custom_metric_id: &str) -> ManagementCustomMetricUpdateCall<'a, C, A> { + pub fn custom_metrics_update(&self, request: CustomMetric, account_id: &str, web_property_id: &str, custom_metric_id: &str) -> ManagementCustomMetricUpdateCall<'a, C, A> { ManagementCustomMetricUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _custom_metric_id: custom_metric_id.to_string(), @@ -4282,10 +4284,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `accountId` - Account Id for the uploads to be deleted. /// * `webPropertyId` - Web property Id for the uploads to be deleted. /// * `customDataSourceId` - Custom data source Id for the uploads to be deleted. - pub fn uploads_delete_upload_data(&self, request: &AnalyticsDataimportDeleteUploadDataRequest, account_id: &str, web_property_id: &str, custom_data_source_id: &str) -> ManagementUploadDeleteUploadDataCall<'a, C, A> { + pub fn uploads_delete_upload_data(&self, request: AnalyticsDataimportDeleteUploadDataRequest, account_id: &str, web_property_id: &str, custom_data_source_id: &str) -> ManagementUploadDeleteUploadDataCall<'a, C, A> { ManagementUploadDeleteUploadDataCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _custom_data_source_id: custom_data_source_id.to_string(), @@ -4306,10 +4308,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `webPropertyId` - Web property ID of the experiment to update. /// * `profileId` - View (Profile) ID of the experiment to update. /// * `experimentId` - Experiment ID of the experiment to update. - pub fn experiments_update(&self, request: &Experiment, account_id: &str, web_property_id: &str, profile_id: &str, experiment_id: &str) -> ManagementExperimentUpdateCall<'a, C, A> { + pub fn experiments_update(&self, request: Experiment, account_id: &str, web_property_id: &str, profile_id: &str, experiment_id: &str) -> ManagementExperimentUpdateCall<'a, C, A> { ManagementExperimentUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _profile_id: profile_id.to_string(), @@ -4331,10 +4333,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `webPropertyId` - Web property ID to update the goal. /// * `profileId` - View (Profile) ID to update the goal. /// * `goalId` - Index of the goal to be updated. - pub fn goals_update(&self, request: &Goal, account_id: &str, web_property_id: &str, profile_id: &str, goal_id: &str) -> ManagementGoalUpdateCall<'a, C, A> { + pub fn goals_update(&self, request: Goal, account_id: &str, web_property_id: &str, profile_id: &str, goal_id: &str) -> ManagementGoalUpdateCall<'a, C, A> { ManagementGoalUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _profile_id: profile_id.to_string(), @@ -4439,10 +4441,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `accountId` - Account ID to create the experiment for. /// * `webPropertyId` - Web property ID to create the experiment for. /// * `profileId` - View (Profile) ID to create the experiment for. - pub fn experiments_insert(&self, request: &Experiment, account_id: &str, web_property_id: &str, profile_id: &str) -> ManagementExperimentInsertCall<'a, C, A> { + pub fn experiments_insert(&self, request: Experiment, account_id: &str, web_property_id: &str, profile_id: &str) -> ManagementExperimentInsertCall<'a, C, A> { ManagementExperimentInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _profile_id: profile_id.to_string(), @@ -4505,10 +4507,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `request` - No description provided. /// * `accountId` - Account ID to which the web property belongs /// * `webPropertyId` - Web property ID - pub fn webproperties_patch(&self, request: &Webproperty, account_id: &str, web_property_id: &str) -> ManagementWebpropertyPatchCall<'a, C, A> { + pub fn webproperties_patch(&self, request: Webproperty, account_id: &str, web_property_id: &str) -> ManagementWebpropertyPatchCall<'a, C, A> { ManagementWebpropertyPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _delegate: Default::default(), @@ -4526,10 +4528,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `request` - No description provided. /// * `accountId` - Account ID for the custom dimension to create. /// * `webPropertyId` - Web property ID for the custom dimension to create. - pub fn custom_dimensions_insert(&self, request: &CustomDimension, account_id: &str, web_property_id: &str) -> ManagementCustomDimensionInsertCall<'a, C, A> { + pub fn custom_dimensions_insert(&self, request: CustomDimension, account_id: &str, web_property_id: &str) -> ManagementCustomDimensionInsertCall<'a, C, A> { ManagementCustomDimensionInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _delegate: Default::default(), @@ -4547,10 +4549,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `request` - No description provided. /// * `accountId` - Account ID for the custom metric to create. /// * `webPropertyId` - Web property ID for the custom dimension to create. - pub fn custom_metrics_insert(&self, request: &CustomMetric, account_id: &str, web_property_id: &str) -> ManagementCustomMetricInsertCall<'a, C, A> { + pub fn custom_metrics_insert(&self, request: CustomMetric, account_id: &str, web_property_id: &str) -> ManagementCustomMetricInsertCall<'a, C, A> { ManagementCustomMetricInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _delegate: Default::default(), @@ -4569,10 +4571,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `accountId` - Account ID to create the user link for. /// * `webPropertyId` - Web Property ID to create the user link for. /// * `profileId` - View (Profile) ID to create the user link for. - pub fn profile_user_links_insert(&self, request: &EntityUserLink, account_id: &str, web_property_id: &str, profile_id: &str) -> ManagementProfileUserLinkInsertCall<'a, C, A> { + pub fn profile_user_links_insert(&self, request: EntityUserLink, account_id: &str, web_property_id: &str, profile_id: &str) -> ManagementProfileUserLinkInsertCall<'a, C, A> { ManagementProfileUserLinkInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _profile_id: profile_id.to_string(), @@ -4610,10 +4612,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `request` - No description provided. /// * `accountId` - ID of the Google Analytics account to create the link for. /// * `webPropertyId` - Web property ID to create the link for. - pub fn web_property_ad_words_links_insert(&self, request: &EntityAdWordsLink, account_id: &str, web_property_id: &str) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> { + pub fn web_property_ad_words_links_insert(&self, request: EntityAdWordsLink, account_id: &str, web_property_id: &str) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> { ManagementWebPropertyAdWordsLinkInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _delegate: Default::default(), @@ -4632,10 +4634,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `accountId` - ID of the account which the given web property belongs to. /// * `webPropertyId` - Web property ID to retrieve the AdWords link for. /// * `webPropertyAdWordsLinkId` - Web property-AdWords link ID. - pub fn web_property_ad_words_links_patch(&self, request: &EntityAdWordsLink, account_id: &str, web_property_id: &str, web_property_ad_words_link_id: &str) -> ManagementWebPropertyAdWordsLinkPatchCall<'a, C, A> { + pub fn web_property_ad_words_links_patch(&self, request: EntityAdWordsLink, account_id: &str, web_property_id: &str, web_property_ad_words_link_id: &str) -> ManagementWebPropertyAdWordsLinkPatchCall<'a, C, A> { ManagementWebPropertyAdWordsLinkPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _web_property_ad_words_link_id: web_property_ad_words_link_id.to_string(), @@ -4699,10 +4701,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `accountId` - ID of the account which the given web property belongs to. /// * `webPropertyId` - Web property ID to retrieve the AdWords link for. /// * `webPropertyAdWordsLinkId` - Web property-AdWords link ID. - pub fn web_property_ad_words_links_update(&self, request: &EntityAdWordsLink, account_id: &str, web_property_id: &str, web_property_ad_words_link_id: &str) -> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C, A> { + pub fn web_property_ad_words_links_update(&self, request: EntityAdWordsLink, account_id: &str, web_property_id: &str, web_property_ad_words_link_id: &str) -> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C, A> { ManagementWebPropertyAdWordsLinkUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _web_property_ad_words_link_id: web_property_ad_words_link_id.to_string(), @@ -4721,10 +4723,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `request` - No description provided. /// * `accountId` - Account ID to which the filter belongs. /// * `filterId` - ID of the filter to be updated. - pub fn filters_patch(&self, request: &Filter, account_id: &str, filter_id: &str) -> ManagementFilterPatchCall<'a, C, A> { + pub fn filters_patch(&self, request: Filter, account_id: &str, filter_id: &str) -> ManagementFilterPatchCall<'a, C, A> { ManagementFilterPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _filter_id: filter_id.to_string(), _delegate: Default::default(), @@ -4780,10 +4782,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `request` - No description provided. /// * `accountId` - Account ID to create the view (profile) for. /// * `webPropertyId` - Web property ID to create the view (profile) for. - pub fn profiles_insert(&self, request: &Profile, account_id: &str, web_property_id: &str) -> ManagementProfileInsertCall<'a, C, A> { + pub fn profiles_insert(&self, request: Profile, account_id: &str, web_property_id: &str) -> ManagementProfileInsertCall<'a, C, A> { ManagementProfileInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _delegate: Default::default(), @@ -4821,10 +4823,10 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// * `accountId` - Account ID to which the view (profile) belongs /// * `webPropertyId` - Web property ID to which the view (profile) belongs /// * `profileId` - ID of the view (profile) to be updated. - pub fn profiles_update(&self, request: &Profile, account_id: &str, web_property_id: &str, profile_id: &str) -> ManagementProfileUpdateCall<'a, C, A> { + pub fn profiles_update(&self, request: Profile, account_id: &str, web_property_id: &str, profile_id: &str) -> ManagementProfileUpdateCall<'a, C, A> { ManagementProfileUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), _profile_id: profile_id.to_string(), @@ -5029,10 +5031,10 @@ impl<'a, C, A> ProvisioningMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn create_account_ticket(&self, request: &AccountTicket) -> ProvisioningCreateAccountTicketCall<'a, C, A> { + pub fn create_account_ticket(&self, request: AccountTicket) -> ProvisioningCreateAccountTicketCall<'a, C, A> { ProvisioningCreateAccountTicketCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -5138,7 +5140,7 @@ impl<'a, C, A> MetadataMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.management().webproperties_insert(&req, "accountId") +/// let result = hub.management().webproperties_insert(req, "accountId") /// .doit(); /// # } /// ``` @@ -5266,12 +5268,17 @@ impl<'a, C, A> ManagementWebpropertyInsertCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5280,7 +5287,7 @@ impl<'a, C, A> ManagementWebpropertyInsertCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5298,8 +5305,8 @@ impl<'a, C, A> ManagementWebpropertyInsertCall<'a, C, A> where C: BorrowMut ManagementWebpropertyInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Webproperty) -> ManagementWebpropertyInsertCall<'a, C, A> { + self._request = new_value; self } /// Account ID to create the web property for. @@ -5513,12 +5520,17 @@ impl<'a, C, A> ManagementProfileGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5527,7 +5539,7 @@ impl<'a, C, A> ManagementProfileGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5751,12 +5763,17 @@ impl<'a, C, A> ManagementAccountListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5765,7 +5782,7 @@ impl<'a, C, A> ManagementAccountListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5876,7 +5893,7 @@ impl<'a, C, A> ManagementAccountListCall<'a, C, A> where C: BorrowMut ManagementProfileFilterLinkPatchCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6024,7 +6046,7 @@ impl<'a, C, A> ManagementProfileFilterLinkPatchCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6042,8 +6064,8 @@ impl<'a, C, A> ManagementProfileFilterLinkPatchCall<'a, C, A> where C: BorrowMut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ProfileFilterLink) -> ManagementProfileFilterLinkPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ProfileFilterLink) -> ManagementProfileFilterLinkPatchCall<'a, C, A> { + self._request = new_value; self } /// Account ID to which profile filter link belongs. @@ -6286,12 +6308,17 @@ impl<'a, C, A> ManagementWebpropertyUserLinkDeleteCall<'a, C, A> where C: Borrow if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -6535,12 +6562,17 @@ impl<'a, C, A> ManagementProfileUserLinkDeleteCall<'a, C, A> where C: BorrowMut< if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -6676,7 +6708,7 @@ impl<'a, C, A> ManagementProfileUserLinkDeleteCall<'a, C, A> where C: BorrowMut< /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.management().profile_user_links_update(&req, "accountId", "webPropertyId", "profileId", "linkId") +/// let result = hub.management().profile_user_links_update(req, "accountId", "webPropertyId", "profileId", "linkId") /// .doit(); /// # } /// ``` @@ -6810,12 +6842,17 @@ impl<'a, C, A> ManagementProfileUserLinkUpdateCall<'a, C, A> where C: BorrowMut< if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6824,7 +6861,7 @@ impl<'a, C, A> ManagementProfileUserLinkUpdateCall<'a, C, A> where C: BorrowMut< Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6842,8 +6879,8 @@ impl<'a, C, A> ManagementProfileUserLinkUpdateCall<'a, C, A> where C: BorrowMut< /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &EntityUserLink) -> ManagementProfileUserLinkUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: EntityUserLink) -> ManagementProfileUserLinkUpdateCall<'a, C, A> { + self._request = new_value; self } /// Account ID to update the user link for. @@ -6970,7 +7007,7 @@ impl<'a, C, A> ManagementProfileUserLinkUpdateCall<'a, C, A> where C: BorrowMut< /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.management().filters_insert(&req, "accountId") +/// let result = hub.management().filters_insert(req, "accountId") /// .doit(); /// # } /// ``` @@ -7098,12 +7135,17 @@ impl<'a, C, A> ManagementFilterInsertCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7112,7 +7154,7 @@ impl<'a, C, A> ManagementFilterInsertCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7130,8 +7172,8 @@ impl<'a, C, A> ManagementFilterInsertCall<'a, C, A> where C: BorrowMut ManagementFilterInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Filter) -> ManagementFilterInsertCall<'a, C, A> { + self._request = new_value; self } /// Account ID to create filter for. @@ -7228,7 +7270,7 @@ impl<'a, C, A> ManagementFilterInsertCall<'a, C, A> where C: BorrowMut ManagementAccountUserLinkUpdateCall<'a, C, A> where C: BorrowMut< if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7372,7 +7419,7 @@ impl<'a, C, A> ManagementAccountUserLinkUpdateCall<'a, C, A> where C: BorrowMut< Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7390,8 +7437,8 @@ impl<'a, C, A> ManagementAccountUserLinkUpdateCall<'a, C, A> where C: BorrowMut< /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &EntityUserLink) -> ManagementAccountUserLinkUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: EntityUserLink) -> ManagementAccountUserLinkUpdateCall<'a, C, A> { + self._request = new_value; self } /// Account ID to update the account-user link for. @@ -7498,7 +7545,7 @@ impl<'a, C, A> ManagementAccountUserLinkUpdateCall<'a, C, A> where C: BorrowMut< /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.management().webproperties_update(&req, "accountId", "webPropertyId") +/// let result = hub.management().webproperties_update(req, "accountId", "webPropertyId") /// .doit(); /// # } /// ``` @@ -7628,12 +7675,17 @@ impl<'a, C, A> ManagementWebpropertyUpdateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7642,7 +7694,7 @@ impl<'a, C, A> ManagementWebpropertyUpdateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7660,8 +7712,8 @@ impl<'a, C, A> ManagementWebpropertyUpdateCall<'a, C, A> where C: BorrowMut ManagementWebpropertyUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Webproperty) -> ManagementWebpropertyUpdateCall<'a, C, A> { + self._request = new_value; self } /// Account ID to which the web property belongs @@ -7768,7 +7820,7 @@ impl<'a, C, A> ManagementWebpropertyUpdateCall<'a, C, A> where C: BorrowMut ManagementWebpropertyUserLinkUpdateCall<'a, C, A> where C: Borrow if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7914,7 +7971,7 @@ impl<'a, C, A> ManagementWebpropertyUserLinkUpdateCall<'a, C, A> where C: Borrow Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7932,8 +7989,8 @@ impl<'a, C, A> ManagementWebpropertyUserLinkUpdateCall<'a, C, A> where C: Borrow /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &EntityUserLink) -> ManagementWebpropertyUserLinkUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: EntityUserLink) -> ManagementWebpropertyUserLinkUpdateCall<'a, C, A> { + self._request = new_value; self } /// Account ID to update the account-user link for. @@ -8050,7 +8107,7 @@ impl<'a, C, A> ManagementWebpropertyUserLinkUpdateCall<'a, C, A> where C: Borrow /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.management().unsampled_reports_insert(&req, "accountId", "webPropertyId", "profileId") +/// let result = hub.management().unsampled_reports_insert(req, "accountId", "webPropertyId", "profileId") /// .doit(); /// # } /// ``` @@ -8182,12 +8239,17 @@ impl<'a, C, A> ManagementUnsampledReportInsertCall<'a, C, A> where C: BorrowMut< if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8196,7 +8258,7 @@ impl<'a, C, A> ManagementUnsampledReportInsertCall<'a, C, A> where C: BorrowMut< Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8214,8 +8276,8 @@ impl<'a, C, A> ManagementUnsampledReportInsertCall<'a, C, A> where C: BorrowMut< /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &UnsampledReport) -> ManagementUnsampledReportInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: UnsampledReport) -> ManagementUnsampledReportInsertCall<'a, C, A> { + self._request = new_value; self } /// Account ID to create the unsampled report for. @@ -8449,12 +8511,17 @@ impl<'a, C, A> ManagementCustomMetricGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8463,7 +8530,7 @@ impl<'a, C, A> ManagementCustomMetricGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8709,12 +8776,17 @@ impl<'a, C, A> ManagementUploadGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8723,7 +8795,7 @@ impl<'a, C, A> ManagementUploadGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8977,12 +9049,17 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> where C: Borrow if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8991,7 +9068,7 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> where C: Borrow Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9243,12 +9320,17 @@ impl<'a, C, A> ManagementWebpropertyUserLinkListCall<'a, C, A> where C: BorrowMu if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9257,7 +9339,7 @@ impl<'a, C, A> ManagementWebpropertyUserLinkListCall<'a, C, A> where C: BorrowMu Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9388,7 +9470,7 @@ impl<'a, C, A> ManagementWebpropertyUserLinkListCall<'a, C, A> where C: BorrowMu /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.management().profile_filter_links_update(&req, "accountId", "webPropertyId", "profileId", "linkId") +/// let result = hub.management().profile_filter_links_update(req, "accountId", "webPropertyId", "profileId", "linkId") /// .doit(); /// # } /// ``` @@ -9522,12 +9604,17 @@ impl<'a, C, A> ManagementProfileFilterLinkUpdateCall<'a, C, A> where C: BorrowMu if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9536,7 +9623,7 @@ impl<'a, C, A> ManagementProfileFilterLinkUpdateCall<'a, C, A> where C: BorrowMu Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9554,8 +9641,8 @@ impl<'a, C, A> ManagementProfileFilterLinkUpdateCall<'a, C, A> where C: BorrowMu /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ProfileFilterLink) -> ManagementProfileFilterLinkUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ProfileFilterLink) -> ManagementProfileFilterLinkUpdateCall<'a, C, A> { + self._request = new_value; self } /// Account ID to which profile filter link belongs. @@ -9801,12 +9888,17 @@ impl<'a, C, A> ManagementExperimentGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9815,7 +9907,7 @@ impl<'a, C, A> ManagementExperimentGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9952,7 +10044,7 @@ impl<'a, C, A> ManagementExperimentGetCall<'a, C, A> where C: BorrowMut ManagementCustomDimensionUpdateCall<'a, C, A> where C: BorrowMut< if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10103,7 +10200,7 @@ impl<'a, C, A> ManagementCustomDimensionUpdateCall<'a, C, A> where C: BorrowMut< Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10121,8 +10218,8 @@ impl<'a, C, A> ManagementCustomDimensionUpdateCall<'a, C, A> where C: BorrowMut< /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &CustomDimension) -> ManagementCustomDimensionUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CustomDimension) -> ManagementCustomDimensionUpdateCall<'a, C, A> { + self._request = new_value; self } /// Account ID for the custom dimension to update. @@ -10365,12 +10462,17 @@ impl<'a, C, A> ManagementUnsampledReportGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10379,7 +10481,7 @@ impl<'a, C, A> ManagementUnsampledReportGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10516,7 +10618,7 @@ impl<'a, C, A> ManagementUnsampledReportGetCall<'a, C, A> where C: BorrowMut ManagementProfileFilterLinkInsertCall<'a, C, A> where C: BorrowMu if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10662,7 +10769,7 @@ impl<'a, C, A> ManagementProfileFilterLinkInsertCall<'a, C, A> where C: BorrowMu Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10680,8 +10787,8 @@ impl<'a, C, A> ManagementProfileFilterLinkInsertCall<'a, C, A> where C: BorrowMu /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ProfileFilterLink) -> ManagementProfileFilterLinkInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ProfileFilterLink) -> ManagementProfileFilterLinkInsertCall<'a, C, A> { + self._request = new_value; self } /// Account ID to create profile filter link for. @@ -10798,7 +10905,7 @@ impl<'a, C, A> ManagementProfileFilterLinkInsertCall<'a, C, A> where C: BorrowMu /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.management().filters_update(&req, "accountId", "filterId") +/// let result = hub.management().filters_update(req, "accountId", "filterId") /// .doit(); /// # } /// ``` @@ -10928,12 +11035,17 @@ impl<'a, C, A> ManagementFilterUpdateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10942,7 +11054,7 @@ impl<'a, C, A> ManagementFilterUpdateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10960,8 +11072,8 @@ impl<'a, C, A> ManagementFilterUpdateCall<'a, C, A> where C: BorrowMut ManagementFilterUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Filter) -> ManagementFilterUpdateCall<'a, C, A> { + self._request = new_value; self } /// Account ID to which the filter belongs. @@ -11186,12 +11298,17 @@ impl<'a, C, A> ManagementProfileFilterLinkDeleteCall<'a, C, A> where C: BorrowMu if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -11424,12 +11541,17 @@ impl<'a, C, A> ManagementSegmentListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11438,7 +11560,7 @@ impl<'a, C, A> ManagementSegmentListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11665,12 +11787,17 @@ impl<'a, C, A> ManagementProfileDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -11796,7 +11923,7 @@ impl<'a, C, A> ManagementProfileDeleteCall<'a, C, A> where C: BorrowMut ManagementGoalPatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11944,7 +12076,7 @@ impl<'a, C, A> ManagementGoalPatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11962,8 +12094,8 @@ impl<'a, C, A> ManagementGoalPatchCall<'a, C, A> where C: BorrowMut ManagementGoalPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Goal) -> ManagementGoalPatchCall<'a, C, A> { + self._request = new_value; self } /// Account ID to update the goal. @@ -12090,7 +12222,7 @@ impl<'a, C, A> ManagementGoalPatchCall<'a, C, A> where C: BorrowMut ManagementCustomDimensionPatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12241,7 +12378,7 @@ impl<'a, C, A> ManagementCustomDimensionPatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12259,8 +12396,8 @@ impl<'a, C, A> ManagementCustomDimensionPatchCall<'a, C, A> where C: BorrowMut ManagementCustomDimensionPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CustomDimension) -> ManagementCustomDimensionPatchCall<'a, C, A> { + self._request = new_value; self } /// Account ID for the custom dimension to update. @@ -12384,7 +12521,7 @@ impl<'a, C, A> ManagementCustomDimensionPatchCall<'a, C, A> where C: BorrowMut ManagementExperimentPatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12532,7 +12674,7 @@ impl<'a, C, A> ManagementExperimentPatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12550,8 +12692,8 @@ impl<'a, C, A> ManagementExperimentPatchCall<'a, C, A> where C: BorrowMut ManagementExperimentPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Experiment) -> ManagementExperimentPatchCall<'a, C, A> { + self._request = new_value; self } /// Account ID of the experiment to update. @@ -12805,12 +12947,17 @@ impl<'a, C, A> ManagementExperimentListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12819,7 +12966,7 @@ impl<'a, C, A> ManagementExperimentListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13085,12 +13232,17 @@ impl<'a, C, A> ManagementProfileListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13099,7 +13251,7 @@ impl<'a, C, A> ManagementProfileListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13357,12 +13509,17 @@ impl<'a, C, A> ManagementGoalListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13371,7 +13528,7 @@ impl<'a, C, A> ManagementGoalListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13512,7 +13669,7 @@ impl<'a, C, A> ManagementGoalListCall<'a, C, A> where C: BorrowMut ManagementGoalInsertCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13658,7 +13820,7 @@ impl<'a, C, A> ManagementGoalInsertCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13676,8 +13838,8 @@ impl<'a, C, A> ManagementGoalInsertCall<'a, C, A> where C: BorrowMut ManagementGoalInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Goal) -> ManagementGoalInsertCall<'a, C, A> { + self._request = new_value; self } /// Account ID to create the goal for. @@ -13794,7 +13956,7 @@ impl<'a, C, A> ManagementGoalInsertCall<'a, C, A> where C: BorrowMut ManagementCustomMetricPatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13945,7 +14112,7 @@ impl<'a, C, A> ManagementCustomMetricPatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13963,8 +14130,8 @@ impl<'a, C, A> ManagementCustomMetricPatchCall<'a, C, A> where C: BorrowMut ManagementCustomMetricPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CustomMetric) -> ManagementCustomMetricPatchCall<'a, C, A> { + self._request = new_value; self } /// Account ID for the custom metric to update. @@ -14132,14 +14299,15 @@ impl<'a, C, A> ManagementUploadUploadDataCall<'a, C, A> where C: BorrowMut ManagementUploadUploadDataCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -14260,9 +14433,9 @@ impl<'a, C, A> ManagementUploadUploadDataCall<'a, C, A> where C: BorrowMut().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -14272,7 +14445,7 @@ impl<'a, C, A> ManagementUploadUploadDataCall<'a, C, A> where C: BorrowMut ManagementUploadUploadDataCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14456,7 +14629,7 @@ impl<'a, C, A> ManagementUploadUploadDataCall<'a, C, A> where C: BorrowMut ManagementAccountUserLinkInsertCall<'a, C, A> where C: BorrowMut< if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14598,7 +14776,7 @@ impl<'a, C, A> ManagementAccountUserLinkInsertCall<'a, C, A> where C: BorrowMut< Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14616,8 +14794,8 @@ impl<'a, C, A> ManagementAccountUserLinkInsertCall<'a, C, A> where C: BorrowMut< /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &EntityUserLink) -> ManagementAccountUserLinkInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: EntityUserLink) -> ManagementAccountUserLinkInsertCall<'a, C, A> { + self._request = new_value; self } /// Account ID to create the user link for. @@ -14714,7 +14892,7 @@ impl<'a, C, A> ManagementAccountUserLinkInsertCall<'a, C, A> where C: BorrowMut< /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.management().webproperty_user_links_insert(&req, "accountId", "webPropertyId") +/// let result = hub.management().webproperty_user_links_insert(req, "accountId", "webPropertyId") /// .doit(); /// # } /// ``` @@ -14844,12 +15022,17 @@ impl<'a, C, A> ManagementWebpropertyUserLinkInsertCall<'a, C, A> where C: Borrow if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14858,7 +15041,7 @@ impl<'a, C, A> ManagementWebpropertyUserLinkInsertCall<'a, C, A> where C: Borrow Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14876,8 +15059,8 @@ impl<'a, C, A> ManagementWebpropertyUserLinkInsertCall<'a, C, A> where C: Borrow /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &EntityUserLink) -> ManagementWebpropertyUserLinkInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: EntityUserLink) -> ManagementWebpropertyUserLinkInsertCall<'a, C, A> { + self._request = new_value; self } /// Account ID to create the user link for. @@ -15102,12 +15285,17 @@ impl<'a, C, A> ManagementExperimentDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -15243,7 +15431,7 @@ impl<'a, C, A> ManagementExperimentDeleteCall<'a, C, A> where C: BorrowMut ManagementProfilePatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15389,7 +15582,7 @@ impl<'a, C, A> ManagementProfilePatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15407,8 +15600,8 @@ impl<'a, C, A> ManagementProfilePatchCall<'a, C, A> where C: BorrowMut ManagementProfilePatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Profile) -> ManagementProfilePatchCall<'a, C, A> { + self._request = new_value; self } /// Account ID to which the view (profile) belongs @@ -15640,12 +15833,17 @@ impl<'a, C, A> ManagementFilterGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15654,7 +15852,7 @@ impl<'a, C, A> ManagementFilterGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15896,12 +16094,17 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkListCall<'a, C, A> where C: Borro if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15910,7 +16113,7 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkListCall<'a, C, A> where C: Borro Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16138,12 +16341,17 @@ impl<'a, C, A> ManagementAccountSummaryListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16152,7 +16360,7 @@ impl<'a, C, A> ManagementAccountSummaryListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16388,12 +16596,17 @@ impl<'a, C, A> ManagementCustomDimensionListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16402,7 +16615,7 @@ impl<'a, C, A> ManagementCustomDimensionListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16660,12 +16873,17 @@ impl<'a, C, A> ManagementUploadListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16674,7 +16892,7 @@ impl<'a, C, A> ManagementUploadListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16942,12 +17160,17 @@ impl<'a, C, A> ManagementProfileUserLinkListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16956,7 +17179,7 @@ impl<'a, C, A> ManagementProfileUserLinkListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -17220,12 +17443,17 @@ impl<'a, C, A> ManagementAccountUserLinkListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -17234,7 +17462,7 @@ impl<'a, C, A> ManagementAccountUserLinkListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -17355,7 +17583,7 @@ impl<'a, C, A> ManagementAccountUserLinkListCall<'a, C, A> where C: BorrowMut ManagementCustomMetricUpdateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -17506,7 +17739,7 @@ impl<'a, C, A> ManagementCustomMetricUpdateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -17524,8 +17757,8 @@ impl<'a, C, A> ManagementCustomMetricUpdateCall<'a, C, A> where C: BorrowMut ManagementCustomMetricUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CustomMetric) -> ManagementCustomMetricUpdateCall<'a, C, A> { + self._request = new_value; self } /// Account ID for the custom metric to update. @@ -17649,7 +17882,7 @@ impl<'a, C, A> ManagementCustomMetricUpdateCall<'a, C, A> where C: BorrowMut ManagementUploadDeleteUploadDataCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -17802,8 +18040,8 @@ impl<'a, C, A> ManagementUploadDeleteUploadDataCall<'a, C, A> where C: BorrowMut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AnalyticsDataimportDeleteUploadDataRequest) -> ManagementUploadDeleteUploadDataCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AnalyticsDataimportDeleteUploadDataRequest) -> ManagementUploadDeleteUploadDataCall<'a, C, A> { + self._request = new_value; self } /// Account Id for the uploads to be deleted. @@ -17920,7 +18158,7 @@ impl<'a, C, A> ManagementUploadDeleteUploadDataCall<'a, C, A> where C: BorrowMut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.management().experiments_update(&req, "accountId", "webPropertyId", "profileId", "experimentId") +/// let result = hub.management().experiments_update(req, "accountId", "webPropertyId", "profileId", "experimentId") /// .doit(); /// # } /// ``` @@ -18054,12 +18292,17 @@ impl<'a, C, A> ManagementExperimentUpdateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -18068,7 +18311,7 @@ impl<'a, C, A> ManagementExperimentUpdateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -18086,8 +18329,8 @@ impl<'a, C, A> ManagementExperimentUpdateCall<'a, C, A> where C: BorrowMut ManagementExperimentUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Experiment) -> ManagementExperimentUpdateCall<'a, C, A> { + self._request = new_value; self } /// Account ID of the experiment to update. @@ -18214,7 +18457,7 @@ impl<'a, C, A> ManagementExperimentUpdateCall<'a, C, A> where C: BorrowMut ManagementGoalUpdateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -18362,7 +18610,7 @@ impl<'a, C, A> ManagementGoalUpdateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -18380,8 +18628,8 @@ impl<'a, C, A> ManagementGoalUpdateCall<'a, C, A> where C: BorrowMut ManagementGoalUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Goal) -> ManagementGoalUpdateCall<'a, C, A> { + self._request = new_value; self } /// Account ID to update the goal. @@ -18633,12 +18881,17 @@ impl<'a, C, A> ManagementCustomDataSourceListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -18647,7 +18900,7 @@ impl<'a, C, A> ManagementCustomDataSourceListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -18903,12 +19156,17 @@ impl<'a, C, A> ManagementCustomMetricListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -18917,7 +19175,7 @@ impl<'a, C, A> ManagementCustomMetricListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -19175,12 +19433,17 @@ impl<'a, C, A> ManagementUnsampledReportListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -19189,7 +19452,7 @@ impl<'a, C, A> ManagementUnsampledReportListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -19445,12 +19708,17 @@ impl<'a, C, A> ManagementWebpropertyGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -19459,7 +19727,7 @@ impl<'a, C, A> ManagementWebpropertyGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -19576,7 +19844,7 @@ impl<'a, C, A> ManagementWebpropertyGetCall<'a, C, A> where C: BorrowMut ManagementExperimentInsertCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -19722,7 +19995,7 @@ impl<'a, C, A> ManagementExperimentInsertCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -19740,8 +20013,8 @@ impl<'a, C, A> ManagementExperimentInsertCall<'a, C, A> where C: BorrowMut ManagementExperimentInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Experiment) -> ManagementExperimentInsertCall<'a, C, A> { + self._request = new_value; self } /// Account ID to create the experiment for. @@ -19975,12 +20248,17 @@ impl<'a, C, A> ManagementCustomDimensionGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -19989,7 +20267,7 @@ impl<'a, C, A> ManagementCustomDimensionGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -20243,12 +20521,17 @@ impl<'a, C, A> ManagementProfileFilterLinkListCall<'a, C, A> where C: BorrowMut< if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -20257,7 +20540,7 @@ impl<'a, C, A> ManagementProfileFilterLinkListCall<'a, C, A> where C: BorrowMut< Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -20398,7 +20681,7 @@ impl<'a, C, A> ManagementProfileFilterLinkListCall<'a, C, A> where C: BorrowMut< /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.management().webproperties_patch(&req, "accountId", "webPropertyId") +/// let result = hub.management().webproperties_patch(req, "accountId", "webPropertyId") /// .doit(); /// # } /// ``` @@ -20528,12 +20811,17 @@ impl<'a, C, A> ManagementWebpropertyPatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -20542,7 +20830,7 @@ impl<'a, C, A> ManagementWebpropertyPatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -20560,8 +20848,8 @@ impl<'a, C, A> ManagementWebpropertyPatchCall<'a, C, A> where C: BorrowMut ManagementWebpropertyPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Webproperty) -> ManagementWebpropertyPatchCall<'a, C, A> { + self._request = new_value; self } /// Account ID to which the web property belongs @@ -20668,7 +20956,7 @@ impl<'a, C, A> ManagementWebpropertyPatchCall<'a, C, A> where C: BorrowMut ManagementCustomDimensionInsertCall<'a, C, A> where C: BorrowMut< if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -20812,7 +21105,7 @@ impl<'a, C, A> ManagementCustomDimensionInsertCall<'a, C, A> where C: BorrowMut< Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -20830,8 +21123,8 @@ impl<'a, C, A> ManagementCustomDimensionInsertCall<'a, C, A> where C: BorrowMut< /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &CustomDimension) -> ManagementCustomDimensionInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CustomDimension) -> ManagementCustomDimensionInsertCall<'a, C, A> { + self._request = new_value; self } /// Account ID for the custom dimension to create. @@ -20938,7 +21231,7 @@ impl<'a, C, A> ManagementCustomDimensionInsertCall<'a, C, A> where C: BorrowMut< /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.management().custom_metrics_insert(&req, "accountId", "webPropertyId") +/// let result = hub.management().custom_metrics_insert(req, "accountId", "webPropertyId") /// .doit(); /// # } /// ``` @@ -21068,12 +21361,17 @@ impl<'a, C, A> ManagementCustomMetricInsertCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -21082,7 +21380,7 @@ impl<'a, C, A> ManagementCustomMetricInsertCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -21100,8 +21398,8 @@ impl<'a, C, A> ManagementCustomMetricInsertCall<'a, C, A> where C: BorrowMut ManagementCustomMetricInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CustomMetric) -> ManagementCustomMetricInsertCall<'a, C, A> { + self._request = new_value; self } /// Account ID for the custom metric to create. @@ -21208,7 +21506,7 @@ impl<'a, C, A> ManagementCustomMetricInsertCall<'a, C, A> where C: BorrowMut ManagementProfileUserLinkInsertCall<'a, C, A> where C: BorrowMut< if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -21354,7 +21657,7 @@ impl<'a, C, A> ManagementProfileUserLinkInsertCall<'a, C, A> where C: BorrowMut< Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -21372,8 +21675,8 @@ impl<'a, C, A> ManagementProfileUserLinkInsertCall<'a, C, A> where C: BorrowMut< /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &EntityUserLink) -> ManagementProfileUserLinkInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: EntityUserLink) -> ManagementProfileUserLinkInsertCall<'a, C, A> { + self._request = new_value; self } /// Account ID to create the user link for. @@ -21613,12 +21916,17 @@ impl<'a, C, A> ManagementWebpropertyListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -21627,7 +21935,7 @@ impl<'a, C, A> ManagementWebpropertyListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -21748,7 +22056,7 @@ impl<'a, C, A> ManagementWebpropertyListCall<'a, C, A> where C: BorrowMut ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> where C: Bor if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -21892,7 +22205,7 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> where C: Bor Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -21910,8 +22223,8 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> where C: Bor /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &EntityAdWordsLink) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: EntityAdWordsLink) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> { + self._request = new_value; self } /// ID of the Google Analytics account to create the link for. @@ -22018,7 +22331,7 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> where C: Bor /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.management().web_property_ad_words_links_patch(&req, "accountId", "webPropertyId", "webPropertyAdWordsLinkId") +/// let result = hub.management().web_property_ad_words_links_patch(req, "accountId", "webPropertyId", "webPropertyAdWordsLinkId") /// .doit(); /// # } /// ``` @@ -22150,12 +22463,17 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkPatchCall<'a, C, A> where C: Borr if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -22164,7 +22482,7 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkPatchCall<'a, C, A> where C: Borr Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -22182,8 +22500,8 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkPatchCall<'a, C, A> where C: Borr /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &EntityAdWordsLink) -> ManagementWebPropertyAdWordsLinkPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: EntityAdWordsLink) -> ManagementWebPropertyAdWordsLinkPatchCall<'a, C, A> { + self._request = new_value; self } /// ID of the account which the given web property belongs to. @@ -22419,12 +22737,17 @@ impl<'a, C, A> ManagementGoalGetCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -22433,7 +22756,7 @@ impl<'a, C, A> ManagementGoalGetCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -22686,12 +23009,17 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> where C: Bor if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -22817,7 +23145,7 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> where C: Bor /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.management().web_property_ad_words_links_update(&req, "accountId", "webPropertyId", "webPropertyAdWordsLinkId") +/// let result = hub.management().web_property_ad_words_links_update(req, "accountId", "webPropertyId", "webPropertyAdWordsLinkId") /// .doit(); /// # } /// ``` @@ -22949,12 +23277,17 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C, A> where C: Bor if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -22963,7 +23296,7 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C, A> where C: Bor Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -22981,8 +23314,8 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C, A> where C: Bor /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &EntityAdWordsLink) -> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: EntityAdWordsLink) -> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C, A> { + self._request = new_value; self } /// ID of the account which the given web property belongs to. @@ -23099,7 +23432,7 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C, A> where C: Bor /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.management().filters_patch(&req, "accountId", "filterId") +/// let result = hub.management().filters_patch(req, "accountId", "filterId") /// .doit(); /// # } /// ``` @@ -23229,12 +23562,17 @@ impl<'a, C, A> ManagementFilterPatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -23243,7 +23581,7 @@ impl<'a, C, A> ManagementFilterPatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -23261,8 +23599,8 @@ impl<'a, C, A> ManagementFilterPatchCall<'a, C, A> where C: BorrowMut ManagementFilterPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Filter) -> ManagementFilterPatchCall<'a, C, A> { + self._request = new_value; self } /// Account ID to which the filter belongs. @@ -23492,12 +23830,17 @@ impl<'a, C, A> ManagementFilterListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -23506,7 +23849,7 @@ impl<'a, C, A> ManagementFilterListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -23742,12 +24085,17 @@ impl<'a, C, A> ManagementFilterDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -23756,7 +24104,7 @@ impl<'a, C, A> ManagementFilterDeleteCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -23873,7 +24221,7 @@ impl<'a, C, A> ManagementFilterDeleteCall<'a, C, A> where C: BorrowMut ManagementProfileInsertCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -24017,7 +24370,7 @@ impl<'a, C, A> ManagementProfileInsertCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -24035,8 +24388,8 @@ impl<'a, C, A> ManagementProfileInsertCall<'a, C, A> where C: BorrowMut ManagementProfileInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Profile) -> ManagementProfileInsertCall<'a, C, A> { + self._request = new_value; self } /// Account ID to create the view (profile) for. @@ -24257,12 +24610,17 @@ impl<'a, C, A> ManagementAccountUserLinkDeleteCall<'a, C, A> where C: BorrowMut< if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -24378,7 +24736,7 @@ impl<'a, C, A> ManagementAccountUserLinkDeleteCall<'a, C, A> where C: BorrowMut< /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.management().profiles_update(&req, "accountId", "webPropertyId", "profileId") +/// let result = hub.management().profiles_update(req, "accountId", "webPropertyId", "profileId") /// .doit(); /// # } /// ``` @@ -24510,12 +24868,17 @@ impl<'a, C, A> ManagementProfileUpdateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -24524,7 +24887,7 @@ impl<'a, C, A> ManagementProfileUpdateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -24542,8 +24905,8 @@ impl<'a, C, A> ManagementProfileUpdateCall<'a, C, A> where C: BorrowMut ManagementProfileUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Profile) -> ManagementProfileUpdateCall<'a, C, A> { + self._request = new_value; self } /// Account ID to which the view (profile) belongs @@ -24779,12 +25142,17 @@ impl<'a, C, A> ManagementProfileFilterLinkGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -24793,7 +25161,7 @@ impl<'a, C, A> ManagementProfileFilterLinkGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -25055,12 +25423,17 @@ impl<'a, C, A> DataMcfGetCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -25069,7 +25442,7 @@ impl<'a, C, A> DataMcfGetCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -25383,12 +25756,17 @@ impl<'a, C, A> DataGaGetCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -25397,7 +25775,7 @@ impl<'a, C, A> DataGaGetCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -25701,12 +26079,17 @@ impl<'a, C, A> DataRealtimeGetCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -25715,7 +26098,7 @@ impl<'a, C, A> DataRealtimeGetCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -25860,7 +26243,7 @@ impl<'a, C, A> DataRealtimeGetCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.provisioning().create_account_ticket(&req) +/// let result = hub.provisioning().create_account_ticket(req) /// .doit(); /// # } /// ``` @@ -25962,12 +26345,17 @@ impl<'a, C, A> ProvisioningCreateAccountTicketCall<'a, C, A> where C: BorrowMut< if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -25976,7 +26364,7 @@ impl<'a, C, A> ProvisioningCreateAccountTicketCall<'a, C, A> where C: BorrowMut< Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -25994,8 +26382,8 @@ impl<'a, C, A> ProvisioningCreateAccountTicketCall<'a, C, A> where C: BorrowMut< /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AccountTicket) -> ProvisioningCreateAccountTicketCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AccountTicket) -> ProvisioningCreateAccountTicketCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -26195,12 +26583,17 @@ impl<'a, C, A> MetadataColumnListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -26209,7 +26602,7 @@ impl<'a, C, A> MetadataColumnListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/androidenterprise1-cli/Cargo.toml b/gen/androidenterprise1-cli/Cargo.toml index 33a95f9dd1..d2570d5bb0 100644 --- a/gen/androidenterprise1-cli/Cargo.toml +++ b/gen/androidenterprise1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-androidenterprise1-cli" -version = "0.0.1+20150309" +version = "0.1.0+20150309" authors = ["Sebastian Thiel "] description = "A complete library to interact with Android Enterprise (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/androidenterprise1-cli" diff --git a/gen/androidenterprise1-cli/README.md b/gen/androidenterprise1-cli/README.md index 9339062bb6..bde6ec1c48 100644 --- a/gen/androidenterprise1-cli/README.md +++ b/gen/androidenterprise1-cli/README.md @@ -1,4 +1,145 @@ -# HELLO ANDROIDENTERPRISE:V1 + +The `androidenterprise1` command-line interface *(CLI)* allows to use most features of the *Google Android Enterprise* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *Android Enterprise* API at revision *20150309*. The CLI is at version *0.1.0*. + +```bash + androidenterprise1 [options] collections delete [-p ...] + androidenterprise1 [options] collections get [-p ...] [-o ] + androidenterprise1 [options] collections insert -r ... [-p ...] [-o ] + androidenterprise1 [options] collections list [-p ...] [-o ] + androidenterprise1 [options] collections patch -r ... [-p ...] [-o ] + androidenterprise1 [options] collections update -r ... [-p ...] [-o ] + androidenterprise1 [options] collectionviewers delete [-p ...] + androidenterprise1 [options] collectionviewers get [-p ...] [-o ] + androidenterprise1 [options] collectionviewers list [-p ...] [-o ] + androidenterprise1 [options] collectionviewers patch -r ... [-p ...] [-o ] + androidenterprise1 [options] collectionviewers update -r ... [-p ...] [-o ] + androidenterprise1 [options] devices get [-p ...] [-o ] + androidenterprise1 [options] devices get-state [-p ...] [-o ] + androidenterprise1 [options] devices list [-p ...] [-o ] + androidenterprise1 [options] devices set-state -r ... [-p ...] [-o ] + androidenterprise1 [options] enterprises delete [-p ...] + androidenterprise1 [options] enterprises enroll -r ... [-p ...] [-o ] + androidenterprise1 [options] enterprises get [-p ...] [-o ] + androidenterprise1 [options] enterprises insert -r ... [-p ...] [-o ] + androidenterprise1 [options] enterprises list [-p ...] [-o ] + androidenterprise1 [options] enterprises set-account -r ... [-p ...] [-o ] + androidenterprise1 [options] enterprises unenroll [-p ...] + androidenterprise1 [options] entitlements delete [-p ...] + androidenterprise1 [options] entitlements get [-p ...] [-o ] + androidenterprise1 [options] entitlements list [-p ...] [-o ] + androidenterprise1 [options] entitlements patch -r ... [-p ...] [-o ] + androidenterprise1 [options] entitlements update -r ... [-p ...] [-o ] + androidenterprise1 [options] grouplicenses get [-p ...] [-o ] + androidenterprise1 [options] grouplicenses list [-p ...] [-o ] + androidenterprise1 [options] grouplicenseusers list [-p ...] [-o ] + androidenterprise1 [options] installs delete [-p ...] + androidenterprise1 [options] installs get [-p ...] [-o ] + androidenterprise1 [options] installs list [-p ...] [-o ] + androidenterprise1 [options] installs patch -r ... [-p ...] [-o ] + androidenterprise1 [options] installs update -r ... [-p ...] [-o ] + androidenterprise1 [options] permissions get [-p ...] [-o ] + androidenterprise1 [options] products get [-p ...] [-o ] + androidenterprise1 [options] products get-app-restrictions-schema [-p ...] [-o ] + androidenterprise1 [options] products get-permissions [-p ...] [-o ] + androidenterprise1 [options] products update-permissions -r ... [-p ...] [-o ] + androidenterprise1 [options] users generate-token [-p ...] [-o ] + androidenterprise1 [options] users get [-p ...] [-o ] + androidenterprise1 [options] users list [-p ...] [-o ] + androidenterprise1 [options] users revoke-token [-p ...] + androidenterprise1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/index.html + +Configuration: + --scope + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `androidenterprise1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/androidenterprise1-token-.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/androidenterprise1-secret.json`, assuming that the required *androidenterprise* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `androidenterprise1 --debug [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/androidenterprise1-cli/mkdocs.yml b/gen/androidenterprise1-cli/mkdocs.yml index 3f6adb7adf..b15d33ea88 100644 --- a/gen/androidenterprise1-cli/mkdocs.yml +++ b/gen/androidenterprise1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Android Enterprise v0.0.1+20150309 +site_name: Android Enterprise v0.1.0+20150309 site_url: http://byron.github.io/google-apis-rs/google-androidenterprise1-cli site_description: Write integrating applications with bcore diff --git a/gen/androidenterprise1-cli/src/cmn.rs b/gen/androidenterprise1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/androidenterprise1-cli/src/cmn.rs +++ b/gen/androidenterprise1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/androidenterprise1-cli/src/main.rs b/gen/androidenterprise1-cli/src/main.rs index 1aca27bdc3..e80ace2496 100644 --- a/gen/androidenterprise1-cli/src/main.rs +++ b/gen/androidenterprise1-cli/src/main.rs @@ -19,69 +19,70 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - androidenterprise1 [options] collections delete [-p ]... - androidenterprise1 [options] collections get [-p ]... [-o ] - androidenterprise1 [options] collections insert -r ... [-p ]... [-o ] - androidenterprise1 [options] collections list [-p ]... [-o ] - androidenterprise1 [options] collections patch -r ... [-p ]... [-o ] - androidenterprise1 [options] collections update -r ... [-p ]... [-o ] - androidenterprise1 [options] collectionviewers delete [-p ]... - androidenterprise1 [options] collectionviewers get [-p ]... [-o ] - androidenterprise1 [options] collectionviewers list [-p ]... [-o ] - androidenterprise1 [options] collectionviewers patch -r ... [-p ]... [-o ] - androidenterprise1 [options] collectionviewers update -r ... [-p ]... [-o ] - androidenterprise1 [options] devices get [-p ]... [-o ] - androidenterprise1 [options] devices get-state [-p ]... [-o ] - androidenterprise1 [options] devices list [-p ]... [-o ] - androidenterprise1 [options] devices set-state -r ... [-p ]... [-o ] - androidenterprise1 [options] enterprises delete [-p ]... - androidenterprise1 [options] enterprises enroll -r ... [-p ]... [-o ] - androidenterprise1 [options] enterprises get [-p ]... [-o ] - androidenterprise1 [options] enterprises insert -r ... [-p ]... [-o ] - androidenterprise1 [options] enterprises list [-p ]... [-o ] - androidenterprise1 [options] enterprises set-account -r ... [-p ]... [-o ] - androidenterprise1 [options] enterprises unenroll [-p ]... - androidenterprise1 [options] entitlements delete [-p ]... - androidenterprise1 [options] entitlements get [-p ]... [-o ] - androidenterprise1 [options] entitlements list [-p ]... [-o ] - androidenterprise1 [options] entitlements patch -r ... [-p ]... [-o ] - androidenterprise1 [options] entitlements update -r ... [-p ]... [-o ] - androidenterprise1 [options] grouplicenses get [-p ]... [-o ] - androidenterprise1 [options] grouplicenses list [-p ]... [-o ] - androidenterprise1 [options] grouplicenseusers list [-p ]... [-o ] - androidenterprise1 [options] installs delete [-p ]... - androidenterprise1 [options] installs get [-p ]... [-o ] - androidenterprise1 [options] installs list [-p ]... [-o ] - androidenterprise1 [options] installs patch -r ... [-p ]... [-o ] - androidenterprise1 [options] installs update -r ... [-p ]... [-o ] - androidenterprise1 [options] permissions get [-p ]... [-o ] - androidenterprise1 [options] products get [-p ]... [-o ] - androidenterprise1 [options] products get-app-restrictions-schema [-p ]... [-o ] - androidenterprise1 [options] products get-permissions [-p ]... [-o ] - androidenterprise1 [options] products update-permissions -r ... [-p ]... [-o ] - androidenterprise1 [options] users generate-token [-p ]... [-o ] - androidenterprise1 [options] users get [-p ]... [-o ] - androidenterprise1 [options] users list [-p ]... [-o ] - androidenterprise1 [options] users revoke-token [-p ]... + androidenterprise1 [options] collections delete [-p ...] + androidenterprise1 [options] collections get [-p ...] [-o ] + androidenterprise1 [options] collections insert -r ... [-p ...] [-o ] + androidenterprise1 [options] collections list [-p ...] [-o ] + androidenterprise1 [options] collections patch -r ... [-p ...] [-o ] + androidenterprise1 [options] collections update -r ... [-p ...] [-o ] + androidenterprise1 [options] collectionviewers delete [-p ...] + androidenterprise1 [options] collectionviewers get [-p ...] [-o ] + androidenterprise1 [options] collectionviewers list [-p ...] [-o ] + androidenterprise1 [options] collectionviewers patch -r ... [-p ...] [-o ] + androidenterprise1 [options] collectionviewers update -r ... [-p ...] [-o ] + androidenterprise1 [options] devices get [-p ...] [-o ] + androidenterprise1 [options] devices get-state [-p ...] [-o ] + androidenterprise1 [options] devices list [-p ...] [-o ] + androidenterprise1 [options] devices set-state -r ... [-p ...] [-o ] + androidenterprise1 [options] enterprises delete [-p ...] + androidenterprise1 [options] enterprises enroll -r ... [-p ...] [-o ] + androidenterprise1 [options] enterprises get [-p ...] [-o ] + androidenterprise1 [options] enterprises insert -r ... [-p ...] [-o ] + androidenterprise1 [options] enterprises list [-p ...] [-o ] + androidenterprise1 [options] enterprises set-account -r ... [-p ...] [-o ] + androidenterprise1 [options] enterprises unenroll [-p ...] + androidenterprise1 [options] entitlements delete [-p ...] + androidenterprise1 [options] entitlements get [-p ...] [-o ] + androidenterprise1 [options] entitlements list [-p ...] [-o ] + androidenterprise1 [options] entitlements patch -r ... [-p ...] [-o ] + androidenterprise1 [options] entitlements update -r ... [-p ...] [-o ] + androidenterprise1 [options] grouplicenses get [-p ...] [-o ] + androidenterprise1 [options] grouplicenses list [-p ...] [-o ] + androidenterprise1 [options] grouplicenseusers list [-p ...] [-o ] + androidenterprise1 [options] installs delete [-p ...] + androidenterprise1 [options] installs get [-p ...] [-o ] + androidenterprise1 [options] installs list [-p ...] [-o ] + androidenterprise1 [options] installs patch -r ... [-p ...] [-o ] + androidenterprise1 [options] installs update -r ... [-p ...] [-o ] + androidenterprise1 [options] permissions get [-p ...] [-o ] + androidenterprise1 [options] products get [-p ...] [-o ] + androidenterprise1 [options] products get-app-restrictions-schema [-p ...] [-o ] + androidenterprise1 [options] products get-permissions [-p ...] [-o ] + androidenterprise1 [options] products update-permissions -r ... [-p ...] [-o ] + androidenterprise1 [options] users generate-token [-p ...] [-o ] + androidenterprise1 [options] users get [-p ...] [-o ] + androidenterprise1 [options] users list [-p ...] [-o ] + androidenterprise1 [options] users revoke-token [-p ...] androidenterprise1 --help -All documentation details can be found TODO: +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/index.html Configuration: --scope - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -130,6 +131,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -171,6 +175,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -187,8 +194,48 @@ impl Engine { fn _collections_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Collection::default(); - let mut call = self.hub.collections().insert(&request, &self.opt.arg_enterprise_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "product-id" => { + if request.product_id.is_none() { + request.product_id = Some(Default::default()); + } + request.product_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + "visibility" => { + request.visibility = Some(value.unwrap_or("").to_string()); + }, + "collection-id" => { + request.collection_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.collections().insert(request, &self.opt.arg_enterprise_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -210,42 +257,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "product-id" => { - if request.product_id.is_none() { - request.product_id = Some(Default::default()); - } - request.product_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "visibility" => { - request.visibility = Some(value.unwrap_or("").to_string()); - }, - "collection-id" => { - request.collection_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -289,6 +308,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -305,8 +327,48 @@ impl Engine { fn _collections_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Collection::default(); - let mut call = self.hub.collections().patch(&request, &self.opt.arg_enterprise_id, &self.opt.arg_collection_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "product-id" => { + if request.product_id.is_none() { + request.product_id = Some(Default::default()); + } + request.product_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + "visibility" => { + request.visibility = Some(value.unwrap_or("").to_string()); + }, + "collection-id" => { + request.collection_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.collections().patch(request, &self.opt.arg_enterprise_id, &self.opt.arg_collection_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -328,42 +390,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "product-id" => { - if request.product_id.is_none() { - request.product_id = Some(Default::default()); - } - request.product_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "visibility" => { - request.visibility = Some(value.unwrap_or("").to_string()); - }, - "collection-id" => { - request.collection_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -380,8 +414,48 @@ impl Engine { fn _collections_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Collection::default(); - let mut call = self.hub.collections().update(&request, &self.opt.arg_enterprise_id, &self.opt.arg_collection_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "product-id" => { + if request.product_id.is_none() { + request.product_id = Some(Default::default()); + } + request.product_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + "visibility" => { + request.visibility = Some(value.unwrap_or("").to_string()); + }, + "collection-id" => { + request.collection_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.collections().update(request, &self.opt.arg_enterprise_id, &self.opt.arg_collection_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -403,42 +477,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "product-id" => { - if request.product_id.is_none() { - request.product_id = Some(Default::default()); - } - request.product_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "visibility" => { - request.visibility = Some(value.unwrap_or("").to_string()); - }, - "collection-id" => { - request.collection_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -482,6 +528,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -523,6 +572,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -566,6 +618,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -582,8 +637,39 @@ impl Engine { fn _collectionviewers_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::User::default(); - let mut call = self.hub.collectionviewers().patch(&request, &self.opt.arg_enterprise_id, &self.opt.arg_collection_id, &self.opt.arg_user_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "primary-email" => { + request.primary_email = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.collectionviewers().patch(request, &self.opt.arg_enterprise_id, &self.opt.arg_collection_id, &self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -605,33 +691,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "primary-email" => { - request.primary_email = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -648,8 +715,39 @@ impl Engine { fn _collectionviewers_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::User::default(); - let mut call = self.hub.collectionviewers().update(&request, &self.opt.arg_enterprise_id, &self.opt.arg_collection_id, &self.opt.arg_user_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "primary-email" => { + request.primary_email = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.collectionviewers().update(request, &self.opt.arg_enterprise_id, &self.opt.arg_collection_id, &self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -671,33 +769,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "primary-email" => { - request.primary_email = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -741,6 +820,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -784,6 +866,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -827,6 +912,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -843,8 +931,36 @@ impl Engine { fn _devices_set_state(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::DeviceState::default(); - let mut call = self.hub.devices().set_state(&request, &self.opt.arg_enterprise_id, &self.opt.arg_user_id, &self.opt.arg_device_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "account-state" => { + request.account_state = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.devices().set_state(request, &self.opt.arg_enterprise_id, &self.opt.arg_user_id, &self.opt.arg_device_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -866,30 +982,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "account-state" => { - request.account_state = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -933,6 +1033,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -947,8 +1050,42 @@ impl Engine { fn _enterprises_enroll(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Enterprise::default(); - let mut call = self.hub.enterprises().enroll(&request, &self.opt.arg_token); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "primary-domain" => { + request.primary_domain = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.enterprises().enroll(request, &self.opt.arg_token); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -970,36 +1107,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "primary-domain" => { - request.primary_domain = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1043,6 +1158,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1059,8 +1177,42 @@ impl Engine { fn _enterprises_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Enterprise::default(); - let mut call = self.hub.enterprises().insert(&request, &self.opt.arg_token); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "primary-domain" => { + request.primary_domain = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.enterprises().insert(request, &self.opt.arg_token); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1082,36 +1234,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "primary-domain" => { - request.primary_domain = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1155,6 +1285,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1171,8 +1304,36 @@ impl Engine { fn _enterprises_set_account(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::EnterpriseAccount::default(); - let mut call = self.hub.enterprises().set_account(&request, &self.opt.arg_enterprise_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "account-email" => { + request.account_email = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.enterprises().set_account(request, &self.opt.arg_enterprise_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1194,30 +1355,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "account-email" => { - request.account_email = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1261,6 +1406,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1302,6 +1450,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1343,6 +1494,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1386,6 +1540,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1402,8 +1559,39 @@ impl Engine { fn _entitlements_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Entitlement::default(); - let mut call = self.hub.entitlements().patch(&request, &self.opt.arg_enterprise_id, &self.opt.arg_user_id, &self.opt.arg_entitlement_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "reason" => { + request.reason = Some(value.unwrap_or("").to_string()); + }, + "product-id" => { + request.product_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.entitlements().patch(request, &self.opt.arg_enterprise_id, &self.opt.arg_user_id, &self.opt.arg_entitlement_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1428,33 +1616,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "reason" => { - request.reason = Some(value.unwrap_or("").to_string()); - }, - "product-id" => { - request.product_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1471,8 +1640,39 @@ impl Engine { fn _entitlements_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Entitlement::default(); - let mut call = self.hub.entitlements().update(&request, &self.opt.arg_enterprise_id, &self.opt.arg_user_id, &self.opt.arg_entitlement_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "reason" => { + request.reason = Some(value.unwrap_or("").to_string()); + }, + "product-id" => { + request.product_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.entitlements().update(request, &self.opt.arg_enterprise_id, &self.opt.arg_user_id, &self.opt.arg_entitlement_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1497,33 +1697,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "reason" => { - request.reason = Some(value.unwrap_or("").to_string()); - }, - "product-id" => { - request.product_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1567,6 +1748,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1610,6 +1794,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1653,6 +1840,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1696,6 +1886,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1737,6 +1930,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1780,6 +1976,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1796,8 +1995,42 @@ impl Engine { fn _installs_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Install::default(); - let mut call = self.hub.installs().patch(&request, &self.opt.arg_enterprise_id, &self.opt.arg_user_id, &self.opt.arg_device_id, &self.opt.arg_install_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "install-state" => { + request.install_state = Some(value.unwrap_or("").to_string()); + }, + "version-code" => { + request.version_code = Some(arg_from_str(value.unwrap_or("-0"), err, "version-code", "integer")); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "product-id" => { + request.product_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.installs().patch(request, &self.opt.arg_enterprise_id, &self.opt.arg_user_id, &self.opt.arg_device_id, &self.opt.arg_install_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1819,36 +2052,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "install-state" => { - request.install_state = Some(value.unwrap_or("").to_string()); - }, - "version-code" => { - request.version_code = Some(arg_from_str(value.unwrap_or("-0"), err, "version-code", "integer")); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "product-id" => { - request.product_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1865,8 +2076,42 @@ impl Engine { fn _installs_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Install::default(); - let mut call = self.hub.installs().update(&request, &self.opt.arg_enterprise_id, &self.opt.arg_user_id, &self.opt.arg_device_id, &self.opt.arg_install_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "install-state" => { + request.install_state = Some(value.unwrap_or("").to_string()); + }, + "version-code" => { + request.version_code = Some(arg_from_str(value.unwrap_or("-0"), err, "version-code", "integer")); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "product-id" => { + request.product_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.installs().update(request, &self.opt.arg_enterprise_id, &self.opt.arg_user_id, &self.opt.arg_device_id, &self.opt.arg_install_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1888,36 +2133,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "install-state" => { - request.install_state = Some(value.unwrap_or("").to_string()); - }, - "version-code" => { - request.version_code = Some(arg_from_str(value.unwrap_or("-0"), err, "version-code", "integer")); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "product-id" => { - request.product_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1964,6 +2187,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2010,6 +2236,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2056,6 +2285,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2099,6 +2331,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2115,8 +2350,36 @@ impl Engine { fn _products_update_permissions(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::ProductPermissions::default(); - let mut call = self.hub.products().update_permissions(&request, &self.opt.arg_enterprise_id, &self.opt.arg_product_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "product-id" => { + request.product_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.products().update_permissions(request, &self.opt.arg_enterprise_id, &self.opt.arg_product_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2138,30 +2401,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "product-id" => { - request.product_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2205,6 +2452,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2248,6 +2498,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2291,6 +2544,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2334,6 +2590,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2561,6 +2820,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -2568,8 +2828,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/androidenterprise1/Cargo.toml b/gen/androidenterprise1/Cargo.toml index 4a39e14588..c6248aaa13 100644 --- a/gen/androidenterprise1/Cargo.toml +++ b/gen/androidenterprise1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-androidenterprise1" -version = "0.1.5+20150309" +version = "0.1.6+20150309" authors = ["Sebastian Thiel "] description = "A complete library to interact with Android Enterprise (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/androidenterprise1" diff --git a/gen/androidenterprise1/README.md b/gen/androidenterprise1/README.md index 78f41163c9..7bd538e025 100644 --- a/gen/androidenterprise1/README.md +++ b/gen/androidenterprise1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-androidenterprise1` library allows access to all features of the *Google Android Enterprise* service. -This documentation was generated from *Android Enterprise* crate version *0.1.5+20150309*, where *20150309* is the exact revision of the *androidenterprise:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *Android Enterprise* crate version *0.1.6+20150309*, where *20150309* is the exact revision of the *androidenterprise:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. # Features Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.AndroidEnterprise.html) ... @@ -121,21 +121,22 @@ let mut req = Enterprise::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.enterprises().insert(&req, "token") +let result = hub.enterprises().insert(req, "token") .doit(); match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/androidenterprise1/src/cmn.rs b/gen/androidenterprise1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/androidenterprise1/src/cmn.rs +++ b/gen/androidenterprise1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option, + location: Option +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option, _: Option) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec]) -> Option { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/androidenterprise1/src/lib.rs b/gen/androidenterprise1/src/lib.rs index 3af3678d06..9c809cc95f 100644 --- a/gen/androidenterprise1/src/lib.rs +++ b/gen/androidenterprise1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Android Enterprise* crate version *0.1.5+20150309*, where *20150309* is the exact revision of the *androidenterprise:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *Android Enterprise* crate version *0.1.6+20150309*, where *20150309* is the exact revision of the *androidenterprise:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/androidenterprise1). //! # Features //! @@ -122,21 +122,22 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.enterprises().insert(&req, "token") +//! let result = hub.enterprises().insert(req, "token") //! .doit(); //! //! match result { //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -224,7 +225,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -297,21 +298,22 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.enterprises().insert(&req, "token") +/// let result = hub.enterprises().insert(req, "token") /// .doit(); /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -332,7 +334,7 @@ impl<'a, C, A> AndroidEnterprise AndroidEnterprise { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -371,7 +373,7 @@ impl<'a, C, A> AndroidEnterprise } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -1150,10 +1152,10 @@ impl<'a, C, A> CollectionviewerMethods<'a, C, A> { /// * `enterpriseId` - The ID of the enterprise. /// * `collectionId` - The ID of the collection. /// * `userId` - The ID of the user. - pub fn patch(&self, request: &User, enterprise_id: &str, collection_id: &str, user_id: &str) -> CollectionviewerPatchCall<'a, C, A> { + pub fn patch(&self, request: User, enterprise_id: &str, collection_id: &str, user_id: &str) -> CollectionviewerPatchCall<'a, C, A> { CollectionviewerPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _enterprise_id: enterprise_id.to_string(), _collection_id: collection_id.to_string(), _user_id: user_id.to_string(), @@ -1213,10 +1215,10 @@ impl<'a, C, A> CollectionviewerMethods<'a, C, A> { /// * `enterpriseId` - The ID of the enterprise. /// * `collectionId` - The ID of the collection. /// * `userId` - The ID of the user. - pub fn update(&self, request: &User, enterprise_id: &str, collection_id: &str, user_id: &str) -> CollectionviewerUpdateCall<'a, C, A> { + pub fn update(&self, request: User, enterprise_id: &str, collection_id: &str, user_id: &str) -> CollectionviewerUpdateCall<'a, C, A> { CollectionviewerUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _enterprise_id: enterprise_id.to_string(), _collection_id: collection_id.to_string(), _user_id: user_id.to_string(), @@ -1395,10 +1397,10 @@ impl<'a, C, A> InstallMethods<'a, C, A> { /// * `userId` - The ID of the user. /// * `deviceId` - The Android ID of the device. /// * `installId` - The ID of the product represented by the install, e.g. "app:com.google.android.gm". - pub fn patch(&self, request: &Install, enterprise_id: &str, user_id: &str, device_id: &str, install_id: &str) -> InstallPatchCall<'a, C, A> { + pub fn patch(&self, request: Install, enterprise_id: &str, user_id: &str, device_id: &str, install_id: &str) -> InstallPatchCall<'a, C, A> { InstallPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _enterprise_id: enterprise_id.to_string(), _user_id: user_id.to_string(), _device_id: device_id.to_string(), @@ -1487,10 +1489,10 @@ impl<'a, C, A> InstallMethods<'a, C, A> { /// * `userId` - The ID of the user. /// * `deviceId` - The Android ID of the device. /// * `installId` - The ID of the product represented by the install, e.g. "app:com.google.android.gm". - pub fn update(&self, request: &Install, enterprise_id: &str, user_id: &str, device_id: &str, install_id: &str) -> InstallUpdateCall<'a, C, A> { + pub fn update(&self, request: Install, enterprise_id: &str, user_id: &str, device_id: &str, install_id: &str) -> InstallUpdateCall<'a, C, A> { InstallUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _enterprise_id: enterprise_id.to_string(), _user_id: user_id.to_string(), _device_id: device_id.to_string(), @@ -1552,10 +1554,10 @@ impl<'a, C, A> DeviceMethods<'a, C, A> { /// * `enterpriseId` - The ID of the enterprise. /// * `userId` - The ID of the user. /// * `deviceId` - The ID of the device. - pub fn set_state(&self, request: &DeviceState, enterprise_id: &str, user_id: &str, device_id: &str) -> DeviceSetStateCall<'a, C, A> { + pub fn set_state(&self, request: DeviceState, enterprise_id: &str, user_id: &str, device_id: &str) -> DeviceSetStateCall<'a, C, A> { DeviceSetStateCall { hub: self.hub, - _request: request.clone(), + _request: request, _enterprise_id: enterprise_id.to_string(), _user_id: user_id.to_string(), _device_id: device_id.to_string(), @@ -1692,10 +1694,10 @@ impl<'a, C, A> EnterpriseMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `token` - The token provided by the enterprise to register the MDM. - pub fn insert(&self, request: &Enterprise, token: &str) -> EnterpriseInsertCall<'a, C, A> { + pub fn insert(&self, request: Enterprise, token: &str) -> EnterpriseInsertCall<'a, C, A> { EnterpriseInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _token: token.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1745,10 +1747,10 @@ impl<'a, C, A> EnterpriseMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `token` - The token provided by the enterprise to register the MDM. - pub fn enroll(&self, request: &Enterprise, token: &str) -> EnterpriseEnrollCall<'a, C, A> { + pub fn enroll(&self, request: Enterprise, token: &str) -> EnterpriseEnrollCall<'a, C, A> { EnterpriseEnrollCall { hub: self.hub, - _request: request.clone(), + _request: request, _token: token.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1764,10 +1766,10 @@ impl<'a, C, A> EnterpriseMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `enterpriseId` - The ID of the enterprise. - pub fn set_account(&self, request: &EnterpriseAccount, enterprise_id: &str) -> EnterpriseSetAccountCall<'a, C, A> { + pub fn set_account(&self, request: EnterpriseAccount, enterprise_id: &str) -> EnterpriseSetAccountCall<'a, C, A> { EnterpriseSetAccountCall { hub: self.hub, - _request: request.clone(), + _request: request, _enterprise_id: enterprise_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1841,10 +1843,10 @@ impl<'a, C, A> CollectionMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `enterpriseId` - The ID of the enterprise. - pub fn insert(&self, request: &Collection, enterprise_id: &str) -> CollectionInsertCall<'a, C, A> { + pub fn insert(&self, request: Collection, enterprise_id: &str) -> CollectionInsertCall<'a, C, A> { CollectionInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _enterprise_id: enterprise_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1861,10 +1863,10 @@ impl<'a, C, A> CollectionMethods<'a, C, A> { /// * `request` - No description provided. /// * `enterpriseId` - The ID of the enterprise. /// * `collectionId` - The ID of the collection. - pub fn patch(&self, request: &Collection, enterprise_id: &str, collection_id: &str) -> CollectionPatchCall<'a, C, A> { + pub fn patch(&self, request: Collection, enterprise_id: &str, collection_id: &str) -> CollectionPatchCall<'a, C, A> { CollectionPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _enterprise_id: enterprise_id.to_string(), _collection_id: collection_id.to_string(), _delegate: Default::default(), @@ -1882,10 +1884,10 @@ impl<'a, C, A> CollectionMethods<'a, C, A> { /// * `request` - No description provided. /// * `enterpriseId` - The ID of the enterprise. /// * `collectionId` - The ID of the collection. - pub fn update(&self, request: &Collection, enterprise_id: &str, collection_id: &str) -> CollectionUpdateCall<'a, C, A> { + pub fn update(&self, request: Collection, enterprise_id: &str, collection_id: &str) -> CollectionUpdateCall<'a, C, A> { CollectionUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _enterprise_id: enterprise_id.to_string(), _collection_id: collection_id.to_string(), _delegate: Default::default(), @@ -2060,10 +2062,10 @@ impl<'a, C, A> EntitlementMethods<'a, C, A> { /// * `enterpriseId` - The ID of the enterprise. /// * `userId` - The ID of the user. /// * `entitlementId` - The ID of the entitlement, e.g. "app:com.google.android.gm". - pub fn update(&self, request: &Entitlement, enterprise_id: &str, user_id: &str, entitlement_id: &str) -> EntitlementUpdateCall<'a, C, A> { + pub fn update(&self, request: Entitlement, enterprise_id: &str, user_id: &str, entitlement_id: &str) -> EntitlementUpdateCall<'a, C, A> { EntitlementUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _enterprise_id: enterprise_id.to_string(), _user_id: user_id.to_string(), _entitlement_id: entitlement_id.to_string(), @@ -2124,10 +2126,10 @@ impl<'a, C, A> EntitlementMethods<'a, C, A> { /// * `enterpriseId` - The ID of the enterprise. /// * `userId` - The ID of the user. /// * `entitlementId` - The ID of the entitlement, e.g. "app:com.google.android.gm". - pub fn patch(&self, request: &Entitlement, enterprise_id: &str, user_id: &str, entitlement_id: &str) -> EntitlementPatchCall<'a, C, A> { + pub fn patch(&self, request: Entitlement, enterprise_id: &str, user_id: &str, entitlement_id: &str) -> EntitlementPatchCall<'a, C, A> { EntitlementPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _enterprise_id: enterprise_id.to_string(), _user_id: user_id.to_string(), _entitlement_id: entitlement_id.to_string(), @@ -2268,10 +2270,10 @@ impl<'a, C, A> ProductMethods<'a, C, A> { /// * `request` - No description provided. /// * `enterpriseId` - The ID of the enterprise. /// * `productId` - The ID of the product. - pub fn update_permissions(&self, request: &ProductPermissions, enterprise_id: &str, product_id: &str) -> ProductUpdatePermissionCall<'a, C, A> { + pub fn update_permissions(&self, request: ProductPermissions, enterprise_id: &str, product_id: &str) -> ProductUpdatePermissionCall<'a, C, A> { ProductUpdatePermissionCall { hub: self.hub, - _request: request.clone(), + _request: request, _enterprise_id: enterprise_id.to_string(), _product_id: product_id.to_string(), _delegate: Default::default(), @@ -2573,12 +2575,17 @@ impl<'a, C, A> CollectionviewerDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -2704,7 +2711,7 @@ impl<'a, C, A> CollectionviewerDeleteCall<'a, C, A> where C: BorrowMut CollectionviewerPatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2850,7 +2862,7 @@ impl<'a, C, A> CollectionviewerPatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2868,8 +2880,8 @@ impl<'a, C, A> CollectionviewerPatchCall<'a, C, A> where C: BorrowMut CollectionviewerPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: User) -> CollectionviewerPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the enterprise. @@ -3103,12 +3115,17 @@ impl<'a, C, A> CollectionviewerGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3117,7 +3134,7 @@ impl<'a, C, A> CollectionviewerGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3359,12 +3376,17 @@ impl<'a, C, A> CollectionviewerListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3373,7 +3395,7 @@ impl<'a, C, A> CollectionviewerListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3490,7 +3512,7 @@ impl<'a, C, A> CollectionviewerListCall<'a, C, A> where C: BorrowMut CollectionviewerUpdateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3636,7 +3663,7 @@ impl<'a, C, A> CollectionviewerUpdateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3654,8 +3681,8 @@ impl<'a, C, A> CollectionviewerUpdateCall<'a, C, A> where C: BorrowMut CollectionviewerUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: User) -> CollectionviewerUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the enterprise. @@ -3886,12 +3913,17 @@ impl<'a, C, A> UserRevokeTokenCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -4122,12 +4154,17 @@ impl<'a, C, A> UserGetCall<'a, C, A> where C: BorrowMut, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4136,7 +4173,7 @@ impl<'a, C, A> UserGetCall<'a, C, A> where C: BorrowMut, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4368,12 +4405,17 @@ impl<'a, C, A> UserListCall<'a, C, A> where C: BorrowMut, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4382,7 +4424,7 @@ impl<'a, C, A> UserListCall<'a, C, A> where C: BorrowMut, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4614,12 +4656,17 @@ impl<'a, C, A> UserGenerateTokenCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4628,7 +4675,7 @@ impl<'a, C, A> UserGenerateTokenCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4745,7 +4792,7 @@ impl<'a, C, A> UserGenerateTokenCall<'a, C, A> where C: BorrowMut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.installs().patch(&req, "enterpriseId", "userId", "deviceId", "installId") +/// let result = hub.installs().patch(req, "enterpriseId", "userId", "deviceId", "installId") /// .doit(); /// # } /// ``` @@ -4879,12 +4926,17 @@ impl<'a, C, A> InstallPatchCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4893,7 +4945,7 @@ impl<'a, C, A> InstallPatchCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4911,8 +4963,8 @@ impl<'a, C, A> InstallPatchCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Install) -> InstallPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Install) -> InstallPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the enterprise. @@ -5158,12 +5210,17 @@ impl<'a, C, A> InstallGetCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5172,7 +5229,7 @@ impl<'a, C, A> InstallGetCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5426,12 +5483,17 @@ impl<'a, C, A> InstallListCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5440,7 +5502,7 @@ impl<'a, C, A> InstallListCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5685,12 +5747,17 @@ impl<'a, C, A> InstallDeleteCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -5826,7 +5893,7 @@ impl<'a, C, A> InstallDeleteCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.installs().update(&req, "enterpriseId", "userId", "deviceId", "installId") +/// let result = hub.installs().update(req, "enterpriseId", "userId", "deviceId", "installId") /// .doit(); /// # } /// ``` @@ -5960,12 +6027,17 @@ impl<'a, C, A> InstallUpdateCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5974,7 +6046,7 @@ impl<'a, C, A> InstallUpdateCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5992,8 +6064,8 @@ impl<'a, C, A> InstallUpdateCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Install) -> InstallUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Install) -> InstallUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the enterprise. @@ -6120,7 +6192,7 @@ impl<'a, C, A> InstallUpdateCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.devices().set_state(&req, "enterpriseId", "userId", "deviceId") +/// let result = hub.devices().set_state(req, "enterpriseId", "userId", "deviceId") /// .doit(); /// # } /// ``` @@ -6252,12 +6324,17 @@ impl<'a, C, A> DeviceSetStateCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6266,7 +6343,7 @@ impl<'a, C, A> DeviceSetStateCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6284,8 +6361,8 @@ impl<'a, C, A> DeviceSetStateCall<'a, C, A> where C: BorrowMut, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &DeviceState) -> DeviceSetStateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: DeviceState) -> DeviceSetStateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the enterprise. @@ -6519,12 +6596,17 @@ impl<'a, C, A> DeviceGetStateCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6533,7 +6615,7 @@ impl<'a, C, A> DeviceGetStateCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6775,12 +6857,17 @@ impl<'a, C, A> DeviceListCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6789,7 +6876,7 @@ impl<'a, C, A> DeviceListCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7023,12 +7110,17 @@ impl<'a, C, A> DeviceGetCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7037,7 +7129,7 @@ impl<'a, C, A> DeviceGetCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7276,12 +7368,17 @@ impl<'a, C, A> EnterpriseUnenrollCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -7387,7 +7484,7 @@ impl<'a, C, A> EnterpriseUnenrollCall<'a, C, A> where C: BorrowMut EnterpriseInsertCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7505,7 +7607,7 @@ impl<'a, C, A> EnterpriseInsertCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7523,8 +7625,8 @@ impl<'a, C, A> EnterpriseInsertCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Enterprise) -> EnterpriseInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Enterprise) -> EnterpriseInsertCall<'a, C, A> { + self._request = new_value; self } /// The token provided by the enterprise to register the MDM. @@ -7710,12 +7812,17 @@ impl<'a, C, A> EnterpriseListCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7724,7 +7831,7 @@ impl<'a, C, A> EnterpriseListCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7944,12 +8051,17 @@ impl<'a, C, A> EnterpriseGetCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7958,7 +8070,7 @@ impl<'a, C, A> EnterpriseGetCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8065,7 +8177,7 @@ impl<'a, C, A> EnterpriseGetCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.enterprises().enroll(&req, "token") +/// let result = hub.enterprises().enroll(req, "token") /// .doit(); /// # } /// ``` @@ -8169,12 +8281,17 @@ impl<'a, C, A> EnterpriseEnrollCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8183,7 +8300,7 @@ impl<'a, C, A> EnterpriseEnrollCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8201,8 +8318,8 @@ impl<'a, C, A> EnterpriseEnrollCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Enterprise) -> EnterpriseEnrollCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Enterprise) -> EnterpriseEnrollCall<'a, C, A> { + self._request = new_value; self } /// The token provided by the enterprise to register the MDM. @@ -8299,7 +8416,7 @@ impl<'a, C, A> EnterpriseEnrollCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.enterprises().set_account(&req, "enterpriseId") +/// let result = hub.enterprises().set_account(req, "enterpriseId") /// .doit(); /// # } /// ``` @@ -8427,12 +8544,17 @@ impl<'a, C, A> EnterpriseSetAccountCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8441,7 +8563,7 @@ impl<'a, C, A> EnterpriseSetAccountCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8459,8 +8581,8 @@ impl<'a, C, A> EnterpriseSetAccountCall<'a, C, A> where C: BorrowMut EnterpriseSetAccountCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: EnterpriseAccount) -> EnterpriseSetAccountCall<'a, C, A> { + self._request = new_value; self } /// The ID of the enterprise. @@ -8669,12 +8791,17 @@ impl<'a, C, A> EnterpriseDeleteCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -8780,7 +8907,7 @@ impl<'a, C, A> EnterpriseDeleteCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.collections().insert(&req, "enterpriseId") +/// let result = hub.collections().insert(req, "enterpriseId") /// .doit(); /// # } /// ``` @@ -8908,12 +9035,17 @@ impl<'a, C, A> CollectionInsertCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8922,7 +9054,7 @@ impl<'a, C, A> CollectionInsertCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8940,8 +9072,8 @@ impl<'a, C, A> CollectionInsertCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Collection) -> CollectionInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Collection) -> CollectionInsertCall<'a, C, A> { + self._request = new_value; self } /// The ID of the enterprise. @@ -9038,7 +9170,7 @@ impl<'a, C, A> CollectionInsertCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.collections().patch(&req, "enterpriseId", "collectionId") +/// let result = hub.collections().patch(req, "enterpriseId", "collectionId") /// .doit(); /// # } /// ``` @@ -9168,12 +9300,17 @@ impl<'a, C, A> CollectionPatchCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9182,7 +9319,7 @@ impl<'a, C, A> CollectionPatchCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9200,8 +9337,8 @@ impl<'a, C, A> CollectionPatchCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Collection) -> CollectionPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Collection) -> CollectionPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the enterprise. @@ -9308,7 +9445,7 @@ impl<'a, C, A> CollectionPatchCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.collections().update(&req, "enterpriseId", "collectionId") +/// let result = hub.collections().update(req, "enterpriseId", "collectionId") /// .doit(); /// # } /// ``` @@ -9438,12 +9575,17 @@ impl<'a, C, A> CollectionUpdateCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9452,7 +9594,7 @@ impl<'a, C, A> CollectionUpdateCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9470,8 +9612,8 @@ impl<'a, C, A> CollectionUpdateCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Collection) -> CollectionUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Collection) -> CollectionUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the enterprise. @@ -9691,12 +9833,17 @@ impl<'a, C, A> CollectionListCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9705,7 +9852,7 @@ impl<'a, C, A> CollectionListCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9927,12 +10074,17 @@ impl<'a, C, A> CollectionGetCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9941,7 +10093,7 @@ impl<'a, C, A> CollectionGetCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10172,12 +10324,17 @@ impl<'a, C, A> CollectionDeleteCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -10408,12 +10565,17 @@ impl<'a, C, A> GrouplicenseuserListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10422,7 +10584,7 @@ impl<'a, C, A> GrouplicenseuserListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10539,7 +10701,7 @@ impl<'a, C, A> GrouplicenseuserListCall<'a, C, A> where C: BorrowMut EntitlementUpdateCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10690,7 +10857,7 @@ impl<'a, C, A> EntitlementUpdateCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10708,8 +10875,8 @@ impl<'a, C, A> EntitlementUpdateCall<'a, C, A> where C: BorrowMut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Entitlement) -> EntitlementUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Entitlement) -> EntitlementUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the enterprise. @@ -10948,12 +11115,17 @@ impl<'a, C, A> EntitlementListCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10962,7 +11134,7 @@ impl<'a, C, A> EntitlementListCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11196,12 +11368,17 @@ impl<'a, C, A> EntitlementGetCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11210,7 +11387,7 @@ impl<'a, C, A> EntitlementGetCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11337,7 +11514,7 @@ impl<'a, C, A> EntitlementGetCall<'a, C, A> where C: BorrowMut, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.entitlements().patch(&req, "enterpriseId", "userId", "entitlementId") +/// let result = hub.entitlements().patch(req, "enterpriseId", "userId", "entitlementId") /// .install(true) /// .doit(); /// # } @@ -11474,12 +11651,17 @@ impl<'a, C, A> EntitlementPatchCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11488,7 +11670,7 @@ impl<'a, C, A> EntitlementPatchCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11506,8 +11688,8 @@ impl<'a, C, A> EntitlementPatchCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Entitlement) -> EntitlementPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Entitlement) -> EntitlementPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the enterprise. @@ -11747,12 +11929,17 @@ impl<'a, C, A> EntitlementDeleteCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -11993,12 +12180,17 @@ impl<'a, C, A> ProductGetPermissionCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12007,7 +12199,7 @@ impl<'a, C, A> ProductGetPermissionCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12244,12 +12436,17 @@ impl<'a, C, A> ProductGetCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12258,7 +12455,7 @@ impl<'a, C, A> ProductGetCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12502,12 +12699,17 @@ impl<'a, C, A> ProductGetAppRestrictionsSchemaCall<'a, C, A> where C: BorrowMut< if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12516,7 +12718,7 @@ impl<'a, C, A> ProductGetAppRestrictionsSchemaCall<'a, C, A> where C: BorrowMut< Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12640,7 +12842,7 @@ impl<'a, C, A> ProductGetAppRestrictionsSchemaCall<'a, C, A> where C: BorrowMut< /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.products().update_permissions(&req, "enterpriseId", "productId") +/// let result = hub.products().update_permissions(req, "enterpriseId", "productId") /// .doit(); /// # } /// ``` @@ -12770,12 +12972,17 @@ impl<'a, C, A> ProductUpdatePermissionCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12784,7 +12991,7 @@ impl<'a, C, A> ProductUpdatePermissionCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12802,8 +13009,8 @@ impl<'a, C, A> ProductUpdatePermissionCall<'a, C, A> where C: BorrowMut ProductUpdatePermissionCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ProductPermissions) -> ProductUpdatePermissionCall<'a, C, A> { + self._request = new_value; self } /// The ID of the enterprise. @@ -13025,12 +13232,17 @@ impl<'a, C, A> GrouplicenseGetCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13039,7 +13251,7 @@ impl<'a, C, A> GrouplicenseGetCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13269,12 +13481,17 @@ impl<'a, C, A> GrouplicenseListCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13283,7 +13500,7 @@ impl<'a, C, A> GrouplicenseListCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13508,12 +13725,17 @@ impl<'a, C, A> PermissionGetCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13522,7 +13744,7 @@ impl<'a, C, A> PermissionGetCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/androidpublisher2-cli/Cargo.toml b/gen/androidpublisher2-cli/Cargo.toml index c3972823b5..b1a0c16610 100644 --- a/gen/androidpublisher2-cli/Cargo.toml +++ b/gen/androidpublisher2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-androidpublisher2-cli" -version = "0.0.1+20150323" +version = "0.1.0+20150323" authors = ["Sebastian Thiel "] description = "A complete library to interact with Android Publisher (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/androidpublisher2-cli" diff --git a/gen/androidpublisher2-cli/README.md b/gen/androidpublisher2-cli/README.md index 92ddc00a90..068dc211a0 100644 --- a/gen/androidpublisher2-cli/README.md +++ b/gen/androidpublisher2-cli/README.md @@ -1,4 +1,152 @@ -# HELLO ANDROIDPUBLISHER:V2 + +The `androidpublisher2` command-line interface *(CLI)* allows to use most features of the *Google Android Publisher* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *Android Publisher* API at revision *20150323*. The CLI is at version *0.1.0*. + +```bash + androidpublisher2 [options] edits apklistings-delete [-p ...] + androidpublisher2 [options] edits apklistings-deleteall [-p ...] + androidpublisher2 [options] edits apklistings-get [-p ...] [-o ] + androidpublisher2 [options] edits apklistings-list [-p ...] [-o ] + androidpublisher2 [options] edits apklistings-patch -r ... [-p ...] [-o ] + androidpublisher2 [options] edits apklistings-update -r ... [-p ...] [-o ] + androidpublisher2 [options] edits apks-addexternallyhosted -r ... [-p ...] [-o ] + androidpublisher2 [options] edits apks-list [-p ...] [-o ] + androidpublisher2 [options] edits apks-upload -u (simple|resumable) [-p ...] [-o ] + androidpublisher2 [options] edits commit [-p ...] [-o ] + androidpublisher2 [options] edits delete [-p ...] + androidpublisher2 [options] edits details-get [-p ...] [-o ] + androidpublisher2 [options] edits details-patch -r ... [-p ...] [-o ] + androidpublisher2 [options] edits details-update -r ... [-p ...] [-o ] + androidpublisher2 [options] edits expansionfiles-get [-p ...] [-o ] + androidpublisher2 [options] edits expansionfiles-patch -r ... [-p ...] [-o ] + androidpublisher2 [options] edits expansionfiles-update -r ... [-p ...] [-o ] + androidpublisher2 [options] edits expansionfiles-upload -u (simple|resumable) [-p ...] [-o ] + androidpublisher2 [options] edits get [-p ...] [-o ] + androidpublisher2 [options] edits images-delete [-p ...] + androidpublisher2 [options] edits images-deleteall [-p ...] [-o ] + androidpublisher2 [options] edits images-list [-p ...] [-o ] + androidpublisher2 [options] edits images-upload -u (simple|resumable) [-p ...] [-o ] + androidpublisher2 [options] edits insert -r ... [-p ...] [-o ] + androidpublisher2 [options] edits listings-delete [-p ...] + androidpublisher2 [options] edits listings-deleteall [-p ...] + androidpublisher2 [options] edits listings-get [-p ...] [-o ] + androidpublisher2 [options] edits listings-list [-p ...] [-o ] + androidpublisher2 [options] edits listings-patch -r ... [-p ...] [-o ] + androidpublisher2 [options] edits listings-update -r ... [-p ...] [-o ] + androidpublisher2 [options] edits testers-get [-p ...] [-o ] + androidpublisher2 [options] edits testers-patch -r ... [-p ...] [-o ] + androidpublisher2 [options] edits testers-update -r ... [-p ...] [-o ] + androidpublisher2 [options] edits tracks-get [-p ...] [-o ] + androidpublisher2 [options] edits tracks-list [-p ...] [-o ] + androidpublisher2 [options] edits tracks-patch -r ... [-p ...] [-o ] + androidpublisher2 [options] edits tracks-update -r ... [-p ...] [-o ] + androidpublisher2 [options] edits validate [-p ...] [-o ] + androidpublisher2 [options] inappproducts batch -r ... [-p ...] [-o ] + androidpublisher2 [options] inappproducts delete [-p ...] + androidpublisher2 [options] inappproducts get [-p ...] [-o ] + androidpublisher2 [options] inappproducts insert -r ... [-p ...] [-o ] + androidpublisher2 [options] inappproducts list [-p ...] [-o ] + androidpublisher2 [options] inappproducts patch -r ... [-p ...] [-o ] + androidpublisher2 [options] inappproducts update -r ... [-p ...] [-o ] + androidpublisher2 [options] purchases products-get [-p ...] [-o ] + androidpublisher2 [options] purchases subscriptions-cancel [-p ...] + androidpublisher2 [options] purchases subscriptions-defer -r ... [-p ...] [-o ] + androidpublisher2 [options] purchases subscriptions-get [-p ...] [-o ] + androidpublisher2 [options] purchases subscriptions-refund [-p ...] + androidpublisher2 [options] purchases subscriptions-revoke [-p ...] + androidpublisher2 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_androidpublisher2_cli/index.html + +Configuration: + --scope + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `androidpublisher2-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/androidpublisher2-token-.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/androidpublisher2-secret.json`, assuming that the required *androidpublisher* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `androidpublisher2 --debug [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/androidpublisher2-cli/mkdocs.yml b/gen/androidpublisher2-cli/mkdocs.yml index 6014864ec0..ec320c2051 100644 --- a/gen/androidpublisher2-cli/mkdocs.yml +++ b/gen/androidpublisher2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Android Publisher v0.0.1+20150323 +site_name: Android Publisher v0.1.0+20150323 site_url: http://byron.github.io/google-apis-rs/google-androidpublisher2-cli site_description: Write integrating applications with bcore diff --git a/gen/androidpublisher2-cli/src/cmn.rs b/gen/androidpublisher2-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/androidpublisher2-cli/src/cmn.rs +++ b/gen/androidpublisher2-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/androidpublisher2-cli/src/main.rs b/gen/androidpublisher2-cli/src/main.rs index c2c747226d..95fd0dcc50 100644 --- a/gen/androidpublisher2-cli/src/main.rs +++ b/gen/androidpublisher2-cli/src/main.rs @@ -19,76 +19,77 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - androidpublisher2 [options] edits apklistings-delete [-p ]... - androidpublisher2 [options] edits apklistings-deleteall [-p ]... - androidpublisher2 [options] edits apklistings-get [-p ]... [-o ] - androidpublisher2 [options] edits apklistings-list [-p ]... [-o ] - androidpublisher2 [options] edits apklistings-patch -r ... [-p ]... [-o ] - androidpublisher2 [options] edits apklistings-update -r ... [-p ]... [-o ] - androidpublisher2 [options] edits apks-addexternallyhosted -r ... [-p ]... [-o ] - androidpublisher2 [options] edits apks-list [-p ]... [-o ] - androidpublisher2 [options] edits apks-upload -u (simple|resumable) [-p ]... [-o ] - androidpublisher2 [options] edits commit [-p ]... [-o ] - androidpublisher2 [options] edits delete [-p ]... - androidpublisher2 [options] edits details-get [-p ]... [-o ] - androidpublisher2 [options] edits details-patch -r ... [-p ]... [-o ] - androidpublisher2 [options] edits details-update -r ... [-p ]... [-o ] - androidpublisher2 [options] edits expansionfiles-get [-p ]... [-o ] - androidpublisher2 [options] edits expansionfiles-patch -r ... [-p ]... [-o ] - androidpublisher2 [options] edits expansionfiles-update -r ... [-p ]... [-o ] - androidpublisher2 [options] edits expansionfiles-upload -u (simple|resumable) [-p ]... [-o ] - androidpublisher2 [options] edits get [-p ]... [-o ] - androidpublisher2 [options] edits images-delete [-p ]... - androidpublisher2 [options] edits images-deleteall [-p ]... [-o ] - androidpublisher2 [options] edits images-list [-p ]... [-o ] - androidpublisher2 [options] edits images-upload -u (simple|resumable) [-p ]... [-o ] - androidpublisher2 [options] edits insert -r ... [-p ]... [-o ] - androidpublisher2 [options] edits listings-delete [-p ]... - androidpublisher2 [options] edits listings-deleteall [-p ]... - androidpublisher2 [options] edits listings-get [-p ]... [-o ] - androidpublisher2 [options] edits listings-list [-p ]... [-o ] - androidpublisher2 [options] edits listings-patch -r ... [-p ]... [-o ] - androidpublisher2 [options] edits listings-update -r ... [-p ]... [-o ] - androidpublisher2 [options] edits testers-get [-p ]... [-o ] - androidpublisher2 [options] edits testers-patch -r ... [-p ]... [-o ] - androidpublisher2 [options] edits testers-update -r ... [-p ]... [-o ] - androidpublisher2 [options] edits tracks-get [-p ]... [-o ] - androidpublisher2 [options] edits tracks-list [-p ]... [-o ] - androidpublisher2 [options] edits tracks-patch -r ... [-p ]... [-o ] - androidpublisher2 [options] edits tracks-update -r ... [-p ]... [-o ] - androidpublisher2 [options] edits validate [-p ]... [-o ] - androidpublisher2 [options] inappproducts batch -r ... [-p ]... [-o ] - androidpublisher2 [options] inappproducts delete [-p ]... - androidpublisher2 [options] inappproducts get [-p ]... [-o ] - androidpublisher2 [options] inappproducts insert -r ... [-p ]... [-o ] - androidpublisher2 [options] inappproducts list [-p ]... [-o ] - androidpublisher2 [options] inappproducts patch -r ... [-p ]... [-o ] - androidpublisher2 [options] inappproducts update -r ... [-p ]... [-o ] - androidpublisher2 [options] purchases products-get [-p ]... [-o ] - androidpublisher2 [options] purchases subscriptions-cancel [-p ]... - androidpublisher2 [options] purchases subscriptions-defer -r ... [-p ]... [-o ] - androidpublisher2 [options] purchases subscriptions-get [-p ]... [-o ] - androidpublisher2 [options] purchases subscriptions-refund [-p ]... - androidpublisher2 [options] purchases subscriptions-revoke [-p ]... + androidpublisher2 [options] edits apklistings-delete [-p ...] + androidpublisher2 [options] edits apklistings-deleteall [-p ...] + androidpublisher2 [options] edits apklistings-get [-p ...] [-o ] + androidpublisher2 [options] edits apklistings-list [-p ...] [-o ] + androidpublisher2 [options] edits apklistings-patch -r ... [-p ...] [-o ] + androidpublisher2 [options] edits apklistings-update -r ... [-p ...] [-o ] + androidpublisher2 [options] edits apks-addexternallyhosted -r ... [-p ...] [-o ] + androidpublisher2 [options] edits apks-list [-p ...] [-o ] + androidpublisher2 [options] edits apks-upload -u (simple|resumable) [-p ...] [-o ] + androidpublisher2 [options] edits commit [-p ...] [-o ] + androidpublisher2 [options] edits delete [-p ...] + androidpublisher2 [options] edits details-get [-p ...] [-o ] + androidpublisher2 [options] edits details-patch -r ... [-p ...] [-o ] + androidpublisher2 [options] edits details-update -r ... [-p ...] [-o ] + androidpublisher2 [options] edits expansionfiles-get [-p ...] [-o ] + androidpublisher2 [options] edits expansionfiles-patch -r ... [-p ...] [-o ] + androidpublisher2 [options] edits expansionfiles-update -r ... [-p ...] [-o ] + androidpublisher2 [options] edits expansionfiles-upload -u (simple|resumable) [-p ...] [-o ] + androidpublisher2 [options] edits get [-p ...] [-o ] + androidpublisher2 [options] edits images-delete [-p ...] + androidpublisher2 [options] edits images-deleteall [-p ...] [-o ] + androidpublisher2 [options] edits images-list [-p ...] [-o ] + androidpublisher2 [options] edits images-upload -u (simple|resumable) [-p ...] [-o ] + androidpublisher2 [options] edits insert -r ... [-p ...] [-o ] + androidpublisher2 [options] edits listings-delete [-p ...] + androidpublisher2 [options] edits listings-deleteall [-p ...] + androidpublisher2 [options] edits listings-get [-p ...] [-o ] + androidpublisher2 [options] edits listings-list [-p ...] [-o ] + androidpublisher2 [options] edits listings-patch -r ... [-p ...] [-o ] + androidpublisher2 [options] edits listings-update -r ... [-p ...] [-o ] + androidpublisher2 [options] edits testers-get [-p ...] [-o ] + androidpublisher2 [options] edits testers-patch -r ... [-p ...] [-o ] + androidpublisher2 [options] edits testers-update -r ... [-p ...] [-o ] + androidpublisher2 [options] edits tracks-get [-p ...] [-o ] + androidpublisher2 [options] edits tracks-list [-p ...] [-o ] + androidpublisher2 [options] edits tracks-patch -r ... [-p ...] [-o ] + androidpublisher2 [options] edits tracks-update -r ... [-p ...] [-o ] + androidpublisher2 [options] edits validate [-p ...] [-o ] + androidpublisher2 [options] inappproducts batch -r ... [-p ...] [-o ] + androidpublisher2 [options] inappproducts delete [-p ...] + androidpublisher2 [options] inappproducts get [-p ...] [-o ] + androidpublisher2 [options] inappproducts insert -r ... [-p ...] [-o ] + androidpublisher2 [options] inappproducts list [-p ...] [-o ] + androidpublisher2 [options] inappproducts patch -r ... [-p ...] [-o ] + androidpublisher2 [options] inappproducts update -r ... [-p ...] [-o ] + androidpublisher2 [options] purchases products-get [-p ...] [-o ] + androidpublisher2 [options] purchases subscriptions-cancel [-p ...] + androidpublisher2 [options] purchases subscriptions-defer -r ... [-p ...] [-o ] + androidpublisher2 [options] purchases subscriptions-get [-p ...] [-o ] + androidpublisher2 [options] purchases subscriptions-refund [-p ...] + androidpublisher2 [options] purchases subscriptions-revoke [-p ...] androidpublisher2 --help -All documentation details can be found TODO: +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_androidpublisher2_cli/index.html Configuration: --scope - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -138,6 +139,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -180,6 +184,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -222,6 +229,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -266,6 +276,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -282,9 +295,37 @@ impl Engine { fn _edits_apklistings_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::ApkListing::default(); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "recent-changes" => { + request.recent_changes = Some(value.unwrap_or("").to_string()); + }, + "language" => { + request.language = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } let apk_version_code: i32 = arg_from_str(&self.opt.arg_apk_version_code, err, "", "integer"); - let mut call = self.hub.edits().apklistings_patch(&request, &self.opt.arg_package_name, &self.opt.arg_edit_id, apk_version_code, &self.opt.arg_language); + let mut call = self.hub.edits().apklistings_patch(request, &self.opt.arg_package_name, &self.opt.arg_edit_id, apk_version_code, &self.opt.arg_language); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -306,30 +347,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "recent-changes" => { - request.recent_changes = Some(value.unwrap_or("").to_string()); - }, - "language" => { - request.language = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -346,9 +371,37 @@ impl Engine { fn _edits_apklistings_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::ApkListing::default(); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "recent-changes" => { + request.recent_changes = Some(value.unwrap_or("").to_string()); + }, + "language" => { + request.language = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } let apk_version_code: i32 = arg_from_str(&self.opt.arg_apk_version_code, err, "", "integer"); - let mut call = self.hub.edits().apklistings_update(&request, &self.opt.arg_package_name, &self.opt.arg_edit_id, apk_version_code, &self.opt.arg_language); + let mut call = self.hub.edits().apklistings_update(request, &self.opt.arg_package_name, &self.opt.arg_edit_id, apk_version_code, &self.opt.arg_language); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -370,30 +423,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "recent-changes" => { - request.recent_changes = Some(value.unwrap_or("").to_string()); - }, - "language" => { - request.language = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -410,43 +447,30 @@ impl Engine { fn _edits_apks_addexternallyhosted(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::ApksAddExternallyHostedRequest::default(); - let mut call = self.hub.edits().apks_addexternallyhosted(&request, &self.opt.arg_package_name, &self.opt.arg_edit_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ApksAddExternallyHostedRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_externally_hosted_apk_init(request: &mut api::ApksAddExternallyHostedRequest) { if request.externally_hosted_apk.is_none() { request.externally_hosted_apk = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "externally-hosted-apk.icon-base64" => { request_externally_hosted_apk_init(&mut request); request.externally_hosted_apk.as_mut().unwrap().icon_base64 = Some(value.unwrap_or("").to_string()); @@ -513,15 +537,40 @@ impl Engine { request.externally_hosted_apk.as_mut().unwrap().native_codes.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.edits().apks_addexternallyhosted(request, &self.opt.arg_package_name, &self.opt.arg_edit_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -565,6 +614,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -617,6 +669,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -661,6 +716,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -704,6 +762,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -745,6 +806,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -761,8 +825,42 @@ impl Engine { fn _edits_details_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::AppDetails::default(); - let mut call = self.hub.edits().details_patch(&request, &self.opt.arg_package_name, &self.opt.arg_edit_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "contact-email" => { + request.contact_email = Some(value.unwrap_or("").to_string()); + }, + "contact-phone" => { + request.contact_phone = Some(value.unwrap_or("").to_string()); + }, + "contact-website" => { + request.contact_website = Some(value.unwrap_or("").to_string()); + }, + "default-language" => { + request.default_language = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.edits().details_patch(request, &self.opt.arg_package_name, &self.opt.arg_edit_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -784,36 +882,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "contact-email" => { - request.contact_email = Some(value.unwrap_or("").to_string()); - }, - "contact-phone" => { - request.contact_phone = Some(value.unwrap_or("").to_string()); - }, - "contact-website" => { - request.contact_website = Some(value.unwrap_or("").to_string()); - }, - "default-language" => { - request.default_language = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -830,8 +906,42 @@ impl Engine { fn _edits_details_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::AppDetails::default(); - let mut call = self.hub.edits().details_update(&request, &self.opt.arg_package_name, &self.opt.arg_edit_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "contact-email" => { + request.contact_email = Some(value.unwrap_or("").to_string()); + }, + "contact-phone" => { + request.contact_phone = Some(value.unwrap_or("").to_string()); + }, + "contact-website" => { + request.contact_website = Some(value.unwrap_or("").to_string()); + }, + "default-language" => { + request.default_language = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.edits().details_update(request, &self.opt.arg_package_name, &self.opt.arg_edit_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -853,36 +963,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "contact-email" => { - request.contact_email = Some(value.unwrap_or("").to_string()); - }, - "contact-phone" => { - request.contact_phone = Some(value.unwrap_or("").to_string()); - }, - "contact-website" => { - request.contact_website = Some(value.unwrap_or("").to_string()); - }, - "default-language" => { - request.default_language = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -927,6 +1015,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -943,9 +1034,37 @@ impl Engine { fn _edits_expansionfiles_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::ExpansionFile::default(); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "references-version" => { + request.references_version = Some(arg_from_str(value.unwrap_or("-0"), err, "references-version", "integer")); + }, + "file-size" => { + request.file_size = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } let apk_version_code: i32 = arg_from_str(&self.opt.arg_apk_version_code, err, "", "integer"); - let mut call = self.hub.edits().expansionfiles_patch(&request, &self.opt.arg_package_name, &self.opt.arg_edit_id, apk_version_code, &self.opt.arg_expansion_file_type); + let mut call = self.hub.edits().expansionfiles_patch(request, &self.opt.arg_package_name, &self.opt.arg_edit_id, apk_version_code, &self.opt.arg_expansion_file_type); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -967,30 +1086,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "references-version" => { - request.references_version = Some(arg_from_str(value.unwrap_or("-0"), err, "references-version", "integer")); - }, - "file-size" => { - request.file_size = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1007,9 +1110,37 @@ impl Engine { fn _edits_expansionfiles_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::ExpansionFile::default(); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "references-version" => { + request.references_version = Some(arg_from_str(value.unwrap_or("-0"), err, "references-version", "integer")); + }, + "file-size" => { + request.file_size = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } let apk_version_code: i32 = arg_from_str(&self.opt.arg_apk_version_code, err, "", "integer"); - let mut call = self.hub.edits().expansionfiles_update(&request, &self.opt.arg_package_name, &self.opt.arg_edit_id, apk_version_code, &self.opt.arg_expansion_file_type); + let mut call = self.hub.edits().expansionfiles_update(request, &self.opt.arg_package_name, &self.opt.arg_edit_id, apk_version_code, &self.opt.arg_expansion_file_type); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1031,30 +1162,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "references-version" => { - request.references_version = Some(arg_from_str(value.unwrap_or("-0"), err, "references-version", "integer")); - }, - "file-size" => { - request.file_size = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1108,6 +1223,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -1152,6 +1270,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1195,6 +1316,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1236,6 +1360,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1279,6 +1406,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1331,6 +1461,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -1348,8 +1481,36 @@ impl Engine { fn _edits_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::AppEdit::default(); - let mut call = self.hub.edits().insert(&request, &self.opt.arg_package_name); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "expiry-time-seconds" => { + request.expiry_time_seconds = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.edits().insert(request, &self.opt.arg_package_name); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1371,30 +1532,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "expiry-time-seconds" => { - request.expiry_time_seconds = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1438,6 +1583,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1479,6 +1627,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1520,6 +1671,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1563,6 +1717,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1579,8 +1736,45 @@ impl Engine { fn _edits_listings_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Listing::default(); - let mut call = self.hub.edits().listings_patch(&request, &self.opt.arg_package_name, &self.opt.arg_edit_id, &self.opt.arg_language); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "short-description" => { + request.short_description = Some(value.unwrap_or("").to_string()); + }, + "video" => { + request.video = Some(value.unwrap_or("").to_string()); + }, + "full-description" => { + request.full_description = Some(value.unwrap_or("").to_string()); + }, + "language" => { + request.language = Some(value.unwrap_or("").to_string()); + }, + "title" => { + request.title = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.edits().listings_patch(request, &self.opt.arg_package_name, &self.opt.arg_edit_id, &self.opt.arg_language); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1602,39 +1796,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "short-description" => { - request.short_description = Some(value.unwrap_or("").to_string()); - }, - "video" => { - request.video = Some(value.unwrap_or("").to_string()); - }, - "full-description" => { - request.full_description = Some(value.unwrap_or("").to_string()); - }, - "language" => { - request.language = Some(value.unwrap_or("").to_string()); - }, - "title" => { - request.title = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1651,8 +1820,45 @@ impl Engine { fn _edits_listings_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Listing::default(); - let mut call = self.hub.edits().listings_update(&request, &self.opt.arg_package_name, &self.opt.arg_edit_id, &self.opt.arg_language); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "short-description" => { + request.short_description = Some(value.unwrap_or("").to_string()); + }, + "video" => { + request.video = Some(value.unwrap_or("").to_string()); + }, + "full-description" => { + request.full_description = Some(value.unwrap_or("").to_string()); + }, + "language" => { + request.language = Some(value.unwrap_or("").to_string()); + }, + "title" => { + request.title = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.edits().listings_update(request, &self.opt.arg_package_name, &self.opt.arg_edit_id, &self.opt.arg_language); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1674,39 +1880,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "short-description" => { - request.short_description = Some(value.unwrap_or("").to_string()); - }, - "video" => { - request.video = Some(value.unwrap_or("").to_string()); - }, - "full-description" => { - request.full_description = Some(value.unwrap_or("").to_string()); - }, - "language" => { - request.language = Some(value.unwrap_or("").to_string()); - }, - "title" => { - request.title = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1750,6 +1931,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1766,8 +1950,42 @@ impl Engine { fn _edits_testers_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Testers::default(); - let mut call = self.hub.edits().testers_patch(&request, &self.opt.arg_package_name, &self.opt.arg_edit_id, &self.opt.arg_track); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "google-groups" => { + if request.google_groups.is_none() { + request.google_groups = Some(Default::default()); + } + request.google_groups.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "google-plus-communities" => { + if request.google_plus_communities.is_none() { + request.google_plus_communities = Some(Default::default()); + } + request.google_plus_communities.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.edits().testers_patch(request, &self.opt.arg_package_name, &self.opt.arg_edit_id, &self.opt.arg_track); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1789,36 +2007,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "google-groups" => { - if request.google_groups.is_none() { - request.google_groups = Some(Default::default()); - } - request.google_groups.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "google-plus-communities" => { - if request.google_plus_communities.is_none() { - request.google_plus_communities = Some(Default::default()); - } - request.google_plus_communities.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1835,8 +2031,42 @@ impl Engine { fn _edits_testers_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Testers::default(); - let mut call = self.hub.edits().testers_update(&request, &self.opt.arg_package_name, &self.opt.arg_edit_id, &self.opt.arg_track); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "google-groups" => { + if request.google_groups.is_none() { + request.google_groups = Some(Default::default()); + } + request.google_groups.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "google-plus-communities" => { + if request.google_plus_communities.is_none() { + request.google_plus_communities = Some(Default::default()); + } + request.google_plus_communities.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.edits().testers_update(request, &self.opt.arg_package_name, &self.opt.arg_edit_id, &self.opt.arg_track); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1858,36 +2088,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "google-groups" => { - if request.google_groups.is_none() { - request.google_groups = Some(Default::default()); - } - request.google_groups.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "google-plus-communities" => { - if request.google_plus_communities.is_none() { - request.google_plus_communities = Some(Default::default()); - } - request.google_plus_communities.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1931,6 +2139,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1974,6 +2185,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1990,8 +2204,42 @@ impl Engine { fn _edits_tracks_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Track::default(); - let mut call = self.hub.edits().tracks_patch(&request, &self.opt.arg_package_name, &self.opt.arg_edit_id, &self.opt.arg_track); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "track" => { + request.track = Some(value.unwrap_or("").to_string()); + }, + "user-fraction" => { + request.user_fraction = Some(arg_from_str(value.unwrap_or("0.0"), err, "user-fraction", "number")); + }, + "version-codes" => { + if request.version_codes.is_none() { + request.version_codes = Some(Default::default()); + } + request.version_codes.as_mut().unwrap().push(arg_from_str(value.unwrap_or("-0"), err, "version-codes", "integer")); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.edits().tracks_patch(request, &self.opt.arg_package_name, &self.opt.arg_edit_id, &self.opt.arg_track); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2013,36 +2261,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "track" => { - request.track = Some(value.unwrap_or("").to_string()); - }, - "user-fraction" => { - request.user_fraction = Some(arg_from_str(value.unwrap_or("0.0"), err, "user-fraction", "number")); - }, - "version-codes" => { - if request.version_codes.is_none() { - request.version_codes = Some(Default::default()); - } - request.version_codes.as_mut().unwrap().push(arg_from_str(value.unwrap_or("-0"), err, "version-codes", "integer")); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2059,8 +2285,42 @@ impl Engine { fn _edits_tracks_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Track::default(); - let mut call = self.hub.edits().tracks_update(&request, &self.opt.arg_package_name, &self.opt.arg_edit_id, &self.opt.arg_track); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "track" => { + request.track = Some(value.unwrap_or("").to_string()); + }, + "user-fraction" => { + request.user_fraction = Some(arg_from_str(value.unwrap_or("0.0"), err, "user-fraction", "number")); + }, + "version-codes" => { + if request.version_codes.is_none() { + request.version_codes = Some(Default::default()); + } + request.version_codes.as_mut().unwrap().push(arg_from_str(value.unwrap_or("-0"), err, "version-codes", "integer")); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.edits().tracks_update(request, &self.opt.arg_package_name, &self.opt.arg_edit_id, &self.opt.arg_track); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2082,36 +2342,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "track" => { - request.track = Some(value.unwrap_or("").to_string()); - }, - "user-fraction" => { - request.user_fraction = Some(arg_from_str(value.unwrap_or("0.0"), err, "user-fraction", "number")); - }, - "version-codes" => { - if request.version_codes.is_none() { - request.version_codes = Some(Default::default()); - } - request.version_codes.as_mut().unwrap().push(arg_from_str(value.unwrap_or("-0"), err, "version-codes", "integer")); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2155,6 +2393,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2171,8 +2412,30 @@ impl Engine { fn _inappproducts_batch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::InappproductsBatchRequest::default(); - let mut call = self.hub.inappproducts().batch(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.inappproducts().batch(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2194,24 +2457,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2255,6 +2508,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2296,6 +2552,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2312,39 +2571,23 @@ impl Engine { fn _inappproducts_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::InAppProduct::default(); - let mut call = self.hub.inappproducts().insert(&request, &self.opt.arg_package_name); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "auto-convert-missing-prices" => { - call = call.auto_convert_missing_prices(arg_from_str(value.unwrap_or("false"), err, "auto-convert-missing-prices", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::InAppProduct::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_default_price_init(request: &mut api::InAppProduct) { if request.default_price.is_none() { request.default_price = Some(Default::default()); @@ -2371,7 +2614,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "sku" => { request.sku = Some(value.unwrap_or("").to_string()); }, @@ -2422,15 +2665,43 @@ impl Engine { request.default_price.as_mut().unwrap().price_micros = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.inappproducts().insert(request, &self.opt.arg_package_name); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "auto-convert-missing-prices" => { + call = call.auto_convert_missing_prices(arg_from_str(value.unwrap_or("false"), err, "auto-convert-missing-prices", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2483,6 +2754,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2499,39 +2773,23 @@ impl Engine { fn _inappproducts_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::InAppProduct::default(); - let mut call = self.hub.inappproducts().patch(&request, &self.opt.arg_package_name, &self.opt.arg_sku); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "auto-convert-missing-prices" => { - call = call.auto_convert_missing_prices(arg_from_str(value.unwrap_or("false"), err, "auto-convert-missing-prices", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::InAppProduct::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_default_price_init(request: &mut api::InAppProduct) { if request.default_price.is_none() { request.default_price = Some(Default::default()); @@ -2558,7 +2816,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "sku" => { request.sku = Some(value.unwrap_or("").to_string()); }, @@ -2609,15 +2867,43 @@ impl Engine { request.default_price.as_mut().unwrap().price_micros = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.inappproducts().patch(request, &self.opt.arg_package_name, &self.opt.arg_sku); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "auto-convert-missing-prices" => { + call = call.auto_convert_missing_prices(arg_from_str(value.unwrap_or("false"), err, "auto-convert-missing-prices", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2634,39 +2920,23 @@ impl Engine { fn _inappproducts_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::InAppProduct::default(); - let mut call = self.hub.inappproducts().update(&request, &self.opt.arg_package_name, &self.opt.arg_sku); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "auto-convert-missing-prices" => { - call = call.auto_convert_missing_prices(arg_from_str(value.unwrap_or("false"), err, "auto-convert-missing-prices", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::InAppProduct::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_default_price_init(request: &mut api::InAppProduct) { if request.default_price.is_none() { request.default_price = Some(Default::default()); @@ -2693,7 +2963,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "sku" => { request.sku = Some(value.unwrap_or("").to_string()); }, @@ -2744,15 +3014,43 @@ impl Engine { request.default_price.as_mut().unwrap().price_micros = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.inappproducts().update(request, &self.opt.arg_package_name, &self.opt.arg_sku); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "auto-convert-missing-prices" => { + call = call.auto_convert_missing_prices(arg_from_str(value.unwrap_or("false"), err, "auto-convert-missing-prices", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2796,6 +3094,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2839,6 +3140,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2853,8 +3157,44 @@ impl Engine { fn _purchases_subscriptions_defer(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::SubscriptionPurchasesDeferRequest::default(); - let mut call = self.hub.purchases().subscriptions_defer(&request, &self.opt.arg_package_name, &self.opt.arg_subscription_id, &self.opt.arg_token); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + fn request_deferral_info_init(request: &mut api::SubscriptionPurchasesDeferRequest) { + if request.deferral_info.is_none() { + request.deferral_info = Some(Default::default()); + } + } + + match &temp_cursor.to_string()[..] { + "deferral-info.expected-expiry-time-millis" => { + request_deferral_info_init(&mut request); + request.deferral_info.as_mut().unwrap().expected_expiry_time_millis = Some(value.unwrap_or("").to_string()); + }, + "deferral-info.desired-expiry-time-millis" => { + request_deferral_info_init(&mut request); + request.deferral_info.as_mut().unwrap().desired_expiry_time_millis = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.purchases().subscriptions_defer(request, &self.opt.arg_package_name, &self.opt.arg_subscription_id, &self.opt.arg_token); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2876,38 +3216,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_deferral_info_init(request: &mut api::SubscriptionPurchasesDeferRequest) { - if request.deferral_info.is_none() { - request.deferral_info = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "deferral-info.expected-expiry-time-millis" => { - request_deferral_info_init(&mut request); - request.deferral_info.as_mut().unwrap().expected_expiry_time_millis = Some(value.unwrap_or("").to_string()); - }, - "deferral-info.desired-expiry-time-millis" => { - request_deferral_info_init(&mut request); - request.deferral_info.as_mut().unwrap().desired_expiry_time_millis = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2951,6 +3267,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2994,6 +3313,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -3035,6 +3357,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -3236,6 +3561,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -3243,8 +3569,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/androidpublisher2/Cargo.toml b/gen/androidpublisher2/Cargo.toml index 62ecf1daa5..2a7fbe3064 100644 --- a/gen/androidpublisher2/Cargo.toml +++ b/gen/androidpublisher2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-androidpublisher2" -version = "0.1.5+20150323" +version = "0.1.6+20150323" authors = ["Sebastian Thiel "] description = "A complete library to interact with Android Publisher (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/androidpublisher2" diff --git a/gen/androidpublisher2/README.md b/gen/androidpublisher2/README.md index 1861b4ec00..d44eb2dbcb 100644 --- a/gen/androidpublisher2/README.md +++ b/gen/androidpublisher2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-androidpublisher2` library allows access to all features of the *Google Android Publisher* service. -This documentation was generated from *Android Publisher* crate version *0.1.5+20150323*, where *20150323* is the exact revision of the *androidpublisher:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *Android Publisher* crate version *0.1.6+20150323*, where *20150323* is the exact revision of the *androidpublisher:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *Android Publisher* *v2* API can be found at the [official documentation site](https://developers.google.com/android-publisher). @@ -111,7 +111,7 @@ let mut req = InAppProduct::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.inappproducts().patch(&req, "packageName", "sku") +let result = hub.inappproducts().patch(req, "packageName", "sku") .auto_convert_missing_prices(false) .doit(); @@ -119,14 +119,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/androidpublisher2/src/cmn.rs b/gen/androidpublisher2/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/androidpublisher2/src/cmn.rs +++ b/gen/androidpublisher2/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option, + location: Option +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option, _: Option) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec]) -> Option { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/androidpublisher2/src/lib.rs b/gen/androidpublisher2/src/lib.rs index 2dd5cd8239..895314c563 100644 --- a/gen/androidpublisher2/src/lib.rs +++ b/gen/androidpublisher2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Android Publisher* crate version *0.1.5+20150323*, where *20150323* is the exact revision of the *androidpublisher:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *Android Publisher* crate version *0.1.6+20150323*, where *20150323* is the exact revision of the *androidpublisher:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *Android Publisher* *v2* API can be found at the //! [official documentation site](https://developers.google.com/android-publisher). @@ -112,7 +112,7 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.inappproducts().patch(&req, "packageName", "sku") +//! let result = hub.inappproducts().patch(req, "packageName", "sku") //! .auto_convert_missing_prices(true) //! .doit(); //! @@ -120,14 +120,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -215,7 +216,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -288,7 +289,7 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.inappproducts().patch(&req, "packageName", "sku") +/// let result = hub.inappproducts().patch(req, "packageName", "sku") /// .auto_convert_missing_prices(true) /// .doit(); /// @@ -296,14 +297,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -324,7 +326,7 @@ impl<'a, C, A> AndroidPublisher AndroidPublisher { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -339,7 +341,7 @@ impl<'a, C, A> AndroidPublisher } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -1431,10 +1433,10 @@ impl<'a, C, A> PurchaseMethods<'a, C, A> { /// * `packageName` - The package name of the application for which this subscription was purchased (for example, 'com.some.thing'). /// * `subscriptionId` - The purchased subscription ID (for example, 'monthly001'). /// * `token` - The token provided to the user's device when the subscription was purchased. - pub fn subscriptions_defer(&self, request: &SubscriptionPurchasesDeferRequest, package_name: &str, subscription_id: &str, token: &str) -> PurchaseSubscriptionDeferCall<'a, C, A> { + pub fn subscriptions_defer(&self, request: SubscriptionPurchasesDeferRequest, package_name: &str, subscription_id: &str, token: &str) -> PurchaseSubscriptionDeferCall<'a, C, A> { PurchaseSubscriptionDeferCall { hub: self.hub, - _request: request.clone(), + _request: request, _package_name: package_name.to_string(), _subscription_id: subscription_id.to_string(), _token: token.to_string(), @@ -1519,10 +1521,10 @@ impl<'a, C, A> EditMethods<'a, C, A> { /// * `editId` - Unique identifier for this edit. /// * `apkVersionCode` - The version code of the APK whose Expansion File configuration is being read or modified. /// * `expansionFileType` - No description provided. - pub fn expansionfiles_update(&self, request: &ExpansionFile, package_name: &str, edit_id: &str, apk_version_code: i32, expansion_file_type: &str) -> EditExpansionfileUpdateCall<'a, C, A> { + pub fn expansionfiles_update(&self, request: ExpansionFile, package_name: &str, edit_id: &str, apk_version_code: i32, expansion_file_type: &str) -> EditExpansionfileUpdateCall<'a, C, A> { EditExpansionfileUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _package_name: package_name.to_string(), _edit_id: edit_id.to_string(), _apk_version_code: apk_version_code, @@ -1603,10 +1605,10 @@ impl<'a, C, A> EditMethods<'a, C, A> { /// * `request` - No description provided. /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// * `editId` - Unique identifier for this edit. - pub fn apks_addexternallyhosted(&self, request: &ApksAddExternallyHostedRequest, package_name: &str, edit_id: &str) -> EditApkAddexternallyhostedCall<'a, C, A> { + pub fn apks_addexternallyhosted(&self, request: ApksAddExternallyHostedRequest, package_name: &str, edit_id: &str) -> EditApkAddexternallyhostedCall<'a, C, A> { EditApkAddexternallyhostedCall { hub: self.hub, - _request: request.clone(), + _request: request, _package_name: package_name.to_string(), _edit_id: edit_id.to_string(), _delegate: Default::default(), @@ -1645,10 +1647,10 @@ impl<'a, C, A> EditMethods<'a, C, A> { /// * `request` - No description provided. /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// * `editId` - Unique identifier for this edit. - pub fn details_update(&self, request: &AppDetails, package_name: &str, edit_id: &str) -> EditDetailUpdateCall<'a, C, A> { + pub fn details_update(&self, request: AppDetails, package_name: &str, edit_id: &str) -> EditDetailUpdateCall<'a, C, A> { EditDetailUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _package_name: package_name.to_string(), _edit_id: edit_id.to_string(), _delegate: Default::default(), @@ -1689,10 +1691,10 @@ impl<'a, C, A> EditMethods<'a, C, A> { /// * `editId` - Unique identifier for this edit. /// * `apkVersionCode` - The version code of the APK whose Expansion File configuration is being read or modified. /// * `expansionFileType` - No description provided. - pub fn expansionfiles_patch(&self, request: &ExpansionFile, package_name: &str, edit_id: &str, apk_version_code: i32, expansion_file_type: &str) -> EditExpansionfilePatchCall<'a, C, A> { + pub fn expansionfiles_patch(&self, request: ExpansionFile, package_name: &str, edit_id: &str, apk_version_code: i32, expansion_file_type: &str) -> EditExpansionfilePatchCall<'a, C, A> { EditExpansionfilePatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _package_name: package_name.to_string(), _edit_id: edit_id.to_string(), _apk_version_code: apk_version_code, @@ -1736,10 +1738,10 @@ impl<'a, C, A> EditMethods<'a, C, A> { /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// * `editId` - Unique identifier for this edit. /// * `track` - The track type to read or modify. - pub fn tracks_update(&self, request: &Track, package_name: &str, edit_id: &str, track: &str) -> EditTrackUpdateCall<'a, C, A> { + pub fn tracks_update(&self, request: Track, package_name: &str, edit_id: &str, track: &str) -> EditTrackUpdateCall<'a, C, A> { EditTrackUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _package_name: package_name.to_string(), _edit_id: edit_id.to_string(), _track: track.to_string(), @@ -1759,10 +1761,10 @@ impl<'a, C, A> EditMethods<'a, C, A> { /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// * `editId` - Unique identifier for this edit. /// * `language` - The language code (a BCP-47 language tag) of the localized listing to read or modify. For example, to select Austrian German, pass "de-AT". - pub fn listings_patch(&self, request: &Listing, package_name: &str, edit_id: &str, language: &str) -> EditListingPatchCall<'a, C, A> { + pub fn listings_patch(&self, request: Listing, package_name: &str, edit_id: &str, language: &str) -> EditListingPatchCall<'a, C, A> { EditListingPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _package_name: package_name.to_string(), _edit_id: edit_id.to_string(), _language: language.to_string(), @@ -1843,10 +1845,10 @@ impl<'a, C, A> EditMethods<'a, C, A> { /// * `editId` - Unique identifier for this edit. /// * `apkVersionCode` - The APK version code whose APK-specific listings should be read or modified. /// * `language` - The language code (a BCP-47 language tag) of the APK-specific localized listing to read or modify. For example, to select Austrian German, pass "de-AT". - pub fn apklistings_update(&self, request: &ApkListing, package_name: &str, edit_id: &str, apk_version_code: i32, language: &str) -> EditApklistingUpdateCall<'a, C, A> { + pub fn apklistings_update(&self, request: ApkListing, package_name: &str, edit_id: &str, apk_version_code: i32, language: &str) -> EditApklistingUpdateCall<'a, C, A> { EditApklistingUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _package_name: package_name.to_string(), _edit_id: edit_id.to_string(), _apk_version_code: apk_version_code, @@ -1884,10 +1886,10 @@ impl<'a, C, A> EditMethods<'a, C, A> { /// * `editId` - Unique identifier for this edit. /// * `apkVersionCode` - The APK version code whose APK-specific listings should be read or modified. /// * `language` - The language code (a BCP-47 language tag) of the APK-specific localized listing to read or modify. For example, to select Austrian German, pass "de-AT". - pub fn apklistings_patch(&self, request: &ApkListing, package_name: &str, edit_id: &str, apk_version_code: i32, language: &str) -> EditApklistingPatchCall<'a, C, A> { + pub fn apklistings_patch(&self, request: ApkListing, package_name: &str, edit_id: &str, apk_version_code: i32, language: &str) -> EditApklistingPatchCall<'a, C, A> { EditApklistingPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _package_name: package_name.to_string(), _edit_id: edit_id.to_string(), _apk_version_code: apk_version_code, @@ -1987,10 +1989,10 @@ impl<'a, C, A> EditMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame". - pub fn insert(&self, request: &AppEdit, package_name: &str) -> EditInsertCall<'a, C, A> { + pub fn insert(&self, request: AppEdit, package_name: &str) -> EditInsertCall<'a, C, A> { EditInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _package_name: package_name.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2024,10 +2026,10 @@ impl<'a, C, A> EditMethods<'a, C, A> { /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// * `editId` - Unique identifier for this edit. /// * `track` - No description provided. - pub fn testers_patch(&self, request: &Testers, package_name: &str, edit_id: &str, track: &str) -> EditTesterPatchCall<'a, C, A> { + pub fn testers_patch(&self, request: Testers, package_name: &str, edit_id: &str, track: &str) -> EditTesterPatchCall<'a, C, A> { EditTesterPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _package_name: package_name.to_string(), _edit_id: edit_id.to_string(), _track: track.to_string(), @@ -2104,10 +2106,10 @@ impl<'a, C, A> EditMethods<'a, C, A> { /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// * `editId` - Unique identifier for this edit. /// * `language` - The language code (a BCP-47 language tag) of the localized listing to read or modify. For example, to select Austrian German, pass "de-AT". - pub fn listings_update(&self, request: &Listing, package_name: &str, edit_id: &str, language: &str) -> EditListingUpdateCall<'a, C, A> { + pub fn listings_update(&self, request: Listing, package_name: &str, edit_id: &str, language: &str) -> EditListingUpdateCall<'a, C, A> { EditListingUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _package_name: package_name.to_string(), _edit_id: edit_id.to_string(), _language: language.to_string(), @@ -2172,10 +2174,10 @@ impl<'a, C, A> EditMethods<'a, C, A> { /// * `request` - No description provided. /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// * `editId` - Unique identifier for this edit. - pub fn details_patch(&self, request: &AppDetails, package_name: &str, edit_id: &str) -> EditDetailPatchCall<'a, C, A> { + pub fn details_patch(&self, request: AppDetails, package_name: &str, edit_id: &str) -> EditDetailPatchCall<'a, C, A> { EditDetailPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _package_name: package_name.to_string(), _edit_id: edit_id.to_string(), _delegate: Default::default(), @@ -2194,10 +2196,10 @@ impl<'a, C, A> EditMethods<'a, C, A> { /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// * `editId` - Unique identifier for this edit. /// * `track` - The track type to read or modify. - pub fn tracks_patch(&self, request: &Track, package_name: &str, edit_id: &str, track: &str) -> EditTrackPatchCall<'a, C, A> { + pub fn tracks_patch(&self, request: Track, package_name: &str, edit_id: &str, track: &str) -> EditTrackPatchCall<'a, C, A> { EditTrackPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _package_name: package_name.to_string(), _edit_id: edit_id.to_string(), _track: track.to_string(), @@ -2258,10 +2260,10 @@ impl<'a, C, A> EditMethods<'a, C, A> { /// * `packageName` - Unique identifier for the Android app that is being updated; for example, "com.spiffygame". /// * `editId` - Unique identifier for this edit. /// * `track` - No description provided. - pub fn testers_update(&self, request: &Testers, package_name: &str, edit_id: &str, track: &str) -> EditTesterUpdateCall<'a, C, A> { + pub fn testers_update(&self, request: Testers, package_name: &str, edit_id: &str, track: &str) -> EditTesterUpdateCall<'a, C, A> { EditTesterUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _package_name: package_name.to_string(), _edit_id: edit_id.to_string(), _track: track.to_string(), @@ -2337,10 +2339,10 @@ impl<'a, C, A> InappproductMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn batch(&self, request: &InappproductsBatchRequest) -> InappproductBatchCall<'a, C, A> { + pub fn batch(&self, request: InappproductsBatchRequest) -> InappproductBatchCall<'a, C, A> { InappproductBatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2375,10 +2377,10 @@ impl<'a, C, A> InappproductMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `packageName` - Unique identifier for the Android app; for example, "com.spiffygame". - pub fn insert(&self, request: &InAppProduct, package_name: &str) -> InappproductInsertCall<'a, C, A> { + pub fn insert(&self, request: InAppProduct, package_name: &str) -> InappproductInsertCall<'a, C, A> { InappproductInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _package_name: package_name.to_string(), _auto_convert_missing_prices: Default::default(), _delegate: Default::default(), @@ -2434,10 +2436,10 @@ impl<'a, C, A> InappproductMethods<'a, C, A> { /// * `request` - No description provided. /// * `packageName` - Unique identifier for the Android app with the in-app product; for example, "com.spiffygame". /// * `sku` - Unique identifier for the in-app product. - pub fn update(&self, request: &InAppProduct, package_name: &str, sku: &str) -> InappproductUpdateCall<'a, C, A> { + pub fn update(&self, request: InAppProduct, package_name: &str, sku: &str) -> InappproductUpdateCall<'a, C, A> { InappproductUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _package_name: package_name.to_string(), _sku: sku.to_string(), _auto_convert_missing_prices: Default::default(), @@ -2456,10 +2458,10 @@ impl<'a, C, A> InappproductMethods<'a, C, A> { /// * `request` - No description provided. /// * `packageName` - Unique identifier for the Android app with the in-app product; for example, "com.spiffygame". /// * `sku` - Unique identifier for the in-app product. - pub fn patch(&self, request: &InAppProduct, package_name: &str, sku: &str) -> InappproductPatchCall<'a, C, A> { + pub fn patch(&self, request: InAppProduct, package_name: &str, sku: &str) -> InappproductPatchCall<'a, C, A> { InappproductPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _package_name: package_name.to_string(), _sku: sku.to_string(), _auto_convert_missing_prices: Default::default(), @@ -2626,12 +2628,17 @@ impl<'a, C, A> PurchaseSubscriptionRevokeCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -2874,12 +2881,17 @@ impl<'a, C, A> PurchaseProductGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2888,7 +2900,7 @@ impl<'a, C, A> PurchaseProductGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3132,12 +3144,17 @@ impl<'a, C, A> PurchaseSubscriptionGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3146,7 +3163,7 @@ impl<'a, C, A> PurchaseSubscriptionGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3389,12 +3406,17 @@ impl<'a, C, A> PurchaseSubscriptionCancelCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -3636,12 +3658,17 @@ impl<'a, C, A> PurchaseSubscriptionRefundCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -3767,7 +3794,7 @@ impl<'a, C, A> PurchaseSubscriptionRefundCall<'a, C, A> where C: BorrowMut PurchaseSubscriptionDeferCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3913,7 +3945,7 @@ impl<'a, C, A> PurchaseSubscriptionDeferCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3931,8 +3963,8 @@ impl<'a, C, A> PurchaseSubscriptionDeferCall<'a, C, A> where C: BorrowMut PurchaseSubscriptionDeferCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: SubscriptionPurchasesDeferRequest) -> PurchaseSubscriptionDeferCall<'a, C, A> { + self._request = new_value; self } /// The package name of the application for which this subscription was purchased (for example, 'com.some.thing'). @@ -4095,14 +4127,15 @@ impl<'a, C, A> EditImageUploadCall<'a, C, A> where C: BorrowMut, params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/listings/{language}/{imageType}".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/listings/{language}/{imageType}".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/listings/{language}/{imageType}".to_string() + ("https://www.googleapis.com/resumable/upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/listings/{language}/{imageType}".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } @@ -4208,12 +4241,17 @@ impl<'a, C, A> EditImageUploadCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -4223,9 +4261,9 @@ impl<'a, C, A> EditImageUploadCall<'a, C, A> where C: BorrowMut, } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -4235,7 +4273,7 @@ impl<'a, C, A> EditImageUploadCall<'a, C, A> where C: BorrowMut, auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -4266,7 +4304,7 @@ impl<'a, C, A> EditImageUploadCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4428,7 +4466,7 @@ impl<'a, C, A> EditImageUploadCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.edits().expansionfiles_update(&req, "packageName", "editId", -75, "expansionFileType") +/// let result = hub.edits().expansionfiles_update(req, "packageName", "editId", -75, "expansionFileType") /// .doit(); /// # } /// ``` @@ -4562,12 +4600,17 @@ impl<'a, C, A> EditExpansionfileUpdateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4576,7 +4619,7 @@ impl<'a, C, A> EditExpansionfileUpdateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4594,8 +4637,8 @@ impl<'a, C, A> EditExpansionfileUpdateCall<'a, C, A> where C: BorrowMut EditExpansionfileUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ExpansionFile) -> EditExpansionfileUpdateCall<'a, C, A> { + self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". @@ -4836,12 +4879,17 @@ impl<'a, C, A> EditDetailGetCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4850,7 +4898,7 @@ impl<'a, C, A> EditDetailGetCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5085,12 +5133,17 @@ impl<'a, C, A> EditApklistingDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -5340,12 +5393,17 @@ impl<'a, C, A> EditListingDeleteallCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -5461,7 +5519,7 @@ impl<'a, C, A> EditListingDeleteallCall<'a, C, A> where C: BorrowMut EditApkAddexternallyhostedCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5605,7 +5668,7 @@ impl<'a, C, A> EditApkAddexternallyhostedCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5623,8 +5686,8 @@ impl<'a, C, A> EditApkAddexternallyhostedCall<'a, C, A> where C: BorrowMut EditApkAddexternallyhostedCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ApksAddExternallyHostedRequest) -> EditApkAddexternallyhostedCall<'a, C, A> { + self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". @@ -5847,12 +5910,17 @@ impl<'a, C, A> EditApklistingDeleteallCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -5978,7 +6046,7 @@ impl<'a, C, A> EditApklistingDeleteallCall<'a, C, A> where C: BorrowMut EditDetailUpdateCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6122,7 +6195,7 @@ impl<'a, C, A> EditDetailUpdateCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6140,8 +6213,8 @@ impl<'a, C, A> EditDetailUpdateCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AppDetails) -> EditDetailUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AppDetails) -> EditDetailUpdateCall<'a, C, A> { + self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". @@ -6365,12 +6438,17 @@ impl<'a, C, A> EditTrackGetCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6379,7 +6457,7 @@ impl<'a, C, A> EditTrackGetCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6506,7 +6584,7 @@ impl<'a, C, A> EditTrackGetCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.edits().expansionfiles_patch(&req, "packageName", "editId", -46, "expansionFileType") +/// let result = hub.edits().expansionfiles_patch(req, "packageName", "editId", -46, "expansionFileType") /// .doit(); /// # } /// ``` @@ -6640,12 +6718,17 @@ impl<'a, C, A> EditExpansionfilePatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6654,7 +6737,7 @@ impl<'a, C, A> EditExpansionfilePatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6672,8 +6755,8 @@ impl<'a, C, A> EditExpansionfilePatchCall<'a, C, A> where C: BorrowMut EditExpansionfilePatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ExpansionFile) -> EditExpansionfilePatchCall<'a, C, A> { + self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". @@ -6918,12 +7001,17 @@ impl<'a, C, A> EditImageListCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6932,7 +7020,7 @@ impl<'a, C, A> EditImageListCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7068,7 +7156,7 @@ impl<'a, C, A> EditImageListCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.edits().tracks_update(&req, "packageName", "editId", "track") +/// let result = hub.edits().tracks_update(req, "packageName", "editId", "track") /// .doit(); /// # } /// ``` @@ -7200,12 +7288,17 @@ impl<'a, C, A> EditTrackUpdateCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7214,7 +7307,7 @@ impl<'a, C, A> EditTrackUpdateCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7232,8 +7325,8 @@ impl<'a, C, A> EditTrackUpdateCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Track) -> EditTrackUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Track) -> EditTrackUpdateCall<'a, C, A> { + self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". @@ -7350,7 +7443,7 @@ impl<'a, C, A> EditTrackUpdateCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.edits().listings_patch(&req, "packageName", "editId", "language") +/// let result = hub.edits().listings_patch(req, "packageName", "editId", "language") /// .doit(); /// # } /// ``` @@ -7482,12 +7575,17 @@ impl<'a, C, A> EditListingPatchCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7496,7 +7594,7 @@ impl<'a, C, A> EditListingPatchCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7514,8 +7612,8 @@ impl<'a, C, A> EditListingPatchCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Listing) -> EditListingPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Listing) -> EditListingPatchCall<'a, C, A> { + self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". @@ -7747,12 +7845,17 @@ impl<'a, C, A> EditGetCall<'a, C, A> where C: BorrowMut, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7761,7 +7864,7 @@ impl<'a, C, A> EditGetCall<'a, C, A> where C: BorrowMut, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7998,12 +8101,17 @@ impl<'a, C, A> EditImageDeleteCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -8188,14 +8296,15 @@ impl<'a, C, A> EditApkUploadCall<'a, C, A> where C: BorrowMut, A: params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks".to_string() + ("https://www.googleapis.com/resumable/upload/androidpublisher/v2/applications/{packageName}/edits/{editId}/apks".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } @@ -8301,12 +8410,17 @@ impl<'a, C, A> EditApkUploadCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -8316,9 +8430,9 @@ impl<'a, C, A> EditApkUploadCall<'a, C, A> where C: BorrowMut, A: } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -8328,7 +8442,7 @@ impl<'a, C, A> EditApkUploadCall<'a, C, A> where C: BorrowMut, A: auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -8359,7 +8473,7 @@ impl<'a, C, A> EditApkUploadCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8502,7 +8616,7 @@ impl<'a, C, A> EditApkUploadCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.edits().apklistings_update(&req, "packageName", "editId", -95, "language") +/// let result = hub.edits().apklistings_update(req, "packageName", "editId", -95, "language") /// .doit(); /// # } /// ``` @@ -8636,12 +8750,17 @@ impl<'a, C, A> EditApklistingUpdateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8650,7 +8769,7 @@ impl<'a, C, A> EditApklistingUpdateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8668,8 +8787,8 @@ impl<'a, C, A> EditApklistingUpdateCall<'a, C, A> where C: BorrowMut EditApklistingUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ApkListing) -> EditApklistingUpdateCall<'a, C, A> { + self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". @@ -8909,12 +9028,17 @@ impl<'a, C, A> EditApkListCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8923,7 +9047,7 @@ impl<'a, C, A> EditApkListCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9040,7 +9164,7 @@ impl<'a, C, A> EditApkListCall<'a, C, A> where C: BorrowMut, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.edits().apklistings_patch(&req, "packageName", "editId", -5, "language") +/// let result = hub.edits().apklistings_patch(req, "packageName", "editId", -5, "language") /// .doit(); /// # } /// ``` @@ -9174,12 +9298,17 @@ impl<'a, C, A> EditApklistingPatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9188,7 +9317,7 @@ impl<'a, C, A> EditApklistingPatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9206,8 +9335,8 @@ impl<'a, C, A> EditApklistingPatchCall<'a, C, A> where C: BorrowMut EditApklistingPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ApkListing) -> EditApklistingPatchCall<'a, C, A> { + self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". @@ -9451,12 +9580,17 @@ impl<'a, C, A> EditListingGetCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9465,7 +9599,7 @@ impl<'a, C, A> EditListingGetCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9707,12 +9841,17 @@ impl<'a, C, A> EditTesterGetCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9721,7 +9860,7 @@ impl<'a, C, A> EditTesterGetCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9961,12 +10100,17 @@ impl<'a, C, A> EditDeleteCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -10128,14 +10272,15 @@ impl<'a, C, A> EditExpansionfileUploadCall<'a, C, A> where C: BorrowMut EditExpansionfileUploadCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -10256,9 +10406,9 @@ impl<'a, C, A> EditExpansionfileUploadCall<'a, C, A> where C: BorrowMut().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -10268,7 +10418,7 @@ impl<'a, C, A> EditExpansionfileUploadCall<'a, C, A> where C: BorrowMut EditExpansionfileUploadCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10461,7 +10611,7 @@ impl<'a, C, A> EditExpansionfileUploadCall<'a, C, A> where C: BorrowMut EditInsertCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10603,7 +10758,7 @@ impl<'a, C, A> EditInsertCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10621,8 +10776,8 @@ impl<'a, C, A> EditInsertCall<'a, C, A> where C: BorrowMut, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AppEdit) -> EditInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AppEdit) -> EditInsertCall<'a, C, A> { + self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". @@ -10834,12 +10989,17 @@ impl<'a, C, A> EditListingListCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10848,7 +11008,7 @@ impl<'a, C, A> EditListingListCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10963,7 +11123,7 @@ impl<'a, C, A> EditListingListCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.edits().testers_patch(&req, "packageName", "editId", "track") +/// let result = hub.edits().testers_patch(req, "packageName", "editId", "track") /// .doit(); /// # } /// ``` @@ -11095,12 +11255,17 @@ impl<'a, C, A> EditTesterPatchCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11109,7 +11274,7 @@ impl<'a, C, A> EditTesterPatchCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11127,8 +11292,8 @@ impl<'a, C, A> EditTesterPatchCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Testers) -> EditTesterPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Testers) -> EditTesterPatchCall<'a, C, A> { + self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". @@ -11359,12 +11524,17 @@ impl<'a, C, A> EditCommitCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11373,7 +11543,7 @@ impl<'a, C, A> EditCommitCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11605,12 +11775,17 @@ impl<'a, C, A> EditTrackListCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11619,7 +11794,7 @@ impl<'a, C, A> EditTrackListCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11851,12 +12026,17 @@ impl<'a, C, A> EditValidateCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11865,7 +12045,7 @@ impl<'a, C, A> EditValidateCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11982,7 +12162,7 @@ impl<'a, C, A> EditValidateCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.edits().listings_update(&req, "packageName", "editId", "language") +/// let result = hub.edits().listings_update(req, "packageName", "editId", "language") /// .doit(); /// # } /// ``` @@ -12114,12 +12294,17 @@ impl<'a, C, A> EditListingUpdateCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12128,7 +12313,7 @@ impl<'a, C, A> EditListingUpdateCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12146,8 +12331,8 @@ impl<'a, C, A> EditListingUpdateCall<'a, C, A> where C: BorrowMut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Listing) -> EditListingUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Listing) -> EditListingUpdateCall<'a, C, A> { + self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". @@ -12383,12 +12568,17 @@ impl<'a, C, A> EditExpansionfileGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12397,7 +12587,7 @@ impl<'a, C, A> EditExpansionfileGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12652,12 +12842,17 @@ impl<'a, C, A> EditImageDeleteallCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12666,7 +12861,7 @@ impl<'a, C, A> EditImageDeleteallCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12802,7 +12997,7 @@ impl<'a, C, A> EditImageDeleteallCall<'a, C, A> where C: BorrowMut EditDetailPatchCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12946,7 +13146,7 @@ impl<'a, C, A> EditDetailPatchCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12964,8 +13164,8 @@ impl<'a, C, A> EditDetailPatchCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AppDetails) -> EditDetailPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AppDetails) -> EditDetailPatchCall<'a, C, A> { + self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". @@ -13072,7 +13272,7 @@ impl<'a, C, A> EditDetailPatchCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.edits().tracks_patch(&req, "packageName", "editId", "track") +/// let result = hub.edits().tracks_patch(req, "packageName", "editId", "track") /// .doit(); /// # } /// ``` @@ -13204,12 +13404,17 @@ impl<'a, C, A> EditTrackPatchCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13218,7 +13423,7 @@ impl<'a, C, A> EditTrackPatchCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13236,8 +13441,8 @@ impl<'a, C, A> EditTrackPatchCall<'a, C, A> where C: BorrowMut, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Track) -> EditTrackPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Track) -> EditTrackPatchCall<'a, C, A> { + self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". @@ -13470,12 +13675,17 @@ impl<'a, C, A> EditListingDeleteCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -13720,12 +13930,17 @@ impl<'a, C, A> EditApklistingGetCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13734,7 +13949,7 @@ impl<'a, C, A> EditApklistingGetCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13869,7 +14084,7 @@ impl<'a, C, A> EditApklistingGetCall<'a, C, A> where C: BorrowMut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.edits().testers_update(&req, "packageName", "editId", "track") +/// let result = hub.edits().testers_update(req, "packageName", "editId", "track") /// .doit(); /// # } /// ``` @@ -14001,12 +14216,17 @@ impl<'a, C, A> EditTesterUpdateCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14015,7 +14235,7 @@ impl<'a, C, A> EditTesterUpdateCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14033,8 +14253,8 @@ impl<'a, C, A> EditTesterUpdateCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Testers) -> EditTesterUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Testers) -> EditTesterUpdateCall<'a, C, A> { + self._request = new_value; self } /// Unique identifier for the Android app that is being updated; for example, "com.spiffygame". @@ -14267,12 +14487,17 @@ impl<'a, C, A> EditApklistingListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14281,7 +14506,7 @@ impl<'a, C, A> EditApklistingListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14406,7 +14631,7 @@ impl<'a, C, A> EditApklistingListCall<'a, C, A> where C: BorrowMut InappproductBatchCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14522,7 +14752,7 @@ impl<'a, C, A> InappproductBatchCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14540,8 +14770,8 @@ impl<'a, C, A> InappproductBatchCall<'a, C, A> where C: BorrowMut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &InappproductsBatchRequest) -> InappproductBatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: InappproductsBatchRequest) -> InappproductBatchCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -14756,12 +14986,17 @@ impl<'a, C, A> InappproductListCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14770,7 +15005,7 @@ impl<'a, C, A> InappproductListCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14895,7 +15130,7 @@ impl<'a, C, A> InappproductListCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.inappproducts().insert(&req, "packageName") +/// let result = hub.inappproducts().insert(req, "packageName") /// .auto_convert_missing_prices(false) /// .doit(); /// # } @@ -15028,12 +15263,17 @@ impl<'a, C, A> InappproductInsertCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15042,7 +15282,7 @@ impl<'a, C, A> InappproductInsertCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15060,8 +15300,8 @@ impl<'a, C, A> InappproductInsertCall<'a, C, A> where C: BorrowMut InappproductInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: InAppProduct) -> InappproductInsertCall<'a, C, A> { + self._request = new_value; self } /// Unique identifier for the Android app; for example, "com.spiffygame". @@ -15279,12 +15519,17 @@ impl<'a, C, A> InappproductDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -15515,12 +15760,17 @@ impl<'a, C, A> InappproductGetCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15529,7 +15779,7 @@ impl<'a, C, A> InappproductGetCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15645,7 +15895,7 @@ impl<'a, C, A> InappproductGetCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.inappproducts().update(&req, "packageName", "sku") +/// let result = hub.inappproducts().update(req, "packageName", "sku") /// .auto_convert_missing_prices(false) /// .doit(); /// # } @@ -15780,12 +16030,17 @@ impl<'a, C, A> InappproductUpdateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15794,7 +16049,7 @@ impl<'a, C, A> InappproductUpdateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15812,8 +16067,8 @@ impl<'a, C, A> InappproductUpdateCall<'a, C, A> where C: BorrowMut InappproductUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: InAppProduct) -> InappproductUpdateCall<'a, C, A> { + self._request = new_value; self } /// Unique identifier for the Android app with the in-app product; for example, "com.spiffygame". @@ -15927,7 +16182,7 @@ impl<'a, C, A> InappproductUpdateCall<'a, C, A> where C: BorrowMut InappproductPatchCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16076,7 +16336,7 @@ impl<'a, C, A> InappproductPatchCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16094,8 +16354,8 @@ impl<'a, C, A> InappproductPatchCall<'a, C, A> where C: BorrowMut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &InAppProduct) -> InappproductPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: InAppProduct) -> InappproductPatchCall<'a, C, A> { + self._request = new_value; self } /// Unique identifier for the Android app with the in-app product; for example, "com.spiffygame". diff --git a/gen/appsactivity1-cli/Cargo.toml b/gen/appsactivity1-cli/Cargo.toml index 40e4f8d2d1..e88c7a6414 100644 --- a/gen/appsactivity1-cli/Cargo.toml +++ b/gen/appsactivity1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-appsactivity1-cli" -version = "0.0.1+20140828" +version = "0.1.0+20140828" authors = ["Sebastian Thiel "] description = "A complete library to interact with appsactivity (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/appsactivity1-cli" diff --git a/gen/appsactivity1-cli/README.md b/gen/appsactivity1-cli/README.md index 73dc6c238e..948ff39447 100644 --- a/gen/appsactivity1-cli/README.md +++ b/gen/appsactivity1-cli/README.md @@ -1,4 +1,102 @@ -# HELLO APPSACTIVITY:V1 + +The `appsactivity1` command-line interface *(CLI)* allows to use most features of the *Google appsactivity* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *appsactivity* API at revision *20140828*. The CLI is at version *0.1.0*. + +```bash + appsactivity1 [options] activities list [-p ...] [-o ] + appsactivity1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_appsactivity1_cli/index.html + +Configuration: + --scope + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `appsactivity1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/appsactivity1-token-.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/appsactivity1-secret.json`, assuming that the required *appsactivity* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `appsactivity1 --debug [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/appsactivity1-cli/mkdocs.yml b/gen/appsactivity1-cli/mkdocs.yml index bb4c5c8a7c..06017bbf9b 100644 --- a/gen/appsactivity1-cli/mkdocs.yml +++ b/gen/appsactivity1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: appsactivity v0.0.1+20140828 +site_name: appsactivity v0.1.0+20140828 site_url: http://byron.github.io/google-apis-rs/google-appsactivity1-cli site_description: Write integrating applications with bcore diff --git a/gen/appsactivity1-cli/src/cmn.rs b/gen/appsactivity1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/appsactivity1-cli/src/cmn.rs +++ b/gen/appsactivity1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/appsactivity1-cli/src/main.rs b/gen/appsactivity1-cli/src/main.rs index 4a4b243924..fef8a91a4e 100644 --- a/gen/appsactivity1-cli/src/main.rs +++ b/gen/appsactivity1-cli/src/main.rs @@ -19,26 +19,27 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - appsactivity1 [options] activities list [-p ]... [-o ] + appsactivity1 [options] activities list [-p ...] [-o ] appsactivity1 --help -All documentation details can be found TODO: +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_appsactivity1_cli/index.html Configuration: --scope - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -108,6 +109,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -201,6 +205,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -208,8 +213,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/appsactivity1/Cargo.toml b/gen/appsactivity1/Cargo.toml index 3d23f8434e..cce9ee4a42 100644 --- a/gen/appsactivity1/Cargo.toml +++ b/gen/appsactivity1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-appsactivity1" -version = "0.1.5+20140828" +version = "0.1.6+20140828" authors = ["Sebastian Thiel "] description = "A complete library to interact with appsactivity (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/appsactivity1" diff --git a/gen/appsactivity1/README.md b/gen/appsactivity1/README.md index fdef1c37f4..9f5bb4477b 100644 --- a/gen/appsactivity1/README.md +++ b/gen/appsactivity1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-appsactivity1` library allows access to all features of the *Google appsactivity* service. -This documentation was generated from *appsactivity* crate version *0.1.5+20140828*, where *20140828* is the exact revision of the *appsactivity:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *appsactivity* crate version *0.1.6+20140828*, where *20140828* is the exact revision of the *appsactivity:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *appsactivity* *v1* API can be found at the [official documentation site](https://developers.google.com/google-apps/activity/). @@ -106,14 +106,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/appsactivity1/src/cmn.rs b/gen/appsactivity1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/appsactivity1/src/cmn.rs +++ b/gen/appsactivity1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option, + location: Option +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option, _: Option) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec]) -> Option { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/appsactivity1/src/lib.rs b/gen/appsactivity1/src/lib.rs index d378793c71..8c824a3425 100644 --- a/gen/appsactivity1/src/lib.rs +++ b/gen/appsactivity1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *appsactivity* crate version *0.1.5+20140828*, where *20140828* is the exact revision of the *appsactivity:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *appsactivity* crate version *0.1.6+20140828*, where *20140828* is the exact revision of the *appsactivity:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *appsactivity* *v1* API can be found at the //! [official documentation site](https://developers.google.com/google-apps/activity/). @@ -107,14 +107,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -202,7 +203,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -295,14 +296,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -323,7 +325,7 @@ impl<'a, C, A> Appsactivity Appsactivity { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -332,7 +334,7 @@ impl<'a, C, A> Appsactivity } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -785,12 +787,17 @@ impl<'a, C, A> ActivityListCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -799,7 +806,7 @@ impl<'a, C, A> ActivityListCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/appstate1-cli/Cargo.toml b/gen/appstate1-cli/Cargo.toml index 0d07d1c0d1..3f470fb69c 100644 --- a/gen/appstate1-cli/Cargo.toml +++ b/gen/appstate1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-appstate1-cli" -version = "0.0.1+20150414" +version = "0.1.0+20150414" authors = ["Sebastian Thiel "] description = "A complete library to interact with App State (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/appstate1-cli" diff --git a/gen/appstate1-cli/README.md b/gen/appstate1-cli/README.md index 7cd835a80d..f25d840104 100644 --- a/gen/appstate1-cli/README.md +++ b/gen/appstate1-cli/README.md @@ -1,4 +1,106 @@ -# HELLO APPSTATE:V1 + +The `appstate1` command-line interface *(CLI)* allows to use most features of the *Google App State* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *App State* API at revision *20150414*. The CLI is at version *0.1.0*. + +```bash + appstate1 [options] states clear [-p ...] [-o ] + appstate1 [options] states delete [-p ...] + appstate1 [options] states get [-p ...] [-o ] + appstate1 [options] states list [-p ...] [-o ] + appstate1 [options] states update -r ... [-p ...] [-o ] + appstate1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_appstate1_cli/index.html + +Configuration: + --scope + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `appstate1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/appstate1-token-.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/appstate1-secret.json`, assuming that the required *appstate* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `appstate1 --debug [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/appstate1-cli/mkdocs.yml b/gen/appstate1-cli/mkdocs.yml index fa05ee0dee..088dd4f66c 100644 --- a/gen/appstate1-cli/mkdocs.yml +++ b/gen/appstate1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: App State v0.0.1+20150414 +site_name: App State v0.1.0+20150414 site_url: http://byron.github.io/google-apis-rs/google-appstate1-cli site_description: Write integrating applications with bcore diff --git a/gen/appstate1-cli/src/cmn.rs b/gen/appstate1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/appstate1-cli/src/cmn.rs +++ b/gen/appstate1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/appstate1-cli/src/main.rs b/gen/appstate1-cli/src/main.rs index 696705a293..c1658245cf 100644 --- a/gen/appstate1-cli/src/main.rs +++ b/gen/appstate1-cli/src/main.rs @@ -19,30 +19,31 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - appstate1 [options] states clear [-p ]... [-o ] - appstate1 [options] states delete [-p ]... - appstate1 [options] states get [-p ]... [-o ] - appstate1 [options] states list [-p ]... [-o ] - appstate1 [options] states update -r ... [-p ]... [-o ] + appstate1 [options] states clear [-p ...] [-o ] + appstate1 [options] states delete [-p ...] + appstate1 [options] states get [-p ...] [-o ] + appstate1 [options] states list [-p ...] [-o ] + appstate1 [options] states update -r ... [-p ...] [-o ] appstate1 --help -All documentation details can be found TODO: +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_appstate1_cli/index.html Configuration: --scope - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -95,6 +96,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -139,6 +143,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -181,6 +188,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -227,6 +237,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -243,9 +256,37 @@ impl Engine { fn _states_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::UpdateRequest::default(); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "data" => { + request.data = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } let state_key: i32 = arg_from_str(&self.opt.arg_state_key, err, "", "integer"); - let mut call = self.hub.states().update(&request, state_key); + let mut call = self.hub.states().update(request, state_key); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -270,30 +311,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "data" => { - request.data = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -395,6 +420,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -402,8 +428,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/appstate1/Cargo.toml b/gen/appstate1/Cargo.toml index e770a879e2..6b9c642847 100644 --- a/gen/appstate1/Cargo.toml +++ b/gen/appstate1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-appstate1" -version = "0.1.5+20150414" +version = "0.1.6+20150414" authors = ["Sebastian Thiel "] description = "A complete library to interact with App State (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/appstate1" diff --git a/gen/appstate1/README.md b/gen/appstate1/README.md index 986c6e6340..a389902cbc 100644 --- a/gen/appstate1/README.md +++ b/gen/appstate1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-appstate1` library allows access to all features of the *Google App State* service. -This documentation was generated from *App State* crate version *0.1.5+20150414*, where *20150414* is the exact revision of the *appstate:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *App State* crate version *0.1.6+20150414*, where *20150414* is the exact revision of the *appstate:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *App State* *v1* API can be found at the [official documentation site](https://developers.google.com/games/services/web/api/states). @@ -99,7 +99,7 @@ let mut req = UpdateRequest::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.states().update(&req, -39) +let result = hub.states().update(req, -39) .current_state_version("sit") .doit(); @@ -107,14 +107,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/appstate1/src/cmn.rs b/gen/appstate1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/appstate1/src/cmn.rs +++ b/gen/appstate1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option, + location: Option +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option, _: Option) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec]) -> Option { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/appstate1/src/lib.rs b/gen/appstate1/src/lib.rs index 365a3ea09d..bbdc90c807 100644 --- a/gen/appstate1/src/lib.rs +++ b/gen/appstate1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *App State* crate version *0.1.5+20150414*, where *20150414* is the exact revision of the *appstate:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *App State* crate version *0.1.6+20150414*, where *20150414* is the exact revision of the *appstate:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *App State* *v1* API can be found at the //! [official documentation site](https://developers.google.com/games/services/web/api/states). @@ -100,7 +100,7 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.states().update(&req, -65) +//! let result = hub.states().update(req, -65) //! .current_state_version("sed") //! .doit(); //! @@ -108,14 +108,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -203,7 +204,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -276,7 +277,7 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.states().update(&req, -85) +/// let result = hub.states().update(req, -85) /// .current_state_version("dolores") /// .doit(); /// @@ -284,14 +285,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -312,7 +314,7 @@ impl<'a, C, A> AppState AppState { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -321,7 +323,7 @@ impl<'a, C, A> AppState } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -545,10 +547,10 @@ impl<'a, C, A> StateMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `stateKey` - The key for the data to be retrieved. - pub fn update(&self, request: &UpdateRequest, state_key: i32) -> StateUpdateCall<'a, C, A> { + pub fn update(&self, request: UpdateRequest, state_key: i32) -> StateUpdateCall<'a, C, A> { StateUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _state_key: state_key, _current_state_version: Default::default(), _delegate: Default::default(), @@ -710,12 +712,17 @@ impl<'a, C, A> StateDeleteCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -934,12 +941,17 @@ impl<'a, C, A> StateGetCall<'a, C, A> where C: BorrowMut, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -948,7 +960,7 @@ impl<'a, C, A> StateGetCall<'a, C, A> where C: BorrowMut, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1173,12 +1185,17 @@ impl<'a, C, A> StateClearCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1187,7 +1204,7 @@ impl<'a, C, A> StateClearCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1393,12 +1410,17 @@ impl<'a, C, A> StateListCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1407,7 +1429,7 @@ impl<'a, C, A> StateListCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1511,7 +1533,7 @@ impl<'a, C, A> StateListCall<'a, C, A> where C: BorrowMut, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.states().update(&req, -81) +/// let result = hub.states().update(req, -81) /// .current_state_version("labore") /// .doit(); /// # } @@ -1644,12 +1666,17 @@ impl<'a, C, A> StateUpdateCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1658,7 +1685,7 @@ impl<'a, C, A> StateUpdateCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1676,8 +1703,8 @@ impl<'a, C, A> StateUpdateCall<'a, C, A> where C: BorrowMut, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &UpdateRequest) -> StateUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: UpdateRequest) -> StateUpdateCall<'a, C, A> { + self._request = new_value; self } /// The key for the data to be retrieved. diff --git a/gen/audit1-cli/Cargo.toml b/gen/audit1-cli/Cargo.toml index 998720b3ca..b183c1ca4b 100644 --- a/gen/audit1-cli/Cargo.toml +++ b/gen/audit1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-audit1-cli" -version = "0.0.1+20150419" +version = "0.1.0+20150419" authors = ["Sebastian Thiel "] description = "A complete library to interact with audit (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/audit1-cli" diff --git a/gen/audit1-cli/README.md b/gen/audit1-cli/README.md index a997937649..acee88c732 100644 --- a/gen/audit1-cli/README.md +++ b/gen/audit1-cli/README.md @@ -1,4 +1,98 @@ -# HELLO AUDIT:V1 + +The `audit1` command-line interface *(CLI)* allows to use most features of the *Google audit* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *audit* API at revision *20150419*. The CLI is at version *0.1.0*. + +```bash + audit1 [options] activities list [-p ...] [-o ] + audit1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_audit1_cli/index.html + +Configuration: + --config-dir + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `audit1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/audit1-token-.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/audit1-secret.json`, assuming that the required *audit* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `audit1 --debug [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/audit1-cli/mkdocs.yml b/gen/audit1-cli/mkdocs.yml index a73833f02c..a222f5f229 100644 --- a/gen/audit1-cli/mkdocs.yml +++ b/gen/audit1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: audit v0.0.1+20150419 +site_name: audit v0.1.0+20150419 site_url: http://byron.github.io/google-apis-rs/google-audit1-cli site_description: Write integrating applications with bcore diff --git a/gen/audit1-cli/src/cmn.rs b/gen/audit1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/audit1-cli/src/cmn.rs +++ b/gen/audit1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/audit1-cli/src/main.rs b/gen/audit1-cli/src/main.rs index 78a205fdf1..eb0492e1dc 100644 --- a/gen/audit1-cli/src/main.rs +++ b/gen/audit1-cli/src/main.rs @@ -19,22 +19,23 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - audit1 [options] activities list [-p ]... [-o ] + audit1 [options] activities list [-p ...] [-o ] audit1 --help -All documentation details can be found TODO: +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_audit1_cli/index.html Configuration: --config-dir - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -203,6 +204,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -210,8 +212,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/audit1/Cargo.toml b/gen/audit1/Cargo.toml index 6565b13823..69ee8e9cc2 100644 --- a/gen/audit1/Cargo.toml +++ b/gen/audit1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-audit1" -version = "0.1.5+20150419" +version = "0.1.6+20150419" authors = ["Sebastian Thiel "] description = "A complete library to interact with audit (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/audit1" diff --git a/gen/audit1/README.md b/gen/audit1/README.md index 70a1b07533..a224e18270 100644 --- a/gen/audit1/README.md +++ b/gen/audit1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-audit1` library allows access to all features of the *Google audit* service. -This documentation was generated from *audit* crate version *0.1.5+20150419*, where *20150419* is the exact revision of the *audit:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *audit* crate version *0.1.6+20150419*, where *20150419* is the exact revision of the *audit:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *audit* *v1* API can be found at the [official documentation site](https://developers.google.com/google-apps/admin-audit/get_started). @@ -108,14 +108,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/audit1/src/cmn.rs b/gen/audit1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/audit1/src/cmn.rs +++ b/gen/audit1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option, + location: Option +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option, _: Option) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec]) -> Option { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/audit1/src/lib.rs b/gen/audit1/src/lib.rs index 05635d541a..a5fb3dad37 100644 --- a/gen/audit1/src/lib.rs +++ b/gen/audit1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *audit* crate version *0.1.5+20150419*, where *20150419* is the exact revision of the *audit:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *audit* crate version *0.1.6+20150419*, where *20150419* is the exact revision of the *audit:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *audit* *v1* API can be found at the //! [official documentation site](https://developers.google.com/google-apps/admin-audit/get_started). @@ -109,14 +109,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -204,7 +205,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -265,14 +266,15 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -293,7 +295,7 @@ impl<'a, C, A> Audit Audit { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -302,7 +304,7 @@ impl<'a, C, A> Audit } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -707,12 +709,17 @@ impl<'a, C, A> ActivityListCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -721,7 +728,7 @@ impl<'a, C, A> ActivityListCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/autoscaler1_beta2-cli/Cargo.toml b/gen/autoscaler1_beta2-cli/Cargo.toml index ba64f6bf26..ddf15d69bb 100644 --- a/gen/autoscaler1_beta2-cli/Cargo.toml +++ b/gen/autoscaler1_beta2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-autoscaler1_beta2-cli" -version = "0.0.1+20141112" +version = "0.1.0+20141112" authors = ["Sebastian Thiel "] description = "A complete library to interact with autoscaler (protocol v1beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/autoscaler1_beta2-cli" diff --git a/gen/autoscaler1_beta2-cli/README.md b/gen/autoscaler1_beta2-cli/README.md index 61f8889ddd..a0bc87fbba 100644 --- a/gen/autoscaler1_beta2-cli/README.md +++ b/gen/autoscaler1_beta2-cli/README.md @@ -1,4 +1,111 @@ -# HELLO AUTOSCALER:V1BETA2 + +The `autoscaler1-beta2` command-line interface *(CLI)* allows to use most features of the *Google autoscaler* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *autoscaler* API at revision *20141112*. The CLI is at version *0.1.0*. + +```bash + autoscaler1-beta2 [options] autoscalers delete [-p ...] [-o ] + autoscaler1-beta2 [options] autoscalers get [-p ...] [-o ] + autoscaler1-beta2 [options] autoscalers insert -r ... [-p ...] [-o ] + autoscaler1-beta2 [options] autoscalers list [-p ...] [-o ] + autoscaler1-beta2 [options] autoscalers patch -r ... [-p ...] [-o ] + autoscaler1-beta2 [options] autoscalers update -r ... [-p ...] [-o ] + autoscaler1-beta2 [options] zone-operations delete [-p ...] + autoscaler1-beta2 [options] zone-operations get [-p ...] [-o ] + autoscaler1-beta2 [options] zone-operations list [-p ...] [-o ] + autoscaler1-beta2 [options] zones list [-p ...] [-o ] + autoscaler1-beta2 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_autoscaler1_beta2_cli/index.html + +Configuration: + --scope + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `autoscaler1-beta2-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/autoscaler1-beta2-token-.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/autoscaler1-beta2-secret.json`, assuming that the required *autoscaler* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `autoscaler1-beta2 --debug [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/autoscaler1_beta2-cli/mkdocs.yml b/gen/autoscaler1_beta2-cli/mkdocs.yml index 23b13f56b6..052476cb1d 100644 --- a/gen/autoscaler1_beta2-cli/mkdocs.yml +++ b/gen/autoscaler1_beta2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: autoscaler v0.0.1+20141112 +site_name: autoscaler v0.1.0+20141112 site_url: http://byron.github.io/google-apis-rs/google-autoscaler1_beta2-cli site_description: Write integrating applications with bcore diff --git a/gen/autoscaler1_beta2-cli/src/cmn.rs b/gen/autoscaler1_beta2-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/autoscaler1_beta2-cli/src/cmn.rs +++ b/gen/autoscaler1_beta2-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/autoscaler1_beta2-cli/src/main.rs b/gen/autoscaler1_beta2-cli/src/main.rs index 2fc9d24cdd..ac3e758196 100644 --- a/gen/autoscaler1_beta2-cli/src/main.rs +++ b/gen/autoscaler1_beta2-cli/src/main.rs @@ -19,35 +19,36 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - autoscaler1-beta2 [options] autoscalers delete [-p ]... [-o ] - autoscaler1-beta2 [options] autoscalers get [-p ]... [-o ] - autoscaler1-beta2 [options] autoscalers insert -r ... [-p ]... [-o ] - autoscaler1-beta2 [options] autoscalers list [-p ]... [-o ] - autoscaler1-beta2 [options] autoscalers patch -r ... [-p ]... [-o ] - autoscaler1-beta2 [options] autoscalers update -r ... [-p ]... [-o ] - autoscaler1-beta2 [options] zone-operations delete [-p ]... - autoscaler1-beta2 [options] zone-operations get [-p ]... [-o ] - autoscaler1-beta2 [options] zone-operations list [-p ]... [-o ] - autoscaler1-beta2 [options] zones list [-p ]... [-o ] + autoscaler1-beta2 [options] autoscalers delete [-p ...] [-o ] + autoscaler1-beta2 [options] autoscalers get [-p ...] [-o ] + autoscaler1-beta2 [options] autoscalers insert -r ... [-p ...] [-o ] + autoscaler1-beta2 [options] autoscalers list [-p ...] [-o ] + autoscaler1-beta2 [options] autoscalers patch -r ... [-p ...] [-o ] + autoscaler1-beta2 [options] autoscalers update -r ... [-p ...] [-o ] + autoscaler1-beta2 [options] zone-operations delete [-p ...] + autoscaler1-beta2 [options] zone-operations get [-p ...] [-o ] + autoscaler1-beta2 [options] zone-operations list [-p ...] [-o ] + autoscaler1-beta2 [options] zones list [-p ...] [-o ] autoscaler1-beta2 --help -All documentation details can be found TODO: +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_autoscaler1_beta2_cli/index.html Configuration: --scope - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -96,6 +97,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -139,6 +143,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -155,36 +162,23 @@ impl Engine { fn _autoscalers_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Autoscaler::default(); - let mut call = self.hub.autoscalers().insert(&request, &self.opt.arg_project, &self.opt.arg_zone); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Autoscaler::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_autoscaling_policy_cpu_utilization_init(request: &mut api::Autoscaler) { request_autoscaling_policy_init(request); if request.autoscaling_policy.as_mut().unwrap().cpu_utilization.is_none() { @@ -205,7 +199,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -253,15 +247,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.autoscalers().insert(request, &self.opt.arg_project, &self.opt.arg_zone); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -314,6 +333,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -330,36 +352,23 @@ impl Engine { fn _autoscalers_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Autoscaler::default(); - let mut call = self.hub.autoscalers().patch(&request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_autoscaler); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Autoscaler::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_autoscaling_policy_cpu_utilization_init(request: &mut api::Autoscaler) { request_autoscaling_policy_init(request); if request.autoscaling_policy.as_mut().unwrap().cpu_utilization.is_none() { @@ -380,7 +389,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -428,15 +437,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.autoscalers().patch(request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_autoscaler); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -453,36 +487,23 @@ impl Engine { fn _autoscalers_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Autoscaler::default(); - let mut call = self.hub.autoscalers().update(&request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_autoscaler); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Autoscaler::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_autoscaling_policy_cpu_utilization_init(request: &mut api::Autoscaler) { request_autoscaling_policy_init(request); if request.autoscaling_policy.as_mut().unwrap().cpu_utilization.is_none() { @@ -503,7 +524,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -551,15 +572,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.autoscalers().update(request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_autoscaler); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -603,6 +649,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -644,6 +693,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -696,6 +748,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -748,6 +803,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -869,6 +927,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -876,8 +935,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/autoscaler1_beta2/Cargo.toml b/gen/autoscaler1_beta2/Cargo.toml index 77b103c9f2..3cccdda204 100644 --- a/gen/autoscaler1_beta2/Cargo.toml +++ b/gen/autoscaler1_beta2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-autoscaler1_beta2" -version = "0.1.5+20141112" +version = "0.1.6+20141112" authors = ["Sebastian Thiel "] description = "A complete library to interact with autoscaler (protocol v1beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/autoscaler1_beta2" diff --git a/gen/autoscaler1_beta2/README.md b/gen/autoscaler1_beta2/README.md index 801fb54962..2cc7abe754 100644 --- a/gen/autoscaler1_beta2/README.md +++ b/gen/autoscaler1_beta2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-autoscaler1_beta2` library allows access to all features of the *Google autoscaler* service. -This documentation was generated from *autoscaler* crate version *0.1.5+20141112*, where *20141112* is the exact revision of the *autoscaler:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *autoscaler* crate version *0.1.6+20141112*, where *20141112* is the exact revision of the *autoscaler:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *autoscaler* *v1_beta2* API can be found at the [official documentation site](http://developers.google.com/compute/docs/autoscaler). @@ -111,14 +111,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/autoscaler1_beta2/src/cmn.rs b/gen/autoscaler1_beta2/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/autoscaler1_beta2/src/cmn.rs +++ b/gen/autoscaler1_beta2/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option, + location: Option +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option, _: Option) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec]) -> Option { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/autoscaler1_beta2/src/lib.rs b/gen/autoscaler1_beta2/src/lib.rs index b7240cc3c1..e4cc981c83 100644 --- a/gen/autoscaler1_beta2/src/lib.rs +++ b/gen/autoscaler1_beta2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *autoscaler* crate version *0.1.5+20141112*, where *20141112* is the exact revision of the *autoscaler:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *autoscaler* crate version *0.1.6+20141112*, where *20141112* is the exact revision of the *autoscaler:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *autoscaler* *v1_beta2* API can be found at the //! [official documentation site](http://developers.google.com/compute/docs/autoscaler). @@ -112,14 +112,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -207,7 +208,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -288,14 +289,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -316,7 +318,7 @@ impl<'a, C, A> AutoscalerHub AutoscalerHub { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -331,7 +333,7 @@ impl<'a, C, A> AutoscalerHub } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -1007,10 +1009,10 @@ impl<'a, C, A> AutoscalerMethods<'a, C, A> { /// * `project` - Project ID of Autoscaler resource. /// * `zone` - Zone name of Autoscaler resource. /// * `autoscaler` - Name of the Autoscaler resource. - pub fn update(&self, request: &Autoscaler, project: &str, zone: &str, autoscaler: &str) -> AutoscalerUpdateCall<'a, C, A> { + pub fn update(&self, request: Autoscaler, project: &str, zone: &str, autoscaler: &str) -> AutoscalerUpdateCall<'a, C, A> { AutoscalerUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _zone: zone.to_string(), _autoscaler: autoscaler.to_string(), @@ -1030,10 +1032,10 @@ impl<'a, C, A> AutoscalerMethods<'a, C, A> { /// * `project` - Project ID of Autoscaler resource. /// * `zone` - Zone name of Autoscaler resource. /// * `autoscaler` - Name of the Autoscaler resource. - pub fn patch(&self, request: &Autoscaler, project: &str, zone: &str, autoscaler: &str) -> AutoscalerPatchCall<'a, C, A> { + pub fn patch(&self, request: Autoscaler, project: &str, zone: &str, autoscaler: &str) -> AutoscalerPatchCall<'a, C, A> { AutoscalerPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _zone: zone.to_string(), _autoscaler: autoscaler.to_string(), @@ -1073,10 +1075,10 @@ impl<'a, C, A> AutoscalerMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Project ID of Autoscaler resource. /// * `zone` - Zone name of Autoscaler resource. - pub fn insert(&self, request: &Autoscaler, project: &str, zone: &str) -> AutoscalerInsertCall<'a, C, A> { + pub fn insert(&self, request: Autoscaler, project: &str, zone: &str) -> AutoscalerInsertCall<'a, C, A> { AutoscalerInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _zone: zone.to_string(), _delegate: Default::default(), @@ -1275,12 +1277,17 @@ impl<'a, C, A> ZoneListCall<'a, C, A> where C: BorrowMut, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1289,7 +1296,7 @@ impl<'a, C, A> ZoneListCall<'a, C, A> where C: BorrowMut, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1543,12 +1550,17 @@ impl<'a, C, A> ZoneOperationListCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1557,7 +1569,7 @@ impl<'a, C, A> ZoneOperationListCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1806,12 +1818,17 @@ impl<'a, C, A> ZoneOperationDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -2051,12 +2068,17 @@ impl<'a, C, A> ZoneOperationGetCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2065,7 +2087,7 @@ impl<'a, C, A> ZoneOperationGetCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2319,12 +2341,17 @@ impl<'a, C, A> AutoscalerListCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2333,7 +2360,7 @@ impl<'a, C, A> AutoscalerListCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2468,7 +2495,7 @@ impl<'a, C, A> AutoscalerListCall<'a, C, A> where C: BorrowMut, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.autoscalers().update(&req, "project", "zone", "autoscaler") +/// let result = hub.autoscalers().update(req, "project", "zone", "autoscaler") /// .doit(); /// # } /// ``` @@ -2600,12 +2627,17 @@ impl<'a, C, A> AutoscalerUpdateCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2614,7 +2646,7 @@ impl<'a, C, A> AutoscalerUpdateCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2632,8 +2664,8 @@ impl<'a, C, A> AutoscalerUpdateCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Autoscaler) -> AutoscalerUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Autoscaler) -> AutoscalerUpdateCall<'a, C, A> { + self._request = new_value; self } /// Project ID of Autoscaler resource. @@ -2750,7 +2782,7 @@ impl<'a, C, A> AutoscalerUpdateCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.autoscalers().patch(&req, "project", "zone", "autoscaler") +/// let result = hub.autoscalers().patch(req, "project", "zone", "autoscaler") /// .doit(); /// # } /// ``` @@ -2882,12 +2914,17 @@ impl<'a, C, A> AutoscalerPatchCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2896,7 +2933,7 @@ impl<'a, C, A> AutoscalerPatchCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2914,8 +2951,8 @@ impl<'a, C, A> AutoscalerPatchCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Autoscaler) -> AutoscalerPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Autoscaler) -> AutoscalerPatchCall<'a, C, A> { + self._request = new_value; self } /// Project ID of Autoscaler resource. @@ -3149,12 +3186,17 @@ impl<'a, C, A> AutoscalerDeleteCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3163,7 +3205,7 @@ impl<'a, C, A> AutoscalerDeleteCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3290,7 +3332,7 @@ impl<'a, C, A> AutoscalerDeleteCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.autoscalers().insert(&req, "project", "zone") +/// let result = hub.autoscalers().insert(req, "project", "zone") /// .doit(); /// # } /// ``` @@ -3420,12 +3462,17 @@ impl<'a, C, A> AutoscalerInsertCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3434,7 +3481,7 @@ impl<'a, C, A> AutoscalerInsertCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3452,8 +3499,8 @@ impl<'a, C, A> AutoscalerInsertCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Autoscaler) -> AutoscalerInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Autoscaler) -> AutoscalerInsertCall<'a, C, A> { + self._request = new_value; self } /// Project ID of Autoscaler resource. @@ -3677,12 +3724,17 @@ impl<'a, C, A> AutoscalerGetCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3691,7 +3743,7 @@ impl<'a, C, A> AutoscalerGetCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/bigquery2-cli/Cargo.toml b/gen/bigquery2-cli/Cargo.toml index 81e0ab5750..c54405421a 100644 --- a/gen/bigquery2-cli/Cargo.toml +++ b/gen/bigquery2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-bigquery2-cli" -version = "0.0.1+20150326" +version = "0.1.0+20150326" authors = ["Sebastian Thiel "] description = "A complete library to interact with bigquery (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/bigquery2-cli" diff --git a/gen/bigquery2-cli/README.md b/gen/bigquery2-cli/README.md index 7e74087139..7be0ecb22e 100644 --- a/gen/bigquery2-cli/README.md +++ b/gen/bigquery2-cli/README.md @@ -1,4 +1,121 @@ -# HELLO BIGQUERY:V2 + +The `bigquery2` command-line interface *(CLI)* allows to use most features of the *Google bigquery* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *bigquery* API at revision *20150326*. The CLI is at version *0.1.0*. + +```bash + bigquery2 [options] datasets delete [-p ...] + bigquery2 [options] datasets get [-p ...] [-o ] + bigquery2 [options] datasets insert -r ... [-p ...] [-o ] + bigquery2 [options] datasets list [-p ...] [-o ] + bigquery2 [options] datasets patch -r ... [-p ...] [-o ] + bigquery2 [options] datasets update -r ... [-p ...] [-o ] + bigquery2 [options] jobs get [-p ...] [-o ] + bigquery2 [options] jobs get-query-results [-p ...] [-o ] + bigquery2 [options] jobs insert -r ... -u (simple|resumable) [-p ...] [-o ] + bigquery2 [options] jobs list [-p ...] [-o ] + bigquery2 [options] jobs query -r ... [-p ...] [-o ] + bigquery2 [options] projects list [-p ...] [-o ] + bigquery2 [options] tabledata insert-all -r ... [-p ...] [-o ] + bigquery2 [options] tabledata list [-p ...] [-o ] + bigquery2 [options] tables delete [-p ...] + bigquery2 [options] tables get [-p ...] [-o ] + bigquery2 [options] tables insert -r ... [-p ...] [-o ] + bigquery2 [options] tables list [-p ...] [-o ] + bigquery2 [options] tables patch -r ... [-p ...] [-o ] + bigquery2 [options] tables update -r ... [-p ...] [-o ] + bigquery2 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_bigquery2_cli/index.html + +Configuration: + --scope + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `bigquery2-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/bigquery2-token-.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/bigquery2-secret.json`, assuming that the required *bigquery* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `bigquery2 --debug [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/bigquery2-cli/mkdocs.yml b/gen/bigquery2-cli/mkdocs.yml index 3ddf30c613..903cbb5d7e 100644 --- a/gen/bigquery2-cli/mkdocs.yml +++ b/gen/bigquery2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: bigquery v0.0.1+20150326 +site_name: bigquery v0.1.0+20150326 site_url: http://byron.github.io/google-apis-rs/google-bigquery2-cli site_description: Write integrating applications with bcore diff --git a/gen/bigquery2-cli/src/cmn.rs b/gen/bigquery2-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/bigquery2-cli/src/cmn.rs +++ b/gen/bigquery2-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/bigquery2-cli/src/main.rs b/gen/bigquery2-cli/src/main.rs index 1c2eae0564..9c61640b3b 100644 --- a/gen/bigquery2-cli/src/main.rs +++ b/gen/bigquery2-cli/src/main.rs @@ -19,45 +19,46 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - bigquery2 [options] datasets delete [-p ]... - bigquery2 [options] datasets get [-p ]... [-o ] - bigquery2 [options] datasets insert -r ... [-p ]... [-o ] - bigquery2 [options] datasets list [-p ]... [-o ] - bigquery2 [options] datasets patch -r ... [-p ]... [-o ] - bigquery2 [options] datasets update -r ... [-p ]... [-o ] - bigquery2 [options] jobs get [-p ]... [-o ] - bigquery2 [options] jobs get-query-results [-p ]... [-o ] - bigquery2 [options] jobs insert -r ... -u (simple|resumable) [-p ]... [-o ] - bigquery2 [options] jobs list [-p ]... [-o ] - bigquery2 [options] jobs query -r ... [-p ]... [-o ] - bigquery2 [options] projects list [-p ]... [-o ] - bigquery2 [options] tabledata insert-all -r ... [-p ]... [-o ] - bigquery2 [options] tabledata list [-p ]... [-o ] - bigquery2 [options] tables delete [-p ]... - bigquery2 [options] tables get [-p ]... [-o ] - bigquery2 [options] tables insert -r ... [-p ]... [-o ] - bigquery2 [options] tables list [-p ]... [-o ] - bigquery2 [options] tables patch -r ... [-p ]... [-o ] - bigquery2 [options] tables update -r ... [-p ]... [-o ] + bigquery2 [options] datasets delete [-p ...] + bigquery2 [options] datasets get [-p ...] [-o ] + bigquery2 [options] datasets insert -r ... [-p ...] [-o ] + bigquery2 [options] datasets list [-p ...] [-o ] + bigquery2 [options] datasets patch -r ... [-p ...] [-o ] + bigquery2 [options] datasets update -r ... [-p ...] [-o ] + bigquery2 [options] jobs get [-p ...] [-o ] + bigquery2 [options] jobs get-query-results [-p ...] [-o ] + bigquery2 [options] jobs insert -r ... -u (simple|resumable) [-p ...] [-o ] + bigquery2 [options] jobs list [-p ...] [-o ] + bigquery2 [options] jobs query -r ... [-p ...] [-o ] + bigquery2 [options] projects list [-p ...] [-o ] + bigquery2 [options] tabledata insert-all -r ... [-p ...] [-o ] + bigquery2 [options] tabledata list [-p ...] [-o ] + bigquery2 [options] tables delete [-p ...] + bigquery2 [options] tables get [-p ...] [-o ] + bigquery2 [options] tables insert -r ... [-p ...] [-o ] + bigquery2 [options] tables list [-p ...] [-o ] + bigquery2 [options] tables patch -r ... [-p ...] [-o ] + bigquery2 [options] tables update -r ... [-p ...] [-o ] bigquery2 --help -All documentation details can be found TODO: +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_bigquery2_cli/index.html Configuration: --scope - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -109,6 +110,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -150,6 +154,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -166,43 +173,30 @@ impl Engine { fn _datasets_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Dataset::default(); - let mut call = self.hub.datasets().insert(&request, &self.opt.arg_project_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Dataset::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_dataset_reference_init(request: &mut api::Dataset) { if request.dataset_reference.is_none() { request.dataset_reference = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -246,15 +240,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.datasets().insert(request, &self.opt.arg_project_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -307,6 +326,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -323,43 +345,30 @@ impl Engine { fn _datasets_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Dataset::default(); - let mut call = self.hub.datasets().patch(&request, &self.opt.arg_project_id, &self.opt.arg_dataset_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Dataset::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_dataset_reference_init(request: &mut api::Dataset) { if request.dataset_reference.is_none() { request.dataset_reference = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -403,15 +412,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.datasets().patch(request, &self.opt.arg_project_id, &self.opt.arg_dataset_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -428,43 +462,30 @@ impl Engine { fn _datasets_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Dataset::default(); - let mut call = self.hub.datasets().update(&request, &self.opt.arg_project_id, &self.opt.arg_dataset_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Dataset::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_dataset_reference_init(request: &mut api::Dataset) { if request.dataset_reference.is_none() { request.dataset_reference = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -508,15 +529,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.datasets().update(request, &self.opt.arg_project_id, &self.opt.arg_dataset_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -560,6 +606,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -615,6 +664,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -631,36 +683,23 @@ impl Engine { fn _jobs_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Job::default(); - let mut call = self.hub.jobs().insert(&request, &self.opt.arg_project_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Job::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_configuration_copy_destination_table_init(request: &mut api::Job) { request_configuration_copy_init(request); if request.configuration.as_mut().unwrap().copy.as_mut().unwrap().destination_table.is_none() { @@ -797,7 +836,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status.state" => { request_status_init(&mut request); request.status.as_mut().unwrap().state = Some(value.unwrap_or("").to_string()); @@ -1126,10 +1165,32 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.jobs().insert(request, &self.opt.arg_project_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = if self.opt.cmd_simple { "simple" @@ -1144,6 +1205,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -1203,6 +1267,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1219,43 +1286,30 @@ impl Engine { fn _jobs_query(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::QueryRequest::default(); - let mut call = self.hub.jobs().query(&request, &self.opt.arg_project_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::QueryRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_default_dataset_init(request: &mut api::QueryRequest) { if request.default_dataset.is_none() { request.default_dataset = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "timeout-ms" => { request.timeout_ms = Some(arg_from_str(value.unwrap_or("-0"), err, "timeout-ms", "integer")); }, @@ -1289,15 +1343,40 @@ impl Engine { request.preserve_nulls = Some(arg_from_str(value.unwrap_or("false"), err, "preserve-nulls", "boolean")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.jobs().query(request, &self.opt.arg_project_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1347,6 +1426,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1363,8 +1445,39 @@ impl Engine { fn _tabledata_insert_all(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::TableDataInsertAllRequest::default(); - let mut call = self.hub.tabledata().insert_all(&request, &self.opt.arg_project_id, &self.opt.arg_dataset_id, &self.opt.arg_table_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "ignore-unknown-values" => { + request.ignore_unknown_values = Some(arg_from_str(value.unwrap_or("false"), err, "ignore-unknown-values", "boolean")); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "skip-invalid-rows" => { + request.skip_invalid_rows = Some(arg_from_str(value.unwrap_or("false"), err, "skip-invalid-rows", "boolean")); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.tabledata().insert_all(request, &self.opt.arg_project_id, &self.opt.arg_dataset_id, &self.opt.arg_table_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1386,33 +1499,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "ignore-unknown-values" => { - request.ignore_unknown_values = Some(arg_from_str(value.unwrap_or("false"), err, "ignore-unknown-values", "boolean")); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "skip-invalid-rows" => { - request.skip_invalid_rows = Some(arg_from_str(value.unwrap_or("false"), err, "skip-invalid-rows", "boolean")); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1465,6 +1559,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1508,6 +1605,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1549,6 +1649,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1565,36 +1668,23 @@ impl Engine { fn _tables_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Table::default(); - let mut call = self.hub.tables().insert(&request, &self.opt.arg_project_id, &self.opt.arg_dataset_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Table::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_table_reference_init(request: &mut api::Table) { if request.table_reference.is_none() { request.table_reference = Some(Default::default()); @@ -1607,7 +1697,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1669,15 +1759,40 @@ impl Engine { request.view.as_mut().unwrap().query = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.tables().insert(request, &self.opt.arg_project_id, &self.opt.arg_dataset_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1727,6 +1842,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1743,36 +1861,23 @@ impl Engine { fn _tables_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Table::default(); - let mut call = self.hub.tables().patch(&request, &self.opt.arg_project_id, &self.opt.arg_dataset_id, &self.opt.arg_table_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Table::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_table_reference_init(request: &mut api::Table) { if request.table_reference.is_none() { request.table_reference = Some(Default::default()); @@ -1785,7 +1890,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1847,15 +1952,40 @@ impl Engine { request.view.as_mut().unwrap().query = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.tables().patch(request, &self.opt.arg_project_id, &self.opt.arg_dataset_id, &self.opt.arg_table_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1872,36 +2002,23 @@ impl Engine { fn _tables_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Table::default(); - let mut call = self.hub.tables().update(&request, &self.opt.arg_project_id, &self.opt.arg_dataset_id, &self.opt.arg_table_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Table::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_table_reference_init(request: &mut api::Table) { if request.table_reference.is_none() { request.table_reference = Some(Default::default()); @@ -1914,7 +2031,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1976,15 +2093,40 @@ impl Engine { request.view.as_mut().unwrap().query = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.tables().update(request, &self.opt.arg_project_id, &self.opt.arg_dataset_id, &self.opt.arg_table_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2136,6 +2278,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -2143,8 +2286,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/bigquery2/Cargo.toml b/gen/bigquery2/Cargo.toml index 5cb8d8c3c1..47dfaa67f5 100644 --- a/gen/bigquery2/Cargo.toml +++ b/gen/bigquery2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-bigquery2" -version = "0.1.5+20150326" +version = "0.1.6+20150326" authors = ["Sebastian Thiel "] description = "A complete library to interact with bigquery (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/bigquery2" diff --git a/gen/bigquery2/README.md b/gen/bigquery2/README.md index 1be8736c57..9a5bc90de9 100644 --- a/gen/bigquery2/README.md +++ b/gen/bigquery2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-bigquery2` library allows access to all features of the *Google bigquery* service. -This documentation was generated from *bigquery* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *bigquery:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *bigquery* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *bigquery:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *bigquery* *v2* API can be found at the [official documentation site](https://cloud.google.com/bigquery/). @@ -115,21 +115,22 @@ let mut req = Table::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.tables().update(&req, "projectId", "datasetId", "tableId") +let result = hub.tables().update(req, "projectId", "datasetId", "tableId") .doit(); match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/bigquery2/src/cmn.rs b/gen/bigquery2/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/bigquery2/src/cmn.rs +++ b/gen/bigquery2/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option, + location: Option +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option, _: Option) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec]) -> Option { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/bigquery2/src/lib.rs b/gen/bigquery2/src/lib.rs index 70234dea8e..9f827bf631 100644 --- a/gen/bigquery2/src/lib.rs +++ b/gen/bigquery2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *bigquery* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *bigquery:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *bigquery* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *bigquery:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *bigquery* *v2* API can be found at the //! [official documentation site](https://cloud.google.com/bigquery/). @@ -116,21 +116,22 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.tables().update(&req, "projectId", "datasetId", "tableId") +//! let result = hub.tables().update(req, "projectId", "datasetId", "tableId") //! .doit(); //! //! match result { //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -218,7 +219,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -311,21 +312,22 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.tables().update(&req, "projectId", "datasetId", "tableId") +/// let result = hub.tables().update(req, "projectId", "datasetId", "tableId") /// .doit(); /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -346,7 +348,7 @@ impl<'a, C, A> Bigquery Bigquery { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -367,7 +369,7 @@ impl<'a, C, A> Bigquery } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -1610,10 +1612,10 @@ impl<'a, C, A> TableMethods<'a, C, A> { /// * `projectId` - Project ID of the table to update /// * `datasetId` - Dataset ID of the table to update /// * `tableId` - Table ID of the table to update - pub fn update(&self, request: &Table, project_id: &str, dataset_id: &str, table_id: &str) -> TableUpdateCall<'a, C, A> { + pub fn update(&self, request: Table, project_id: &str, dataset_id: &str, table_id: &str) -> TableUpdateCall<'a, C, A> { TableUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _project_id: project_id.to_string(), _dataset_id: dataset_id.to_string(), _table_id: table_id.to_string(), @@ -1632,10 +1634,10 @@ impl<'a, C, A> TableMethods<'a, C, A> { /// * `request` - No description provided. /// * `projectId` - Project ID of the new table /// * `datasetId` - Dataset ID of the new table - pub fn insert(&self, request: &Table, project_id: &str, dataset_id: &str) -> TableInsertCall<'a, C, A> { + pub fn insert(&self, request: Table, project_id: &str, dataset_id: &str) -> TableInsertCall<'a, C, A> { TableInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project_id: project_id.to_string(), _dataset_id: dataset_id.to_string(), _delegate: Default::default(), @@ -1717,10 +1719,10 @@ impl<'a, C, A> TableMethods<'a, C, A> { /// * `projectId` - Project ID of the table to update /// * `datasetId` - Dataset ID of the table to update /// * `tableId` - Table ID of the table to update - pub fn patch(&self, request: &Table, project_id: &str, dataset_id: &str, table_id: &str) -> TablePatchCall<'a, C, A> { + pub fn patch(&self, request: Table, project_id: &str, dataset_id: &str, table_id: &str) -> TablePatchCall<'a, C, A> { TablePatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _project_id: project_id.to_string(), _dataset_id: dataset_id.to_string(), _table_id: table_id.to_string(), @@ -1780,10 +1782,10 @@ impl<'a, C, A> DatasetMethods<'a, C, A> { /// * `request` - No description provided. /// * `projectId` - Project ID of the dataset being updated /// * `datasetId` - Dataset ID of the dataset being updated - pub fn patch(&self, request: &Dataset, project_id: &str, dataset_id: &str) -> DatasetPatchCall<'a, C, A> { + pub fn patch(&self, request: Dataset, project_id: &str, dataset_id: &str) -> DatasetPatchCall<'a, C, A> { DatasetPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _project_id: project_id.to_string(), _dataset_id: dataset_id.to_string(), _delegate: Default::default(), @@ -1840,10 +1842,10 @@ impl<'a, C, A> DatasetMethods<'a, C, A> { /// * `request` - No description provided. /// * `projectId` - Project ID of the dataset being updated /// * `datasetId` - Dataset ID of the dataset being updated - pub fn update(&self, request: &Dataset, project_id: &str, dataset_id: &str) -> DatasetUpdateCall<'a, C, A> { + pub fn update(&self, request: Dataset, project_id: &str, dataset_id: &str) -> DatasetUpdateCall<'a, C, A> { DatasetUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _project_id: project_id.to_string(), _dataset_id: dataset_id.to_string(), _delegate: Default::default(), @@ -1880,10 +1882,10 @@ impl<'a, C, A> DatasetMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `projectId` - Project ID of the new dataset - pub fn insert(&self, request: &Dataset, project_id: &str) -> DatasetInsertCall<'a, C, A> { + pub fn insert(&self, request: Dataset, project_id: &str) -> DatasetInsertCall<'a, C, A> { DatasetInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project_id: project_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1940,10 +1942,10 @@ impl<'a, C, A> JobMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `projectId` - Project ID of the project billed for the query - pub fn query(&self, request: &QueryRequest, project_id: &str) -> JobQueryCall<'a, C, A> { + pub fn query(&self, request: QueryRequest, project_id: &str) -> JobQueryCall<'a, C, A> { JobQueryCall { hub: self.hub, - _request: request.clone(), + _request: request, _project_id: project_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2023,10 +2025,10 @@ impl<'a, C, A> JobMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `projectId` - Project ID of the project that will be billed for the job - pub fn insert(&self, request: &Job, project_id: &str) -> JobInsertCall<'a, C, A> { + pub fn insert(&self, request: Job, project_id: &str) -> JobInsertCall<'a, C, A> { JobInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project_id: project_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2085,10 +2087,10 @@ impl<'a, C, A> TabledataMethods<'a, C, A> { /// * `projectId` - Project ID of the destination table. /// * `datasetId` - Dataset ID of the destination table. /// * `tableId` - Table ID of the destination table. - pub fn insert_all(&self, request: &TableDataInsertAllRequest, project_id: &str, dataset_id: &str, table_id: &str) -> TabledataInsertAllCall<'a, C, A> { + pub fn insert_all(&self, request: TableDataInsertAllRequest, project_id: &str, dataset_id: &str, table_id: &str) -> TabledataInsertAllCall<'a, C, A> { TabledataInsertAllCall { hub: self.hub, - _request: request.clone(), + _request: request, _project_id: project_id.to_string(), _dataset_id: dataset_id.to_string(), _table_id: table_id.to_string(), @@ -2218,7 +2220,7 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.tables().update(&req, "projectId", "datasetId", "tableId") +/// let result = hub.tables().update(req, "projectId", "datasetId", "tableId") /// .doit(); /// # } /// ``` @@ -2350,12 +2352,17 @@ impl<'a, C, A> TableUpdateCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2364,7 +2371,7 @@ impl<'a, C, A> TableUpdateCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2382,8 +2389,8 @@ impl<'a, C, A> TableUpdateCall<'a, C, A> where C: BorrowMut, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Table) -> TableUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Table) -> TableUpdateCall<'a, C, A> { + self._request = new_value; self } /// Project ID of the table to update @@ -2500,7 +2507,7 @@ impl<'a, C, A> TableUpdateCall<'a, C, A> where C: BorrowMut, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.tables().insert(&req, "projectId", "datasetId") +/// let result = hub.tables().insert(req, "projectId", "datasetId") /// .doit(); /// # } /// ``` @@ -2630,12 +2637,17 @@ impl<'a, C, A> TableInsertCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2644,7 +2656,7 @@ impl<'a, C, A> TableInsertCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2662,8 +2674,8 @@ impl<'a, C, A> TableInsertCall<'a, C, A> where C: BorrowMut, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Table) -> TableInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Table) -> TableInsertCall<'a, C, A> { + self._request = new_value; self } /// Project ID of the new table @@ -2895,12 +2907,17 @@ impl<'a, C, A> TableListCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2909,7 +2926,7 @@ impl<'a, C, A> TableListCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3156,12 +3173,17 @@ impl<'a, C, A> TableDeleteCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -3404,12 +3426,17 @@ impl<'a, C, A> TableGetCall<'a, C, A> where C: BorrowMut, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3418,7 +3445,7 @@ impl<'a, C, A> TableGetCall<'a, C, A> where C: BorrowMut, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3545,7 +3572,7 @@ impl<'a, C, A> TableGetCall<'a, C, A> where C: BorrowMut, A: oaut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.tables().patch(&req, "projectId", "datasetId", "tableId") +/// let result = hub.tables().patch(req, "projectId", "datasetId", "tableId") /// .doit(); /// # } /// ``` @@ -3677,12 +3704,17 @@ impl<'a, C, A> TablePatchCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3691,7 +3723,7 @@ impl<'a, C, A> TablePatchCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3709,8 +3741,8 @@ impl<'a, C, A> TablePatchCall<'a, C, A> where C: BorrowMut, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Table) -> TablePatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Table) -> TablePatchCall<'a, C, A> { + self._request = new_value; self } /// Project ID of the table to update @@ -3827,7 +3859,7 @@ impl<'a, C, A> TablePatchCall<'a, C, A> where C: BorrowMut, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.datasets().patch(&req, "projectId", "datasetId") +/// let result = hub.datasets().patch(req, "projectId", "datasetId") /// .doit(); /// # } /// ``` @@ -3957,12 +3989,17 @@ impl<'a, C, A> DatasetPatchCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3971,7 +4008,7 @@ impl<'a, C, A> DatasetPatchCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3989,8 +4026,8 @@ impl<'a, C, A> DatasetPatchCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Dataset) -> DatasetPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Dataset) -> DatasetPatchCall<'a, C, A> { + self._request = new_value; self } /// Project ID of the dataset being updated @@ -4212,12 +4249,17 @@ impl<'a, C, A> DatasetGetCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4226,7 +4268,7 @@ impl<'a, C, A> DatasetGetCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4471,12 +4513,17 @@ impl<'a, C, A> DatasetListCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4485,7 +4532,7 @@ impl<'a, C, A> DatasetListCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4613,7 +4660,7 @@ impl<'a, C, A> DatasetListCall<'a, C, A> where C: BorrowMut, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.datasets().update(&req, "projectId", "datasetId") +/// let result = hub.datasets().update(req, "projectId", "datasetId") /// .doit(); /// # } /// ``` @@ -4743,12 +4790,17 @@ impl<'a, C, A> DatasetUpdateCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4757,7 +4809,7 @@ impl<'a, C, A> DatasetUpdateCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4775,8 +4827,8 @@ impl<'a, C, A> DatasetUpdateCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Dataset) -> DatasetUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Dataset) -> DatasetUpdateCall<'a, C, A> { + self._request = new_value; self } /// Project ID of the dataset being updated @@ -5002,12 +5054,17 @@ impl<'a, C, A> DatasetDeleteCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -5130,7 +5187,7 @@ impl<'a, C, A> DatasetDeleteCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.datasets().insert(&req, "projectId") +/// let result = hub.datasets().insert(req, "projectId") /// .doit(); /// # } /// ``` @@ -5258,12 +5315,17 @@ impl<'a, C, A> DatasetInsertCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5272,7 +5334,7 @@ impl<'a, C, A> DatasetInsertCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5290,8 +5352,8 @@ impl<'a, C, A> DatasetInsertCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Dataset) -> DatasetInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Dataset) -> DatasetInsertCall<'a, C, A> { + self._request = new_value; self } /// Project ID of the new dataset @@ -5388,7 +5450,7 @@ impl<'a, C, A> DatasetInsertCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.jobs().query(&req, "projectId") +/// let result = hub.jobs().query(req, "projectId") /// .doit(); /// # } /// ``` @@ -5516,12 +5578,17 @@ impl<'a, C, A> JobQueryCall<'a, C, A> where C: BorrowMut, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5530,7 +5597,7 @@ impl<'a, C, A> JobQueryCall<'a, C, A> where C: BorrowMut, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5548,8 +5615,8 @@ impl<'a, C, A> JobQueryCall<'a, C, A> where C: BorrowMut, A: oaut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &QueryRequest) -> JobQueryCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: QueryRequest) -> JobQueryCall<'a, C, A> { + self._request = new_value; self } /// Project ID of the project billed for the query @@ -5781,12 +5848,17 @@ impl<'a, C, A> JobGetQueryResultCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5795,7 +5867,7 @@ impl<'a, C, A> JobGetQueryResultCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6082,12 +6154,17 @@ impl<'a, C, A> JobListCall<'a, C, A> where C: BorrowMut, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6096,7 +6173,7 @@ impl<'a, C, A> JobListCall<'a, C, A> where C: BorrowMut, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6354,12 +6431,17 @@ impl<'a, C, A> JobGetCall<'a, C, A> where C: BorrowMut, A: oauth2 if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6368,7 +6450,7 @@ impl<'a, C, A> JobGetCall<'a, C, A> where C: BorrowMut, A: oauth2 Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6486,7 +6568,7 @@ impl<'a, C, A> JobGetCall<'a, C, A> where C: BorrowMut, A: oauth2 /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.jobs().insert(&req, "projectId") +/// let result = hub.jobs().insert(req, "projectId") /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } /// ``` @@ -6532,14 +6614,15 @@ impl<'a, C, A> JobInsertCall<'a, C, A> where C: BorrowMut, A: oau params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/bigquery/v2/projects/{projectId}/jobs".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/bigquery/v2/projects/{projectId}/jobs".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/bigquery/v2/projects/{projectId}/jobs".to_string() + ("https://www.googleapis.com/resumable/upload/bigquery/v2/projects/{projectId}/jobs".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } @@ -6656,12 +6739,17 @@ impl<'a, C, A> JobInsertCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -6669,9 +6757,9 @@ impl<'a, C, A> JobInsertCall<'a, C, A> where C: BorrowMut, A: oau let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -6681,7 +6769,7 @@ impl<'a, C, A> JobInsertCall<'a, C, A> where C: BorrowMut, A: oau auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -6712,7 +6800,7 @@ impl<'a, C, A> JobInsertCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6756,8 +6844,8 @@ impl<'a, C, A> JobInsertCall<'a, C, A> where C: BorrowMut, A: oau /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Job) -> JobInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Job) -> JobInsertCall<'a, C, A> { + self._request = new_value; self } /// Project ID of the project that will be billed for the job @@ -6854,7 +6942,7 @@ impl<'a, C, A> JobInsertCall<'a, C, A> where C: BorrowMut, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.tabledata().insert_all(&req, "projectId", "datasetId", "tableId") +/// let result = hub.tabledata().insert_all(req, "projectId", "datasetId", "tableId") /// .doit(); /// # } /// ``` @@ -6986,12 +7074,17 @@ impl<'a, C, A> TabledataInsertAllCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7000,7 +7093,7 @@ impl<'a, C, A> TabledataInsertAllCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7018,8 +7111,8 @@ impl<'a, C, A> TabledataInsertAllCall<'a, C, A> where C: BorrowMut TabledataInsertAllCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: TableDataInsertAllRequest) -> TabledataInsertAllCall<'a, C, A> { + self._request = new_value; self } /// Project ID of the destination table. @@ -7268,12 +7361,17 @@ impl<'a, C, A> TabledataListCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7282,7 +7380,7 @@ impl<'a, C, A> TabledataListCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7527,12 +7625,17 @@ impl<'a, C, A> ProjectListCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7541,7 +7644,7 @@ impl<'a, C, A> ProjectListCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/blogger3-cli/Cargo.toml b/gen/blogger3-cli/Cargo.toml index 8b7435e5c6..53c0ed7c44 100644 --- a/gen/blogger3-cli/Cargo.toml +++ b/gen/blogger3-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-blogger3-cli" -version = "0.0.1+20150422" +version = "0.1.0+20150422" authors = ["Sebastian Thiel "] description = "A complete library to interact with blogger (protocol v3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/blogger3-cli" diff --git a/gen/blogger3-cli/README.md b/gen/blogger3-cli/README.md index f2320b7f98..5d02d26def 100644 --- a/gen/blogger3-cli/README.md +++ b/gen/blogger3-cli/README.md @@ -1,4 +1,134 @@ -# HELLO BLOGGER:V3 + +The `blogger3` command-line interface *(CLI)* allows to use most features of the *Google blogger* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *blogger* API at revision *20150422*. The CLI is at version *0.1.0*. + +```bash + blogger3 [options] blog-user-infos get [-p ...] [-o ] + blogger3 [options] blogs get [-p ...] [-o ] + blogger3 [options] blogs get-by-url [-p ...] [-o ] + blogger3 [options] blogs list-by-user [-p ...] [-o ] + blogger3 [options] comments approve [-p ...] [-o ] + blogger3 [options] comments delete [-p ...] + blogger3 [options] comments get [-p ...] [-o ] + blogger3 [options] comments list [-p ...] [-o ] + blogger3 [options] comments list-by-blog [-p ...] [-o ] + blogger3 [options] comments mark-as-spam [-p ...] [-o ] + blogger3 [options] comments remove-content [-p ...] [-o ] + blogger3 [options] page-views get [-p ...] [-o ] + blogger3 [options] pages delete [-p ...] + blogger3 [options] pages get [-p ...] [-o ] + blogger3 [options] pages insert -r ... [-p ...] [-o ] + blogger3 [options] pages list [-p ...] [-o ] + blogger3 [options] pages patch -r ... [-p ...] [-o ] + blogger3 [options] pages publish [-p ...] [-o ] + blogger3 [options] pages revert [-p ...] [-o ] + blogger3 [options] pages update -r ... [-p ...] [-o ] + blogger3 [options] post-user-infos get [-p ...] [-o ] + blogger3 [options] post-user-infos list [-p ...] [-o ] + blogger3 [options] posts delete [-p ...] + blogger3 [options] posts get [-p ...] [-o ] + blogger3 [options] posts get-by-path [-p ...] [-o ] + blogger3 [options] posts insert -r ... [-p ...] [-o ] + blogger3 [options] posts list [-p ...] [-o ] + blogger3 [options] posts patch -r ... [-p ...] [-o ] + blogger3 [options] posts publish [-p ...] [-o ] + blogger3 [options] posts revert [-p ...] [-o ] + blogger3 [options] posts search [-p ...] [-o ] + blogger3 [options] posts update -r ... [-p ...] [-o ] + blogger3 [options] users get [-p ...] [-o ] + blogger3 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_blogger3_cli/index.html + +Configuration: + --scope + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `blogger3-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/blogger3-token-.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/blogger3-secret.json`, assuming that the required *blogger* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `blogger3 --debug [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/blogger3-cli/mkdocs.yml b/gen/blogger3-cli/mkdocs.yml index bc359d567f..756a43af63 100644 --- a/gen/blogger3-cli/mkdocs.yml +++ b/gen/blogger3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: blogger v0.0.1+20150422 +site_name: blogger v0.1.0+20150422 site_url: http://byron.github.io/google-apis-rs/google-blogger3-cli site_description: Write integrating applications with bcore diff --git a/gen/blogger3-cli/src/cmn.rs b/gen/blogger3-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/blogger3-cli/src/cmn.rs +++ b/gen/blogger3-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/blogger3-cli/src/main.rs b/gen/blogger3-cli/src/main.rs index 201aa876a5..cd4f10a952 100644 --- a/gen/blogger3-cli/src/main.rs +++ b/gen/blogger3-cli/src/main.rs @@ -19,58 +19,59 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - blogger3 [options] blog-user-infos get [-p ]... [-o ] - blogger3 [options] blogs get [-p ]... [-o ] - blogger3 [options] blogs get-by-url [-p ]... [-o ] - blogger3 [options] blogs list-by-user [-p ]... [-o ] - blogger3 [options] comments approve [-p ]... [-o ] - blogger3 [options] comments delete [-p ]... - blogger3 [options] comments get [-p ]... [-o ] - blogger3 [options] comments list [-p ]... [-o ] - blogger3 [options] comments list-by-blog [-p ]... [-o ] - blogger3 [options] comments mark-as-spam [-p ]... [-o ] - blogger3 [options] comments remove-content [-p ]... [-o ] - blogger3 [options] page-views get [-p ]... [-o ] - blogger3 [options] pages delete [-p ]... - blogger3 [options] pages get [-p ]... [-o ] - blogger3 [options] pages insert -r ... [-p ]... [-o ] - blogger3 [options] pages list [-p ]... [-o ] - blogger3 [options] pages patch -r ... [-p ]... [-o ] - blogger3 [options] pages publish [-p ]... [-o ] - blogger3 [options] pages revert [-p ]... [-o ] - blogger3 [options] pages update -r ... [-p ]... [-o ] - blogger3 [options] post-user-infos get [-p ]... [-o ] - blogger3 [options] post-user-infos list [-p ]... [-o ] - blogger3 [options] posts delete [-p ]... - blogger3 [options] posts get [-p ]... [-o ] - blogger3 [options] posts get-by-path [-p ]... [-o ] - blogger3 [options] posts insert -r ... [-p ]... [-o ] - blogger3 [options] posts list [-p ]... [-o ] - blogger3 [options] posts patch -r ... [-p ]... [-o ] - blogger3 [options] posts publish [-p ]... [-o ] - blogger3 [options] posts revert [-p ]... [-o ] - blogger3 [options] posts search [-p ]... [-o ] - blogger3 [options] posts update -r ... [-p ]... [-o ] - blogger3 [options] users get [-p ]... [-o ] + blogger3 [options] blog-user-infos get [-p ...] [-o ] + blogger3 [options] blogs get [-p ...] [-o ] + blogger3 [options] blogs get-by-url [-p ...] [-o ] + blogger3 [options] blogs list-by-user [-p ...] [-o ] + blogger3 [options] comments approve [-p ...] [-o ] + blogger3 [options] comments delete [-p ...] + blogger3 [options] comments get [-p ...] [-o ] + blogger3 [options] comments list [-p ...] [-o ] + blogger3 [options] comments list-by-blog [-p ...] [-o ] + blogger3 [options] comments mark-as-spam [-p ...] [-o ] + blogger3 [options] comments remove-content [-p ...] [-o ] + blogger3 [options] page-views get [-p ...] [-o ] + blogger3 [options] pages delete [-p ...] + blogger3 [options] pages get [-p ...] [-o ] + blogger3 [options] pages insert -r ... [-p ...] [-o ] + blogger3 [options] pages list [-p ...] [-o ] + blogger3 [options] pages patch -r ... [-p ...] [-o ] + blogger3 [options] pages publish [-p ...] [-o ] + blogger3 [options] pages revert [-p ...] [-o ] + blogger3 [options] pages update -r ... [-p ...] [-o ] + blogger3 [options] post-user-infos get [-p ...] [-o ] + blogger3 [options] post-user-infos list [-p ...] [-o ] + blogger3 [options] posts delete [-p ...] + blogger3 [options] posts get [-p ...] [-o ] + blogger3 [options] posts get-by-path [-p ...] [-o ] + blogger3 [options] posts insert -r ... [-p ...] [-o ] + blogger3 [options] posts list [-p ...] [-o ] + blogger3 [options] posts patch -r ... [-p ...] [-o ] + blogger3 [options] posts publish [-p ...] [-o ] + blogger3 [options] posts revert [-p ...] [-o ] + blogger3 [options] posts search [-p ...] [-o ] + blogger3 [options] posts update -r ... [-p ...] [-o ] + blogger3 [options] users get [-p ...] [-o ] blogger3 --help -All documentation details can be found TODO: +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_blogger3_cli/index.html Configuration: --scope - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -122,6 +123,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -171,6 +175,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -217,6 +224,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -272,6 +282,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -315,6 +328,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -358,6 +374,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -402,6 +421,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -466,6 +488,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -527,6 +552,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -570,6 +598,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -613,6 +644,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -659,6 +693,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -702,6 +739,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -746,6 +786,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -762,39 +805,23 @@ impl Engine { fn _pages_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Page::default(); - let mut call = self.hub.pages().insert(&request, &self.opt.arg_blog_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "is-draft" => { - call = call.is_draft(arg_from_str(value.unwrap_or("false"), err, "is-draft", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Page::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_author_image_init(request: &mut api::Page) { request_author_init(request); if request.author.as_mut().unwrap().image.is_none() { @@ -814,7 +841,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -873,15 +900,43 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.pages().insert(request, &self.opt.arg_blog_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "is-draft" => { + call = call.is_draft(arg_from_str(value.unwrap_or("false"), err, "is-draft", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -940,6 +995,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -956,42 +1014,23 @@ impl Engine { fn _pages_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Page::default(); - let mut call = self.hub.pages().patch(&request, &self.opt.arg_blog_id, &self.opt.arg_page_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "revert" => { - call = call.revert(arg_from_str(value.unwrap_or("false"), err, "revert", "boolean")); - }, - "publish" => { - call = call.publish(arg_from_str(value.unwrap_or("false"), err, "publish", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Page::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_author_image_init(request: &mut api::Page) { request_author_init(request); if request.author.as_mut().unwrap().image.is_none() { @@ -1011,7 +1050,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -1070,15 +1109,46 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.pages().patch(request, &self.opt.arg_blog_id, &self.opt.arg_page_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "revert" => { + call = call.revert(arg_from_str(value.unwrap_or("false"), err, "revert", "boolean")); + }, + "publish" => { + call = call.publish(arg_from_str(value.unwrap_or("false"), err, "publish", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1122,6 +1192,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1165,6 +1238,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1181,42 +1257,23 @@ impl Engine { fn _pages_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Page::default(); - let mut call = self.hub.pages().update(&request, &self.opt.arg_blog_id, &self.opt.arg_page_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "revert" => { - call = call.revert(arg_from_str(value.unwrap_or("false"), err, "revert", "boolean")); - }, - "publish" => { - call = call.publish(arg_from_str(value.unwrap_or("false"), err, "publish", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Page::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_author_image_init(request: &mut api::Page) { request_author_init(request); if request.author.as_mut().unwrap().image.is_none() { @@ -1236,7 +1293,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -1295,15 +1352,46 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.pages().update(request, &self.opt.arg_blog_id, &self.opt.arg_page_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "revert" => { + call = call.revert(arg_from_str(value.unwrap_or("false"), err, "revert", "boolean")); + }, + "publish" => { + call = call.publish(arg_from_str(value.unwrap_or("false"), err, "publish", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1350,6 +1438,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1420,6 +1511,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1463,6 +1557,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1516,6 +1613,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1565,6 +1665,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1581,45 +1684,23 @@ impl Engine { fn _posts_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Post::default(); - let mut call = self.hub.posts().insert(&request, &self.opt.arg_blog_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "is-draft" => { - call = call.is_draft(arg_from_str(value.unwrap_or("false"), err, "is-draft", "boolean")); - }, - "fetch-images" => { - call = call.fetch_images(arg_from_str(value.unwrap_or("false"), err, "fetch-images", "boolean")); - }, - "fetch-body" => { - call = call.fetch_body(arg_from_str(value.unwrap_or("false"), err, "fetch-body", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Post::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_author_image_init(request: &mut api::Post) { request_author_init(request); if request.author.as_mut().unwrap().image.is_none() { @@ -1651,7 +1732,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -1752,15 +1833,49 @@ impl Engine { request.published = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.posts().insert(request, &self.opt.arg_blog_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "is-draft" => { + call = call.is_draft(arg_from_str(value.unwrap_or("false"), err, "is-draft", "boolean")); + }, + "fetch-images" => { + call = call.fetch_images(arg_from_str(value.unwrap_or("false"), err, "fetch-images", "boolean")); + }, + "fetch-body" => { + call = call.fetch_body(arg_from_str(value.unwrap_or("false"), err, "fetch-body", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1834,6 +1949,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1850,51 +1968,23 @@ impl Engine { fn _posts_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Post::default(); - let mut call = self.hub.posts().patch(&request, &self.opt.arg_blog_id, &self.opt.arg_post_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "revert" => { - call = call.revert(arg_from_str(value.unwrap_or("false"), err, "revert", "boolean")); - }, - "publish" => { - call = call.publish(arg_from_str(value.unwrap_or("false"), err, "publish", "boolean")); - }, - "max-comments" => { - call = call.max_comments(arg_from_str(value.unwrap_or("-0"), err, "max-comments", "integer")); - }, - "fetch-images" => { - call = call.fetch_images(arg_from_str(value.unwrap_or("false"), err, "fetch-images", "boolean")); - }, - "fetch-body" => { - call = call.fetch_body(arg_from_str(value.unwrap_or("false"), err, "fetch-body", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Post::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_author_image_init(request: &mut api::Post) { request_author_init(request); if request.author.as_mut().unwrap().image.is_none() { @@ -1926,7 +2016,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -2027,15 +2117,55 @@ impl Engine { request.published = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.posts().patch(request, &self.opt.arg_blog_id, &self.opt.arg_post_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "revert" => { + call = call.revert(arg_from_str(value.unwrap_or("false"), err, "revert", "boolean")); + }, + "publish" => { + call = call.publish(arg_from_str(value.unwrap_or("false"), err, "publish", "boolean")); + }, + "max-comments" => { + call = call.max_comments(arg_from_str(value.unwrap_or("-0"), err, "max-comments", "integer")); + }, + "fetch-images" => { + call = call.fetch_images(arg_from_str(value.unwrap_or("false"), err, "fetch-images", "boolean")); + }, + "fetch-body" => { + call = call.fetch_body(arg_from_str(value.unwrap_or("false"), err, "fetch-body", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2082,6 +2212,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2125,6 +2258,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2174,6 +2310,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2190,51 +2329,23 @@ impl Engine { fn _posts_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Post::default(); - let mut call = self.hub.posts().update(&request, &self.opt.arg_blog_id, &self.opt.arg_post_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "revert" => { - call = call.revert(arg_from_str(value.unwrap_or("false"), err, "revert", "boolean")); - }, - "publish" => { - call = call.publish(arg_from_str(value.unwrap_or("false"), err, "publish", "boolean")); - }, - "max-comments" => { - call = call.max_comments(arg_from_str(value.unwrap_or("-0"), err, "max-comments", "integer")); - }, - "fetch-images" => { - call = call.fetch_images(arg_from_str(value.unwrap_or("false"), err, "fetch-images", "boolean")); - }, - "fetch-body" => { - call = call.fetch_body(arg_from_str(value.unwrap_or("false"), err, "fetch-body", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Post::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_author_image_init(request: &mut api::Post) { request_author_init(request); if request.author.as_mut().unwrap().image.is_none() { @@ -2266,7 +2377,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -2367,15 +2478,55 @@ impl Engine { request.published = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.posts().update(request, &self.opt.arg_blog_id, &self.opt.arg_post_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "revert" => { + call = call.revert(arg_from_str(value.unwrap_or("false"), err, "revert", "boolean")); + }, + "publish" => { + call = call.publish(arg_from_str(value.unwrap_or("false"), err, "publish", "boolean")); + }, + "max-comments" => { + call = call.max_comments(arg_from_str(value.unwrap_or("-0"), err, "max-comments", "integer")); + }, + "fetch-images" => { + call = call.fetch_images(arg_from_str(value.unwrap_or("false"), err, "fetch-images", "boolean")); + }, + "fetch-body" => { + call = call.fetch_body(arg_from_str(value.unwrap_or("false"), err, "fetch-body", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2419,6 +2570,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2611,6 +2765,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -2618,8 +2773,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/blogger3/Cargo.toml b/gen/blogger3/Cargo.toml index 7399a22a8c..bc9a9167d4 100644 --- a/gen/blogger3/Cargo.toml +++ b/gen/blogger3/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-blogger3" -version = "0.1.5+20150422" +version = "0.1.6+20150422" authors = ["Sebastian Thiel "] description = "A complete library to interact with blogger (protocol v3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/blogger3" diff --git a/gen/blogger3/README.md b/gen/blogger3/README.md index 208f92275e..3cc61ea5f1 100644 --- a/gen/blogger3/README.md +++ b/gen/blogger3/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-blogger3` library allows access to all features of the *Google blogger* service. -This documentation was generated from *blogger* crate version *0.1.5+20150422*, where *20150422* is the exact revision of the *blogger:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *blogger* crate version *0.1.6+20150422*, where *20150422* is the exact revision of the *blogger:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *blogger* *v3* API can be found at the [official documentation site](https://developers.google.com/blogger/docs/3.0/getting_started). @@ -132,14 +132,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/blogger3/src/cmn.rs b/gen/blogger3/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/blogger3/src/cmn.rs +++ b/gen/blogger3/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option, + location: Option +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option, _: Option) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec]) -> Option { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/blogger3/src/lib.rs b/gen/blogger3/src/lib.rs index 1160f79540..976655c14f 100644 --- a/gen/blogger3/src/lib.rs +++ b/gen/blogger3/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *blogger* crate version *0.1.5+20150422*, where *20150422* is the exact revision of the *blogger:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *blogger* crate version *0.1.6+20150422*, where *20150422* is the exact revision of the *blogger:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *blogger* *v3* API can be found at the //! [official documentation site](https://developers.google.com/blogger/docs/3.0/getting_started). @@ -133,14 +133,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -228,7 +229,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -316,14 +317,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -344,7 +346,7 @@ impl<'a, C, A> Blogger Blogger { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -374,7 +376,7 @@ impl<'a, C, A> Blogger } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -1489,10 +1491,10 @@ impl<'a, C, A> PostMethods<'a, C, A> { /// * `request` - No description provided. /// * `blogId` - The ID of the Blog. /// * `postId` - The ID of the Post. - pub fn update(&self, request: &Post, blog_id: &str, post_id: &str) -> PostUpdateCall<'a, C, A> { + pub fn update(&self, request: Post, blog_id: &str, post_id: &str) -> PostUpdateCall<'a, C, A> { PostUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _blog_id: blog_id.to_string(), _post_id: post_id.to_string(), _revert: Default::default(), @@ -1558,10 +1560,10 @@ impl<'a, C, A> PostMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `blogId` - ID of the blog to add the post to. - pub fn insert(&self, request: &Post, blog_id: &str) -> PostInsertCall<'a, C, A> { + pub fn insert(&self, request: Post, blog_id: &str) -> PostInsertCall<'a, C, A> { PostInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _blog_id: blog_id.to_string(), _is_draft: Default::default(), _fetch_images: Default::default(), @@ -1660,10 +1662,10 @@ impl<'a, C, A> PostMethods<'a, C, A> { /// * `request` - No description provided. /// * `blogId` - The ID of the Blog. /// * `postId` - The ID of the Post. - pub fn patch(&self, request: &Post, blog_id: &str, post_id: &str) -> PostPatchCall<'a, C, A> { + pub fn patch(&self, request: Post, blog_id: &str, post_id: &str) -> PostPatchCall<'a, C, A> { PostPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _blog_id: blog_id.to_string(), _post_id: post_id.to_string(), _revert: Default::default(), @@ -2162,10 +2164,10 @@ impl<'a, C, A> PageMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `blogId` - ID of the blog to add the page to. - pub fn insert(&self, request: &Page, blog_id: &str) -> PageInsertCall<'a, C, A> { + pub fn insert(&self, request: Page, blog_id: &str) -> PageInsertCall<'a, C, A> { PageInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _blog_id: blog_id.to_string(), _is_draft: Default::default(), _delegate: Default::default(), @@ -2183,10 +2185,10 @@ impl<'a, C, A> PageMethods<'a, C, A> { /// * `request` - No description provided. /// * `blogId` - The ID of the Blog. /// * `pageId` - The ID of the Page. - pub fn patch(&self, request: &Page, blog_id: &str, page_id: &str) -> PagePatchCall<'a, C, A> { + pub fn patch(&self, request: Page, blog_id: &str, page_id: &str) -> PagePatchCall<'a, C, A> { PagePatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _blog_id: blog_id.to_string(), _page_id: page_id.to_string(), _revert: Default::default(), @@ -2225,10 +2227,10 @@ impl<'a, C, A> PageMethods<'a, C, A> { /// * `request` - No description provided. /// * `blogId` - The ID of the Blog. /// * `pageId` - The ID of the Page. - pub fn update(&self, request: &Page, blog_id: &str, page_id: &str) -> PageUpdateCall<'a, C, A> { + pub fn update(&self, request: Page, blog_id: &str, page_id: &str) -> PageUpdateCall<'a, C, A> { PageUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _blog_id: blog_id.to_string(), _page_id: page_id.to_string(), _revert: Default::default(), @@ -2421,12 +2423,17 @@ impl<'a, C, A> PageViewGetCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2435,7 +2442,7 @@ impl<'a, C, A> PageViewGetCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2662,12 +2669,17 @@ impl<'a, C, A> UserGetCall<'a, C, A> where C: BorrowMut, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2676,7 +2688,7 @@ impl<'a, C, A> UserGetCall<'a, C, A> where C: BorrowMut, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2924,12 +2936,17 @@ impl<'a, C, A> BlogListByUserCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2938,7 +2955,7 @@ impl<'a, C, A> BlogListByUserCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3198,12 +3215,17 @@ impl<'a, C, A> BlogGetCall<'a, C, A> where C: BorrowMut, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3212,7 +3234,7 @@ impl<'a, C, A> BlogGetCall<'a, C, A> where C: BorrowMut, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3427,12 +3449,17 @@ impl<'a, C, A> BlogGetByUrlCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3441,7 +3468,7 @@ impl<'a, C, A> BlogGetByUrlCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3555,7 +3582,7 @@ impl<'a, C, A> BlogGetByUrlCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.posts().update(&req, "blogId", "postId") +/// let result = hub.posts().update(req, "blogId", "postId") /// .revert(true) /// .publish(true) /// .max_comments(31) @@ -3710,12 +3737,17 @@ impl<'a, C, A> PostUpdateCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3724,7 +3756,7 @@ impl<'a, C, A> PostUpdateCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3742,8 +3774,8 @@ impl<'a, C, A> PostUpdateCall<'a, C, A> where C: BorrowMut, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Post) -> PostUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Post) -> PostUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the Blog. @@ -4010,12 +4042,17 @@ impl<'a, C, A> PostGetByPathCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4024,7 +4061,7 @@ impl<'a, C, A> PostGetByPathCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4290,12 +4327,17 @@ impl<'a, C, A> PostGetCall<'a, C, A> where C: BorrowMut, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4304,7 +4346,7 @@ impl<'a, C, A> PostGetCall<'a, C, A> where C: BorrowMut, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4449,7 +4491,7 @@ impl<'a, C, A> PostGetCall<'a, C, A> where C: BorrowMut, A: oauth /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.posts().insert(&req, "blogId") +/// let result = hub.posts().insert(req, "blogId") /// .is_draft(true) /// .fetch_images(false) /// .fetch_body(false) @@ -4592,12 +4634,17 @@ impl<'a, C, A> PostInsertCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4606,7 +4653,7 @@ impl<'a, C, A> PostInsertCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4624,8 +4671,8 @@ impl<'a, C, A> PostInsertCall<'a, C, A> where C: BorrowMut, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Post) -> PostInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Post) -> PostInsertCall<'a, C, A> { + self._request = new_value; self } /// ID of the blog to add the post to. @@ -4863,12 +4910,17 @@ impl<'a, C, A> PostPublishCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4877,7 +4929,7 @@ impl<'a, C, A> PostPublishCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5115,12 +5167,17 @@ impl<'a, C, A> PostDeleteCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -5351,12 +5408,17 @@ impl<'a, C, A> PostRevertCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5365,7 +5427,7 @@ impl<'a, C, A> PostRevertCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5607,12 +5669,17 @@ impl<'a, C, A> PostSearchCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5621,7 +5688,7 @@ impl<'a, C, A> PostSearchCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5752,7 +5819,7 @@ impl<'a, C, A> PostSearchCall<'a, C, A> where C: BorrowMut, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.posts().patch(&req, "blogId", "postId") +/// let result = hub.posts().patch(req, "blogId", "postId") /// .revert(false) /// .publish(false) /// .max_comments(82) @@ -5907,12 +5974,17 @@ impl<'a, C, A> PostPatchCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5921,7 +5993,7 @@ impl<'a, C, A> PostPatchCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5939,8 +6011,8 @@ impl<'a, C, A> PostPatchCall<'a, C, A> where C: BorrowMut, A: oau /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Post) -> PostPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Post) -> PostPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the Blog. @@ -6249,12 +6321,17 @@ impl<'a, C, A> PostListCall<'a, C, A> where C: BorrowMut, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6263,7 +6340,7 @@ impl<'a, C, A> PostListCall<'a, C, A> where C: BorrowMut, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6563,12 +6640,17 @@ impl<'a, C, A> CommentGetCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6577,7 +6659,7 @@ impl<'a, C, A> CommentGetCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6828,12 +6910,17 @@ impl<'a, C, A> CommentRemoveContentCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6842,7 +6929,7 @@ impl<'a, C, A> CommentRemoveContentCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7116,12 +7203,17 @@ impl<'a, C, A> CommentListByBlogCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7130,7 +7222,7 @@ impl<'a, C, A> CommentListByBlogCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7396,12 +7488,17 @@ impl<'a, C, A> CommentMarkAsSpamCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7410,7 +7507,7 @@ impl<'a, C, A> CommentMarkAsSpamCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7691,12 +7788,17 @@ impl<'a, C, A> CommentListCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7705,7 +7807,7 @@ impl<'a, C, A> CommentListCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7988,12 +8090,17 @@ impl<'a, C, A> CommentApproveCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8002,7 +8109,7 @@ impl<'a, C, A> CommentApproveCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8245,12 +8352,17 @@ impl<'a, C, A> CommentDeleteCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -8498,12 +8610,17 @@ impl<'a, C, A> PostUserInfoGetCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8512,7 +8629,7 @@ impl<'a, C, A> PostUserInfoGetCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8810,12 +8927,17 @@ impl<'a, C, A> PostUserInfoListCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8824,7 +8946,7 @@ impl<'a, C, A> PostUserInfoListCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9124,12 +9246,17 @@ impl<'a, C, A> BlogUserInfoGetCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9138,7 +9265,7 @@ impl<'a, C, A> BlogUserInfoGetCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9382,12 +9509,17 @@ impl<'a, C, A> PageGetCall<'a, C, A> where C: BorrowMut, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9396,7 +9528,7 @@ impl<'a, C, A> PageGetCall<'a, C, A> where C: BorrowMut, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9661,12 +9793,17 @@ impl<'a, C, A> PageListCall<'a, C, A> where C: BorrowMut, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9675,7 +9812,7 @@ impl<'a, C, A> PageListCall<'a, C, A> where C: BorrowMut, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9932,12 +10069,17 @@ impl<'a, C, A> PageRevertCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9946,7 +10088,7 @@ impl<'a, C, A> PageRevertCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10063,7 +10205,7 @@ impl<'a, C, A> PageRevertCall<'a, C, A> where C: BorrowMut, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.pages().insert(&req, "blogId") +/// let result = hub.pages().insert(req, "blogId") /// .is_draft(true) /// .doit(); /// # } @@ -10196,12 +10338,17 @@ impl<'a, C, A> PageInsertCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10210,7 +10357,7 @@ impl<'a, C, A> PageInsertCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10228,8 +10375,8 @@ impl<'a, C, A> PageInsertCall<'a, C, A> where C: BorrowMut, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Page) -> PageInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Page) -> PageInsertCall<'a, C, A> { + self._request = new_value; self } /// ID of the blog to add the page to. @@ -10333,7 +10480,7 @@ impl<'a, C, A> PageInsertCall<'a, C, A> where C: BorrowMut, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.pages().patch(&req, "blogId", "pageId") +/// let result = hub.pages().patch(req, "blogId", "pageId") /// .revert(true) /// .publish(true) /// .doit(); @@ -10473,12 +10620,17 @@ impl<'a, C, A> PagePatchCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10487,7 +10639,7 @@ impl<'a, C, A> PagePatchCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10505,8 +10657,8 @@ impl<'a, C, A> PagePatchCall<'a, C, A> where C: BorrowMut, A: oau /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Page) -> PagePatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Page) -> PagePatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the Blog. @@ -10742,12 +10894,17 @@ impl<'a, C, A> PagePublishCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10756,7 +10913,7 @@ impl<'a, C, A> PagePublishCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10873,7 +11030,7 @@ impl<'a, C, A> PagePublishCall<'a, C, A> where C: BorrowMut, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.pages().update(&req, "blogId", "pageId") +/// let result = hub.pages().update(req, "blogId", "pageId") /// .revert(true) /// .publish(true) /// .doit(); @@ -11013,12 +11170,17 @@ impl<'a, C, A> PageUpdateCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11027,7 +11189,7 @@ impl<'a, C, A> PageUpdateCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11045,8 +11207,8 @@ impl<'a, C, A> PageUpdateCall<'a, C, A> where C: BorrowMut, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Page) -> PageUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Page) -> PageUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the Blog. @@ -11281,12 +11443,17 @@ impl<'a, C, A> PageDeleteCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; diff --git a/gen/books1-cli/Cargo.toml b/gen/books1-cli/Cargo.toml index 09857322b3..2cb4156082 100644 --- a/gen/books1-cli/Cargo.toml +++ b/gen/books1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-books1-cli" -version = "0.0.1+20150401" +version = "0.1.0+20150401" authors = ["Sebastian Thiel "] description = "A complete library to interact with books (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/books1-cli" diff --git a/gen/books1-cli/README.md b/gen/books1-cli/README.md index 08b6452f31..483a184544 100644 --- a/gen/books1-cli/README.md +++ b/gen/books1-cli/README.md @@ -1,4 +1,145 @@ -# HELLO BOOKS:V1 + +The `books1` command-line interface *(CLI)* allows to use most features of the *Google books* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *books* API at revision *20150401*. The CLI is at version *0.1.0*. + +```bash + books1 [options] bookshelves get [-p ...] [-o ] + books1 [options] bookshelves list [-p ...] [-o ] + books1 [options] bookshelves volumes-list [-p ...] [-o ] + books1 [options] cloudloading add-book [-p ...] [-o ] + books1 [options] cloudloading delete-book [-p ...] + books1 [options] cloudloading update-book -r ... [-p ...] [-o ] + books1 [options] dictionary list-offline-metadata [-p ...] [-o ] + books1 [options] layers annotation-data-get [-p ...] [-o ] + books1 [options] layers annotation-data-list [-p ...] [-o ] + books1 [options] layers get [-p ...] [-o ] + books1 [options] layers list [-p ...] [-o ] + books1 [options] layers volume-annotations-get [-p ...] [-o ] + books1 [options] layers volume-annotations-list [-p ...] [-o ] + books1 [options] myconfig get-user-settings [-p ...] [-o ] + books1 [options] myconfig release-download-access ... [-p ...] [-o ] + books1 [options] myconfig request-access [-p ...] [-o ] + books1 [options] myconfig sync-volume-licenses [-p ...] [-o ] + books1 [options] myconfig update-user-settings -r ... [-p ...] [-o ] + books1 [options] mylibrary annotations-delete [-p ...] + books1 [options] mylibrary annotations-insert -r ... [-p ...] [-o ] + books1 [options] mylibrary annotations-list [-p ...] [-o ] + books1 [options] mylibrary annotations-summary ... [-p ...] [-o ] + books1 [options] mylibrary annotations-update -r ... [-p ...] [-o ] + books1 [options] mylibrary bookshelves-add-volume [-p ...] + books1 [options] mylibrary bookshelves-clear-volumes [-p ...] + books1 [options] mylibrary bookshelves-get [-p ...] [-o ] + books1 [options] mylibrary bookshelves-list [-p ...] [-o ] + books1 [options] mylibrary bookshelves-move-volume [-p ...] + books1 [options] mylibrary bookshelves-remove-volume [-p ...] + books1 [options] mylibrary bookshelves-volumes-list [-p ...] [-o ] + books1 [options] mylibrary readingpositions-get [-p ...] [-o ] + books1 [options] mylibrary readingpositions-set-position [-p ...] + books1 [options] onboarding list-categories [-p ...] [-o ] + books1 [options] onboarding list-category-volumes [-p ...] [-o ] + books1 [options] promooffer accept [-p ...] + books1 [options] promooffer dismiss [-p ...] + books1 [options] promooffer get [-p ...] [-o ] + books1 [options] volumes associated-list [-p ...] [-o ] + books1 [options] volumes get [-p ...] [-o ] + books1 [options] volumes list [-p ...] [-o ] + books1 [options] volumes mybooks-list [-p ...] [-o ] + books1 [options] volumes recommended-list [-p ...] [-o ] + books1 [options] volumes recommended-rate [-p ...] [-o ] + books1 [options] volumes useruploaded-list [-p ...] [-o ] + books1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_books1_cli/index.html + +Configuration: + --scope + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `books1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/books1-token-.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/books1-secret.json`, assuming that the required *books* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `books1 --debug [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/books1-cli/mkdocs.yml b/gen/books1-cli/mkdocs.yml index 59b2893e1d..2a48f35c4a 100644 --- a/gen/books1-cli/mkdocs.yml +++ b/gen/books1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: books v0.0.1+20150401 +site_name: books v0.1.0+20150401 site_url: http://byron.github.io/google-apis-rs/google-books1-cli site_description: Write integrating applications with bcore diff --git a/gen/books1-cli/src/cmn.rs b/gen/books1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/books1-cli/src/cmn.rs +++ b/gen/books1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/books1-cli/src/main.rs b/gen/books1-cli/src/main.rs index f02f488470..b27d6d2d78 100644 --- a/gen/books1-cli/src/main.rs +++ b/gen/books1-cli/src/main.rs @@ -19,69 +19,70 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - books1 [options] bookshelves get [-p ]... [-o ] - books1 [options] bookshelves list [-p ]... [-o ] - books1 [options] bookshelves volumes-list [-p ]... [-o ] - books1 [options] cloudloading add-book [-p ]... [-o ] - books1 [options] cloudloading delete-book [-p ]... - books1 [options] cloudloading update-book -r ... [-p ]... [-o ] - books1 [options] dictionary list-offline-metadata [-p ]... [-o ] - books1 [options] layers annotation-data-get [-p ]... [-o ] - books1 [options] layers annotation-data-list [-p ]... [-o ] - books1 [options] layers get [-p ]... [-o ] - books1 [options] layers list [-p ]... [-o ] - books1 [options] layers volume-annotations-get [-p ]... [-o ] - books1 [options] layers volume-annotations-list [-p ]... [-o ] - books1 [options] myconfig get-user-settings [-p ]... [-o ] - books1 [options] myconfig release-download-access ... [-p ]... [-o ] - books1 [options] myconfig request-access [-p ]... [-o ] - books1 [options] myconfig sync-volume-licenses [-p ]... [-o ] - books1 [options] myconfig update-user-settings -r ... [-p ]... [-o ] - books1 [options] mylibrary annotations-delete [-p ]... - books1 [options] mylibrary annotations-insert -r ... [-p ]... [-o ] - books1 [options] mylibrary annotations-list [-p ]... [-o ] - books1 [options] mylibrary annotations-summary ... [-p ]... [-o ] - books1 [options] mylibrary annotations-update -r ... [-p ]... [-o ] - books1 [options] mylibrary bookshelves-add-volume [-p ]... - books1 [options] mylibrary bookshelves-clear-volumes [-p ]... - books1 [options] mylibrary bookshelves-get [-p ]... [-o ] - books1 [options] mylibrary bookshelves-list [-p ]... [-o ] - books1 [options] mylibrary bookshelves-move-volume [-p ]... - books1 [options] mylibrary bookshelves-remove-volume [-p ]... - books1 [options] mylibrary bookshelves-volumes-list [-p ]... [-o ] - books1 [options] mylibrary readingpositions-get [-p ]... [-o ] - books1 [options] mylibrary readingpositions-set-position [-p ]... - books1 [options] onboarding list-categories [-p ]... [-o ] - books1 [options] onboarding list-category-volumes [-p ]... [-o ] - books1 [options] promooffer accept [-p ]... - books1 [options] promooffer dismiss [-p ]... - books1 [options] promooffer get [-p ]... [-o ] - books1 [options] volumes associated-list [-p ]... [-o ] - books1 [options] volumes get [-p ]... [-o ] - books1 [options] volumes list [-p ]... [-o ] - books1 [options] volumes mybooks-list [-p ]... [-o ] - books1 [options] volumes recommended-list [-p ]... [-o ] - books1 [options] volumes recommended-rate [-p ]... [-o ] - books1 [options] volumes useruploaded-list [-p ]... [-o ] + books1 [options] bookshelves get [-p ...] [-o ] + books1 [options] bookshelves list [-p ...] [-o ] + books1 [options] bookshelves volumes-list [-p ...] [-o ] + books1 [options] cloudloading add-book [-p ...] [-o ] + books1 [options] cloudloading delete-book [-p ...] + books1 [options] cloudloading update-book -r ... [-p ...] [-o ] + books1 [options] dictionary list-offline-metadata [-p ...] [-o ] + books1 [options] layers annotation-data-get [-p ...] [-o ] + books1 [options] layers annotation-data-list [-p ...] [-o ] + books1 [options] layers get [-p ...] [-o ] + books1 [options] layers list [-p ...] [-o ] + books1 [options] layers volume-annotations-get [-p ...] [-o ] + books1 [options] layers volume-annotations-list [-p ...] [-o ] + books1 [options] myconfig get-user-settings [-p ...] [-o ] + books1 [options] myconfig release-download-access ... [-p ...] [-o ] + books1 [options] myconfig request-access [-p ...] [-o ] + books1 [options] myconfig sync-volume-licenses [-p ...] [-o ] + books1 [options] myconfig update-user-settings -r ... [-p ...] [-o ] + books1 [options] mylibrary annotations-delete [-p ...] + books1 [options] mylibrary annotations-insert -r ... [-p ...] [-o ] + books1 [options] mylibrary annotations-list [-p ...] [-o ] + books1 [options] mylibrary annotations-summary ... [-p ...] [-o ] + books1 [options] mylibrary annotations-update -r ... [-p ...] [-o ] + books1 [options] mylibrary bookshelves-add-volume [-p ...] + books1 [options] mylibrary bookshelves-clear-volumes [-p ...] + books1 [options] mylibrary bookshelves-get [-p ...] [-o ] + books1 [options] mylibrary bookshelves-list [-p ...] [-o ] + books1 [options] mylibrary bookshelves-move-volume [-p ...] + books1 [options] mylibrary bookshelves-remove-volume [-p ...] + books1 [options] mylibrary bookshelves-volumes-list [-p ...] [-o ] + books1 [options] mylibrary readingpositions-get [-p ...] [-o ] + books1 [options] mylibrary readingpositions-set-position [-p ...] + books1 [options] onboarding list-categories [-p ...] [-o ] + books1 [options] onboarding list-category-volumes [-p ...] [-o ] + books1 [options] promooffer accept [-p ...] + books1 [options] promooffer dismiss [-p ...] + books1 [options] promooffer get [-p ...] [-o ] + books1 [options] volumes associated-list [-p ...] [-o ] + books1 [options] volumes get [-p ...] [-o ] + books1 [options] volumes list [-p ...] [-o ] + books1 [options] volumes mybooks-list [-p ...] [-o ] + books1 [options] volumes recommended-list [-p ...] [-o ] + books1 [options] volumes recommended-rate [-p ...] [-o ] + books1 [options] volumes useruploaded-list [-p ...] [-o ] books1 --help -All documentation details can be found TODO: +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_books1_cli/index.html Configuration: --scope - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -133,6 +134,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -179,6 +183,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -234,6 +241,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -289,6 +299,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -332,6 +345,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -346,8 +362,42 @@ impl Engine { fn _cloudloading_update_book(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::BooksCloudloadingResource::default(); - let mut call = self.hub.cloudloading().update_book(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "title" => { + request.title = Some(value.unwrap_or("").to_string()); + }, + "processing-state" => { + request.processing_state = Some(value.unwrap_or("").to_string()); + }, + "volume-id" => { + request.volume_id = Some(value.unwrap_or("").to_string()); + }, + "author" => { + request.author = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.cloudloading().update_book(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -369,36 +419,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "title" => { - request.title = Some(value.unwrap_or("").to_string()); - }, - "processing-state" => { - request.processing_state = Some(value.unwrap_or("").to_string()); - }, - "volume-id" => { - request.volume_id = Some(value.unwrap_or("").to_string()); - }, - "author" => { - request.author = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -442,6 +470,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -503,6 +534,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -576,6 +610,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -625,6 +662,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -680,6 +720,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -729,6 +772,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -808,6 +854,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -851,6 +900,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -900,6 +952,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -949,6 +1004,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1004,6 +1062,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1020,8 +1081,47 @@ impl Engine { fn _myconfig_update_user_settings(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Usersettings::default(); - let mut call = self.hub.myconfig().update_user_settings(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + fn request_notes_export_init(request: &mut api::Usersettings) { + if request.notes_export.is_none() { + request.notes_export = Some(Default::default()); + } + } + + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "notes-export.is-enabled" => { + request_notes_export_init(&mut request); + request.notes_export.as_mut().unwrap().is_enabled = Some(arg_from_str(value.unwrap_or("false"), err, "notes-export.is-enabled", "boolean")); + }, + "notes-export.folder-name" => { + request_notes_export_init(&mut request); + request.notes_export.as_mut().unwrap().folder_name = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.myconfig().update_user_settings(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1043,41 +1143,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_notes_export_init(request: &mut api::Usersettings) { - if request.notes_export.is_none() { - request.notes_export = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "notes-export.is-enabled" => { - request_notes_export_init(&mut request); - request.notes_export.as_mut().unwrap().is_enabled = Some(arg_from_str(value.unwrap_or("false"), err, "notes-export.is-enabled", "boolean")); - }, - "notes-export.folder-name" => { - request_notes_export_init(&mut request); - request.notes_export.as_mut().unwrap().folder_name = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1124,6 +1197,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1138,45 +1214,23 @@ impl Engine { fn _mylibrary_annotations_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Annotation::default(); - let mut call = self.hub.mylibrary().annotations_insert(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "source" => { - call = call.source(value.unwrap_or("")); - }, - "show-only-summary-in-response" => { - call = call.show_only_summary_in_response(arg_from_str(value.unwrap_or("false"), err, "show-only-summary-in-response", "boolean")); - }, - "country" => { - call = call.country(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Annotation::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_client_version_ranges_cfi_range_init(request: &mut api::Annotation) { request_client_version_ranges_init(request); if request.client_version_ranges.as_mut().unwrap().cfi_range.is_none() { @@ -1251,7 +1305,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "updated" => { request.updated = Some(value.unwrap_or("").to_string()); }, @@ -1455,15 +1509,49 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.mylibrary().annotations_insert(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "source" => { + call = call.source(value.unwrap_or("")); + }, + "show-only-summary-in-response" => { + call = call.show_only_summary_in_response(arg_from_str(value.unwrap_or("false"), err, "show-only-summary-in-response", "boolean")); + }, + "country" => { + call = call.country(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1537,6 +1625,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1580,6 +1671,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1596,39 +1690,23 @@ impl Engine { fn _mylibrary_annotations_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Annotation::default(); - let mut call = self.hub.mylibrary().annotations_update(&request, &self.opt.arg_annotation_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "source" => { - call = call.source(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Annotation::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_client_version_ranges_cfi_range_init(request: &mut api::Annotation) { request_client_version_ranges_init(request); if request.client_version_ranges.as_mut().unwrap().cfi_range.is_none() { @@ -1703,7 +1781,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "updated" => { request.updated = Some(value.unwrap_or("").to_string()); }, @@ -1907,15 +1985,43 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.mylibrary().annotations_update(request, &self.opt.arg_annotation_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "source" => { + call = call.source(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1965,6 +2071,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2009,6 +2118,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2053,6 +2165,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2099,6 +2214,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2146,6 +2264,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2193,6 +2314,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2255,6 +2379,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2304,6 +2431,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2359,6 +2489,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2403,6 +2536,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2458,6 +2594,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2525,6 +2664,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2587,6 +2729,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2646,6 +2791,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2698,6 +2846,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2756,6 +2907,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2835,6 +2989,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2896,6 +3053,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2945,6 +3105,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2994,6 +3157,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3055,6 +3221,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3274,6 +3443,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -3281,8 +3451,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/books1/Cargo.toml b/gen/books1/Cargo.toml index e72093dcdf..d9a7f62792 100644 --- a/gen/books1/Cargo.toml +++ b/gen/books1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-books1" -version = "0.1.5+20150401" +version = "0.1.6+20150401" authors = ["Sebastian Thiel "] description = "A complete library to interact with books (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/books1" diff --git a/gen/books1/README.md b/gen/books1/README.md index 326140e794..de570fb159 100644 --- a/gen/books1/README.md +++ b/gen/books1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-books1` library allows access to all features of the *Google books* service. -This documentation was generated from *books* crate version *0.1.5+20150401*, where *20150401* is the exact revision of the *books:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *books* crate version *0.1.6+20150401*, where *20150401* is the exact revision of the *books:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *books* *v1* API can be found at the [official documentation site](https://developers.google.com/books/docs/v1/getting_started). @@ -134,14 +134,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/books1/src/cmn.rs b/gen/books1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/books1/src/cmn.rs +++ b/gen/books1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option, + location: Option +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option, _: Option) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec]) -> Option { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/books1/src/lib.rs b/gen/books1/src/lib.rs index 7f675a05dd..3246c9ce23 100644 --- a/gen/books1/src/lib.rs +++ b/gen/books1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *books* crate version *0.1.5+20150401*, where *20150401* is the exact revision of the *books:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *books* crate version *0.1.6+20150401*, where *20150401* is the exact revision of the *books:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *books* *v1* API can be found at the //! [official documentation site](https://developers.google.com/books/docs/v1/getting_started). @@ -135,14 +135,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -230,7 +231,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -316,14 +317,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -344,7 +346,7 @@ impl<'a, C, A> Books Books { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -377,7 +379,7 @@ impl<'a, C, A> Books } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -2873,10 +2875,10 @@ impl<'a, C, A> MyconfigMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn update_user_settings(&self, request: &Usersettings) -> MyconfigUpdateUserSettingCall<'a, C, A> { + pub fn update_user_settings(&self, request: Usersettings) -> MyconfigUpdateUserSettingCall<'a, C, A> { MyconfigUpdateUserSettingCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3053,10 +3055,10 @@ impl<'a, C, A> MylibraryMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn annotations_insert(&self, request: &Annotation) -> MylibraryAnnotationInsertCall<'a, C, A> { + pub fn annotations_insert(&self, request: Annotation) -> MylibraryAnnotationInsertCall<'a, C, A> { MylibraryAnnotationInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _source: Default::default(), _show_only_summary_in_response: Default::default(), _country: Default::default(), @@ -3117,10 +3119,10 @@ impl<'a, C, A> MylibraryMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `annotationId` - The ID for the annotation to update. - pub fn annotations_update(&self, request: &Annotation, annotation_id: &str) -> MylibraryAnnotationUpdateCall<'a, C, A> { + pub fn annotations_update(&self, request: Annotation, annotation_id: &str) -> MylibraryAnnotationUpdateCall<'a, C, A> { MylibraryAnnotationUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _annotation_id: annotation_id.to_string(), _source: Default::default(), _delegate: Default::default(), @@ -3268,10 +3270,10 @@ impl<'a, C, A> CloudloadingMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn update_book(&self, request: &BooksCloudloadingResource) -> CloudloadingUpdateBookCall<'a, C, A> { + pub fn update_book(&self, request: BooksCloudloadingResource) -> CloudloadingUpdateBookCall<'a, C, A> { CloudloadingUpdateBookCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3485,12 +3487,17 @@ impl<'a, C, A> LayerAnnotationDataGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3499,7 +3506,7 @@ impl<'a, C, A> LayerAnnotationDataGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3805,12 +3812,17 @@ impl<'a, C, A> LayerVolumeAnnotationGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3819,7 +3831,7 @@ impl<'a, C, A> LayerVolumeAnnotationGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4093,12 +4105,17 @@ impl<'a, C, A> LayerListCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4107,7 +4124,7 @@ impl<'a, C, A> LayerListCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4367,12 +4384,17 @@ impl<'a, C, A> LayerGetCall<'a, C, A> where C: BorrowMut, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4381,7 +4403,7 @@ impl<'a, C, A> LayerGetCall<'a, C, A> where C: BorrowMut, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4689,12 +4711,17 @@ impl<'a, C, A> LayerVolumeAnnotationListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4703,7 +4730,7 @@ impl<'a, C, A> LayerVolumeAnnotationListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5085,12 +5112,17 @@ impl<'a, C, A> LayerAnnotationDataListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5099,7 +5131,7 @@ impl<'a, C, A> LayerAnnotationDataListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5398,12 +5430,17 @@ impl<'a, C, A> VolumeRecommendedRateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5412,7 +5449,7 @@ impl<'a, C, A> VolumeRecommendedRateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5668,12 +5705,17 @@ impl<'a, C, A> VolumeMybookListCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5682,7 +5724,7 @@ impl<'a, C, A> VolumeMybookListCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5972,12 +6014,17 @@ impl<'a, C, A> VolumeListCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5986,7 +6033,7 @@ impl<'a, C, A> VolumeListCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6302,12 +6349,17 @@ impl<'a, C, A> VolumeUseruploadedListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6316,7 +6368,7 @@ impl<'a, C, A> VolumeUseruploadedListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6585,12 +6637,17 @@ impl<'a, C, A> VolumeAssociatedListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6599,7 +6656,7 @@ impl<'a, C, A> VolumeAssociatedListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6865,12 +6922,17 @@ impl<'a, C, A> VolumeGetCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6879,7 +6941,7 @@ impl<'a, C, A> VolumeGetCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7117,12 +7179,17 @@ impl<'a, C, A> VolumeRecommendedListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7131,7 +7198,7 @@ impl<'a, C, A> VolumeRecommendedListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7331,12 +7398,17 @@ impl<'a, C, A> DictionaryListOfflineMetadataCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7345,7 +7417,7 @@ impl<'a, C, A> DictionaryListOfflineMetadataCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7587,12 +7659,17 @@ impl<'a, C, A> BookshelveVolumeListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7601,7 +7678,7 @@ impl<'a, C, A> BookshelveVolumeListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7864,12 +7941,17 @@ impl<'a, C, A> BookshelveListCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7878,7 +7960,7 @@ impl<'a, C, A> BookshelveListCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8112,12 +8194,17 @@ impl<'a, C, A> BookshelveGetCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8126,7 +8213,7 @@ impl<'a, C, A> BookshelveGetCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8376,12 +8463,17 @@ impl<'a, C, A> PromoofferAcceptCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -8653,12 +8745,17 @@ impl<'a, C, A> PromoofferDismisCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -8920,12 +9017,17 @@ impl<'a, C, A> PromoofferGetCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8934,7 +9036,7 @@ impl<'a, C, A> PromoofferGetCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9165,12 +9267,17 @@ impl<'a, C, A> OnboardingListCategoryCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9179,7 +9286,7 @@ impl<'a, C, A> OnboardingListCategoryCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9394,12 +9501,17 @@ impl<'a, C, A> OnboardingListCategoryVolumeCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9408,7 +9520,7 @@ impl<'a, C, A> OnboardingListCategoryVolumeCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9639,12 +9751,17 @@ impl<'a, C, A> MyconfigRequestAccesCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9653,7 +9770,7 @@ impl<'a, C, A> MyconfigRequestAccesCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9911,12 +10028,17 @@ impl<'a, C, A> MyconfigReleaseDownloadAccesCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9925,7 +10047,7 @@ impl<'a, C, A> MyconfigReleaseDownloadAccesCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10178,12 +10300,17 @@ impl<'a, C, A> MyconfigSyncVolumeLicenseCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10192,7 +10319,7 @@ impl<'a, C, A> MyconfigSyncVolumeLicenseCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10436,12 +10563,17 @@ impl<'a, C, A> MyconfigGetUserSettingCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10450,7 +10582,7 @@ impl<'a, C, A> MyconfigGetUserSettingCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10547,7 +10679,7 @@ impl<'a, C, A> MyconfigGetUserSettingCall<'a, C, A> where C: BorrowMut MyconfigUpdateUserSettingCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10663,7 +10800,7 @@ impl<'a, C, A> MyconfigUpdateUserSettingCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10681,8 +10818,8 @@ impl<'a, C, A> MyconfigUpdateUserSettingCall<'a, C, A> where C: BorrowMut MyconfigUpdateUserSettingCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Usersettings) -> MyconfigUpdateUserSettingCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -10886,12 +11023,17 @@ impl<'a, C, A> MylibraryBookshelveClearVolumeCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -11125,12 +11267,17 @@ impl<'a, C, A> MylibraryBookshelveMoveVolumeCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -11411,12 +11558,17 @@ impl<'a, C, A> MylibraryBookshelveVolumeListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11425,7 +11577,7 @@ impl<'a, C, A> MylibraryBookshelveVolumeListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11678,12 +11830,17 @@ impl<'a, C, A> MylibraryAnnotationSummaryCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11692,7 +11849,7 @@ impl<'a, C, A> MylibraryAnnotationSummaryCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11927,12 +12084,17 @@ impl<'a, C, A> MylibraryAnnotationDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -12169,12 +12331,17 @@ impl<'a, C, A> MylibraryBookshelveAddVolumeCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -12304,7 +12471,7 @@ impl<'a, C, A> MylibraryBookshelveAddVolumeCall<'a, C, A> where C: BorrowMut MylibraryAnnotationInsertCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12435,7 +12607,7 @@ impl<'a, C, A> MylibraryAnnotationInsertCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12453,8 +12625,8 @@ impl<'a, C, A> MylibraryAnnotationInsertCall<'a, C, A> where C: BorrowMut MylibraryAnnotationInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Annotation) -> MylibraryAnnotationInsertCall<'a, C, A> { + self._request = new_value; self } /// String to identify the originator of this request. @@ -12686,12 +12858,17 @@ impl<'a, C, A> MylibraryBookshelveRemoveVolumeCall<'a, C, A> where C: BorrowMut< if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -12962,12 +13139,17 @@ impl<'a, C, A> MylibraryAnnotationListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12976,7 +13158,7 @@ impl<'a, C, A> MylibraryAnnotationListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13144,7 +13326,7 @@ impl<'a, C, A> MylibraryAnnotationListCall<'a, C, A> where C: BorrowMut MylibraryAnnotationUpdateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13291,7 +13478,7 @@ impl<'a, C, A> MylibraryAnnotationUpdateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13309,8 +13496,8 @@ impl<'a, C, A> MylibraryAnnotationUpdateCall<'a, C, A> where C: BorrowMut MylibraryAnnotationUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Annotation) -> MylibraryAnnotationUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID for the annotation to update. @@ -13550,12 +13737,17 @@ impl<'a, C, A> MylibraryReadingpositionSetPositionCall<'a, C, A> where C: Borrow if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -13827,12 +14019,17 @@ impl<'a, C, A> MylibraryBookshelveGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13841,7 +14038,7 @@ impl<'a, C, A> MylibraryBookshelveGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14047,12 +14244,17 @@ impl<'a, C, A> MylibraryBookshelveListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14061,7 +14263,7 @@ impl<'a, C, A> MylibraryBookshelveListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14288,12 +14490,17 @@ impl<'a, C, A> MylibraryReadingpositionGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14302,7 +14509,7 @@ impl<'a, C, A> MylibraryReadingpositionGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14530,12 +14737,17 @@ impl<'a, C, A> CloudloadingAddBookCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14544,7 +14756,7 @@ impl<'a, C, A> CloudloadingAddBookCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14668,7 +14880,7 @@ impl<'a, C, A> CloudloadingAddBookCall<'a, C, A> where C: BorrowMut CloudloadingUpdateBookCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14784,7 +15001,7 @@ impl<'a, C, A> CloudloadingUpdateBookCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14802,8 +15019,8 @@ impl<'a, C, A> CloudloadingUpdateBookCall<'a, C, A> where C: BorrowMut CloudloadingUpdateBookCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: BooksCloudloadingResource) -> CloudloadingUpdateBookCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -14978,12 +15195,17 @@ impl<'a, C, A> CloudloadingDeleteBookCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; diff --git a/gen/calendar3-cli/Cargo.toml b/gen/calendar3-cli/Cargo.toml index 3c84c3f0ed..777fb9f3dd 100644 --- a/gen/calendar3-cli/Cargo.toml +++ b/gen/calendar3-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-calendar3-cli" -version = "0.0.1+20150326" +version = "0.1.0+20150326" authors = ["Sebastian Thiel "] description = "A complete library to interact with calendar (protocol v3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/calendar3-cli" diff --git a/gen/calendar3-cli/README.md b/gen/calendar3-cli/README.md index e7983d9c71..3f622a7248 100644 --- a/gen/calendar3-cli/README.md +++ b/gen/calendar3-cli/README.md @@ -1,4 +1,138 @@ -# HELLO CALENDAR:V3 + +The `calendar3` command-line interface *(CLI)* allows to use most features of the *Google calendar* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *calendar* API at revision *20150326*. The CLI is at version *0.1.0*. + +```bash + calendar3 [options] acl delete [-p ...] + calendar3 [options] acl get [-p ...] [-o ] + calendar3 [options] acl insert -r ... [-p ...] [-o ] + calendar3 [options] acl list [-p ...] [-o ] + calendar3 [options] acl patch -r ... [-p ...] [-o ] + calendar3 [options] acl update -r ... [-p ...] [-o ] + calendar3 [options] acl watch -r ... [-p ...] [-o ] + calendar3 [options] calendar-list delete [-p ...] + calendar3 [options] calendar-list get [-p ...] [-o ] + calendar3 [options] calendar-list insert -r ... [-p ...] [-o ] + calendar3 [options] calendar-list list [-p ...] [-o ] + calendar3 [options] calendar-list patch -r ... [-p ...] [-o ] + calendar3 [options] calendar-list update -r ... [-p ...] [-o ] + calendar3 [options] calendar-list watch -r ... [-p ...] [-o ] + calendar3 [options] calendars clear [-p ...] + calendar3 [options] calendars delete [-p ...] + calendar3 [options] calendars get [-p ...] [-o ] + calendar3 [options] calendars insert -r ... [-p ...] [-o ] + calendar3 [options] calendars patch -r ... [-p ...] [-o ] + calendar3 [options] calendars update -r ... [-p ...] [-o ] + calendar3 [options] channels stop -r ... [-p ...] + calendar3 [options] colors get [-p ...] [-o ] + calendar3 [options] events delete [-p ...] + calendar3 [options] events get [-p ...] [-o ] + calendar3 [options] events import -r ... [-p ...] [-o ] + calendar3 [options] events insert -r ... [-p ...] [-o ] + calendar3 [options] events instances [-p ...] [-o ] + calendar3 [options] events list [-p ...] [-o ] + calendar3 [options] events move [-p ...] [-o ] + calendar3 [options] events patch -r ... [-p ...] [-o ] + calendar3 [options] events quick-add [-p ...] [-o ] + calendar3 [options] events update -r ... [-p ...] [-o ] + calendar3 [options] events watch -r ... [-p ...] [-o ] + calendar3 [options] freebusy query -r ... [-p ...] [-o ] + calendar3 [options] settings get [-p ...] [-o ] + calendar3 [options] settings list [-p ...] [-o ] + calendar3 [options] settings watch -r ... [-p ...] [-o ] + calendar3 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_calendar3_cli/index.html + +Configuration: + --scope + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `calendar3-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/calendar3-token-.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/calendar3-secret.json`, assuming that the required *calendar* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `calendar3 --debug [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/calendar3-cli/mkdocs.yml b/gen/calendar3-cli/mkdocs.yml index 658196c492..07397ee0ed 100644 --- a/gen/calendar3-cli/mkdocs.yml +++ b/gen/calendar3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: calendar v0.0.1+20150326 +site_name: calendar v0.1.0+20150326 site_url: http://byron.github.io/google-apis-rs/google-calendar3-cli site_description: Write integrating applications with bcore diff --git a/gen/calendar3-cli/src/cmn.rs b/gen/calendar3-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/calendar3-cli/src/cmn.rs +++ b/gen/calendar3-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/calendar3-cli/src/main.rs b/gen/calendar3-cli/src/main.rs index 2664fae3bf..1bbd96128a 100644 --- a/gen/calendar3-cli/src/main.rs +++ b/gen/calendar3-cli/src/main.rs @@ -19,62 +19,63 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - calendar3 [options] acl delete [-p ]... - calendar3 [options] acl get [-p ]... [-o ] - calendar3 [options] acl insert -r ... [-p ]... [-o ] - calendar3 [options] acl list [-p ]... [-o ] - calendar3 [options] acl patch -r ... [-p ]... [-o ] - calendar3 [options] acl update -r ... [-p ]... [-o ] - calendar3 [options] acl watch -r ... [-p ]... [-o ] - calendar3 [options] calendar-list delete [-p ]... - calendar3 [options] calendar-list get [-p ]... [-o ] - calendar3 [options] calendar-list insert -r ... [-p ]... [-o ] - calendar3 [options] calendar-list list [-p ]... [-o ] - calendar3 [options] calendar-list patch -r ... [-p ]... [-o ] - calendar3 [options] calendar-list update -r ... [-p ]... [-o ] - calendar3 [options] calendar-list watch -r ... [-p ]... [-o ] - calendar3 [options] calendars clear [-p ]... - calendar3 [options] calendars delete [-p ]... - calendar3 [options] calendars get [-p ]... [-o ] - calendar3 [options] calendars insert -r ... [-p ]... [-o ] - calendar3 [options] calendars patch -r ... [-p ]... [-o ] - calendar3 [options] calendars update -r ... [-p ]... [-o ] - calendar3 [options] channels stop -r ... [-p ]... - calendar3 [options] colors get [-p ]... [-o ] - calendar3 [options] events delete [-p ]... - calendar3 [options] events get [-p ]... [-o ] - calendar3 [options] events import -r ... [-p ]... [-o ] - calendar3 [options] events insert -r ... [-p ]... [-o ] - calendar3 [options] events instances [-p ]... [-o ] - calendar3 [options] events list [-p ]... [-o ] - calendar3 [options] events move [-p ]... [-o ] - calendar3 [options] events patch -r ... [-p ]... [-o ] - calendar3 [options] events quick-add [-p ]... [-o ] - calendar3 [options] events update -r ... [-p ]... [-o ] - calendar3 [options] events watch -r ... [-p ]... [-o ] - calendar3 [options] freebusy query -r ... [-p ]... [-o ] - calendar3 [options] settings get [-p ]... [-o ] - calendar3 [options] settings list [-p ]... [-o ] - calendar3 [options] settings watch -r ... [-p ]... [-o ] + calendar3 [options] acl delete [-p ...] + calendar3 [options] acl get [-p ...] [-o ] + calendar3 [options] acl insert -r ... [-p ...] [-o ] + calendar3 [options] acl list [-p ...] [-o ] + calendar3 [options] acl patch -r ... [-p ...] [-o ] + calendar3 [options] acl update -r ... [-p ...] [-o ] + calendar3 [options] acl watch -r ... [-p ...] [-o ] + calendar3 [options] calendar-list delete [-p ...] + calendar3 [options] calendar-list get [-p ...] [-o ] + calendar3 [options] calendar-list insert -r ... [-p ...] [-o ] + calendar3 [options] calendar-list list [-p ...] [-o ] + calendar3 [options] calendar-list patch -r ... [-p ...] [-o ] + calendar3 [options] calendar-list update -r ... [-p ...] [-o ] + calendar3 [options] calendar-list watch -r ... [-p ...] [-o ] + calendar3 [options] calendars clear [-p ...] + calendar3 [options] calendars delete [-p ...] + calendar3 [options] calendars get [-p ...] [-o ] + calendar3 [options] calendars insert -r ... [-p ...] [-o ] + calendar3 [options] calendars patch -r ... [-p ...] [-o ] + calendar3 [options] calendars update -r ... [-p ...] [-o ] + calendar3 [options] channels stop -r ... [-p ...] + calendar3 [options] colors get [-p ...] [-o ] + calendar3 [options] events delete [-p ...] + calendar3 [options] events get [-p ...] [-o ] + calendar3 [options] events import -r ... [-p ...] [-o ] + calendar3 [options] events insert -r ... [-p ...] [-o ] + calendar3 [options] events instances [-p ...] [-o ] + calendar3 [options] events list [-p ...] [-o ] + calendar3 [options] events move [-p ...] [-o ] + calendar3 [options] events patch -r ... [-p ...] [-o ] + calendar3 [options] events quick-add [-p ...] [-o ] + calendar3 [options] events update -r ... [-p ...] [-o ] + calendar3 [options] events watch -r ... [-p ...] [-o ] + calendar3 [options] freebusy query -r ... [-p ...] [-o ] + calendar3 [options] settings get [-p ...] [-o ] + calendar3 [options] settings list [-p ...] [-o ] + calendar3 [options] settings watch -r ... [-p ...] [-o ] calendar3 --help -All documentation details can be found TODO: +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_calendar3_cli/index.html Configuration: --scope - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -123,6 +124,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -164,6 +168,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -180,43 +187,30 @@ impl Engine { fn _acl_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::AclRule::default(); - let mut call = self.hub.acl().insert(&request, &self.opt.arg_calendar_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::AclRule::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_scope_init(request: &mut api::AclRule) { if request.scope.is_none() { request.scope = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "scope.type" => { request_scope_init(&mut request); request.scope.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); @@ -242,15 +236,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.acl().insert(request, &self.opt.arg_calendar_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -306,6 +325,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -322,43 +344,30 @@ impl Engine { fn _acl_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::AclRule::default(); - let mut call = self.hub.acl().patch(&request, &self.opt.arg_calendar_id, &self.opt.arg_rule_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::AclRule::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_scope_init(request: &mut api::AclRule) { if request.scope.is_none() { request.scope = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "scope.type" => { request_scope_init(&mut request); request.scope.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); @@ -384,15 +393,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.acl().patch(request, &self.opt.arg_calendar_id, &self.opt.arg_rule_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -409,43 +443,30 @@ impl Engine { fn _acl_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::AclRule::default(); - let mut call = self.hub.acl().update(&request, &self.opt.arg_calendar_id, &self.opt.arg_rule_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::AclRule::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_scope_init(request: &mut api::AclRule) { if request.scope.is_none() { request.scope = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "scope.type" => { request_scope_init(&mut request); request.scope.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); @@ -471,48 +492,14 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _acl_watch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request = api::Channel::default(); - let mut call = self.hub.acl().watch(&request, &self.opt.arg_calendar_id); + let mut call = self.hub.acl().update(request, &self.opt.arg_calendar_id, &self.opt.arg_rule_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { - "sync-token" => { - call = call.sync_token(value.unwrap_or("")); - }, - "show-deleted" => { - call = call.show_deleted(arg_from_str(value.unwrap_or("false"), err, "show-deleted", "boolean")); - }, - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, "alt" |"fields" |"key" @@ -531,14 +518,48 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _acl_watch(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option { - let mut field_name = FieldCursor::default(); + let mut request = api::Channel::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "resource-uri" => { request.resource_uri = Some(value.unwrap_or("").to_string()); }, @@ -574,15 +595,52 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.acl().watch(request, &self.opt.arg_calendar_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "sync-token" => { + call = call.sync_token(value.unwrap_or("")); + }, + "show-deleted" => { + call = call.show_deleted(arg_from_str(value.unwrap_or("false"), err, "show-deleted", "boolean")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -626,6 +684,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -667,6 +728,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -683,40 +747,24 @@ impl Engine { fn _calendar_list_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::CalendarListEntry::default(); - let mut call = self.hub.calendar_list().insert(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "color-rgb-format" => { - call = call.color_rgb_format(arg_from_str(value.unwrap_or("false"), err, "color-rgb-format", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::CalendarListEntry::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -766,15 +814,43 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.calendar_list().insert(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "color-rgb-format" => { + call = call.color_rgb_format(arg_from_str(value.unwrap_or("false"), err, "color-rgb-format", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -836,6 +912,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -852,40 +931,24 @@ impl Engine { fn _calendar_list_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::CalendarListEntry::default(); - let mut call = self.hub.calendar_list().patch(&request, &self.opt.arg_calendar_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "color-rgb-format" => { - call = call.color_rgb_format(arg_from_str(value.unwrap_or("false"), err, "color-rgb-format", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::CalendarListEntry::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -935,15 +998,43 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.calendar_list().patch(request, &self.opt.arg_calendar_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "color-rgb-format" => { + call = call.color_rgb_format(arg_from_str(value.unwrap_or("false"), err, "color-rgb-format", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -960,40 +1051,24 @@ impl Engine { fn _calendar_list_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::CalendarListEntry::default(); - let mut call = self.hub.calendar_list().update(&request, &self.opt.arg_calendar_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "color-rgb-format" => { - call = call.color_rgb_format(arg_from_str(value.unwrap_or("false"), err, "color-rgb-format", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::CalendarListEntry::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1043,15 +1118,43 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.calendar_list().update(request, &self.opt.arg_calendar_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "color-rgb-format" => { + call = call.color_rgb_format(arg_from_str(value.unwrap_or("false"), err, "color-rgb-format", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1068,8 +1171,64 @@ impl Engine { fn _calendar_list_watch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Channel::default(); - let mut call = self.hub.calendar_list().watch(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "resource-uri" => { + request.resource_uri = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "resource-id" => { + request.resource_id = Some(value.unwrap_or("").to_string()); + }, + "payload" => { + request.payload = Some(arg_from_str(value.unwrap_or("false"), err, "payload", "boolean")); + }, + "token" => { + request.token = Some(value.unwrap_or("").to_string()); + }, + "params" => { + if request.params.is_none() { + request.params = Some(Default::default()); + } + let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); + request.params.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); + }, + "expiration" => { + request.expiration = Some(value.unwrap_or("").to_string()); + }, + "address" => { + request.address = Some(value.unwrap_or("").to_string()); + }, + "type" => { + request.type_ = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.calendar_list().watch(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1109,58 +1268,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "resource-uri" => { - request.resource_uri = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "resource-id" => { - request.resource_id = Some(value.unwrap_or("").to_string()); - }, - "payload" => { - request.payload = Some(arg_from_str(value.unwrap_or("false"), err, "payload", "boolean")); - }, - "token" => { - request.token = Some(value.unwrap_or("").to_string()); - }, - "params" => { - if request.params.is_none() { - request.params = Some(Default::default()); - } - let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); - request.params.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); - }, - "expiration" => { - request.expiration = Some(value.unwrap_or("").to_string()); - }, - "address" => { - request.address = Some(value.unwrap_or("").to_string()); - }, - "type" => { - request.type_ = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1204,6 +1319,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1245,6 +1363,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1286,6 +1407,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1302,37 +1426,24 @@ impl Engine { fn _calendars_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Calendar::default(); - let mut call = self.hub.calendars().insert(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Calendar::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1355,15 +1466,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.calendars().insert(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1380,37 +1516,24 @@ impl Engine { fn _calendars_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Calendar::default(); - let mut call = self.hub.calendars().patch(&request, &self.opt.arg_calendar_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Calendar::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1433,15 +1556,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.calendars().patch(request, &self.opt.arg_calendar_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1458,37 +1606,24 @@ impl Engine { fn _calendars_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Calendar::default(); - let mut call = self.hub.calendars().update(&request, &self.opt.arg_calendar_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Calendar::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1511,33 +1646,11 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _channels_stop(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request = api::Channel::default(); - let mut call = self.hub.channels().stop(&request); + let mut call = self.hub.calendars().update(request, &self.opt.arg_calendar_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1559,14 +1672,48 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _channels_stop(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option { - let mut field_name = FieldCursor::default(); + let mut request = api::Channel::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "resource-uri" => { request.resource_uri = Some(value.unwrap_or("").to_string()); }, @@ -1602,15 +1749,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.channels().stop(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1652,6 +1824,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1698,6 +1873,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1748,6 +1926,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1764,36 +1945,23 @@ impl Engine { fn _events_import(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Event::default(); - let mut call = self.hub.events().import(&request, &self.opt.arg_calendar_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Event::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_creator_init(request: &mut api::Event) { if request.creator.is_none() { request.creator = Some(Default::default()); @@ -1848,7 +2016,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "extended-properties.shared" => { request_extended_properties_init(&mut request); if request.extended_properties.as_mut().unwrap().shared.is_none() { @@ -2089,15 +2257,40 @@ impl Engine { request.private_copy = Some(arg_from_str(value.unwrap_or("false"), err, "private-copy", "boolean")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.events().import(request, &self.opt.arg_calendar_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2114,8 +2307,323 @@ impl Engine { fn _events_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Event::default(); - let mut call = self.hub.events().insert(&request, &self.opt.arg_calendar_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + fn request_creator_init(request: &mut api::Event) { + if request.creator.is_none() { + request.creator = Some(Default::default()); + } + } + + fn request_end_init(request: &mut api::Event) { + if request.end.is_none() { + request.end = Some(Default::default()); + } + } + + fn request_extended_properties_init(request: &mut api::Event) { + if request.extended_properties.is_none() { + request.extended_properties = Some(Default::default()); + } + } + + fn request_gadget_init(request: &mut api::Event) { + if request.gadget.is_none() { + request.gadget = Some(Default::default()); + } + } + + fn request_organizer_init(request: &mut api::Event) { + if request.organizer.is_none() { + request.organizer = Some(Default::default()); + } + } + + fn request_original_start_time_init(request: &mut api::Event) { + if request.original_start_time.is_none() { + request.original_start_time = Some(Default::default()); + } + } + + fn request_reminders_init(request: &mut api::Event) { + if request.reminders.is_none() { + request.reminders = Some(Default::default()); + } + } + + fn request_source_init(request: &mut api::Event) { + if request.source.is_none() { + request.source = Some(Default::default()); + } + } + + fn request_start_init(request: &mut api::Event) { + if request.start.is_none() { + request.start = Some(Default::default()); + } + } + + match &temp_cursor.to_string()[..] { + "extended-properties.shared" => { + request_extended_properties_init(&mut request); + if request.extended_properties.as_mut().unwrap().shared.is_none() { + request.extended_properties.as_mut().unwrap().shared = Some(Default::default()); + } + let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); + request.extended_properties.as_mut().unwrap().shared.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); + }, + "extended-properties.private" => { + request_extended_properties_init(&mut request); + if request.extended_properties.as_mut().unwrap().private.is_none() { + request.extended_properties.as_mut().unwrap().private = Some(Default::default()); + } + let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); + request.extended_properties.as_mut().unwrap().private.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); + }, + "creator.self" => { + request_creator_init(&mut request); + request.creator.as_mut().unwrap().self_ = Some(arg_from_str(value.unwrap_or("false"), err, "creator.self", "boolean")); + }, + "creator.display-name" => { + request_creator_init(&mut request); + request.creator.as_mut().unwrap().display_name = Some(value.unwrap_or("").to_string()); + }, + "creator.email" => { + request_creator_init(&mut request); + request.creator.as_mut().unwrap().email = Some(value.unwrap_or("").to_string()); + }, + "creator.id" => { + request_creator_init(&mut request); + request.creator.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); + }, + "organizer.self" => { + request_organizer_init(&mut request); + request.organizer.as_mut().unwrap().self_ = Some(arg_from_str(value.unwrap_or("false"), err, "organizer.self", "boolean")); + }, + "organizer.display-name" => { + request_organizer_init(&mut request); + request.organizer.as_mut().unwrap().display_name = Some(value.unwrap_or("").to_string()); + }, + "organizer.email" => { + request_organizer_init(&mut request); + request.organizer.as_mut().unwrap().email = Some(value.unwrap_or("").to_string()); + }, + "organizer.id" => { + request_organizer_init(&mut request); + request.organizer.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request_organizer_init(&mut request); + request.id = Some(value.unwrap_or("").to_string()); + }, + "hangout-link" => { + request_organizer_init(&mut request); + request.hangout_link = Some(value.unwrap_or("").to_string()); + }, + "end.date" => { + request_end_init(&mut request); + request.end.as_mut().unwrap().date = Some(value.unwrap_or("").to_string()); + }, + "end.time-zone" => { + request_end_init(&mut request); + request.end.as_mut().unwrap().time_zone = Some(value.unwrap_or("").to_string()); + }, + "end.date-time" => { + request_end_init(&mut request); + request.end.as_mut().unwrap().date_time = Some(value.unwrap_or("").to_string()); + }, + "source.url" => { + request_source_init(&mut request); + request.source.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); + }, + "source.title" => { + request_source_init(&mut request); + request.source.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); + }, + "html-link" => { + request_source_init(&mut request); + request.html_link = Some(value.unwrap_or("").to_string()); + }, + "recurrence" => { + request_source_init(&mut request); + if request.recurrence.is_none() { + request.recurrence = Some(Default::default()); + } + request.recurrence.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "start.date" => { + request_start_init(&mut request); + request.start.as_mut().unwrap().date = Some(value.unwrap_or("").to_string()); + }, + "start.time-zone" => { + request_start_init(&mut request); + request.start.as_mut().unwrap().time_zone = Some(value.unwrap_or("").to_string()); + }, + "start.date-time" => { + request_start_init(&mut request); + request.start.as_mut().unwrap().date_time = Some(value.unwrap_or("").to_string()); + }, + "etag" => { + request_start_init(&mut request); + request.etag = Some(value.unwrap_or("").to_string()); + }, + "location" => { + request_start_init(&mut request); + request.location = Some(value.unwrap_or("").to_string()); + }, + "recurring-event-id" => { + request_start_init(&mut request); + request.recurring_event_id = Some(value.unwrap_or("").to_string()); + }, + "original-start-time.date" => { + request_original_start_time_init(&mut request); + request.original_start_time.as_mut().unwrap().date = Some(value.unwrap_or("").to_string()); + }, + "original-start-time.time-zone" => { + request_original_start_time_init(&mut request); + request.original_start_time.as_mut().unwrap().time_zone = Some(value.unwrap_or("").to_string()); + }, + "original-start-time.date-time" => { + request_original_start_time_init(&mut request); + request.original_start_time.as_mut().unwrap().date_time = Some(value.unwrap_or("").to_string()); + }, + "status" => { + request_original_start_time_init(&mut request); + request.status = Some(value.unwrap_or("").to_string()); + }, + "updated" => { + request_original_start_time_init(&mut request); + request.updated = Some(value.unwrap_or("").to_string()); + }, + "description" => { + request_original_start_time_init(&mut request); + request.description = Some(value.unwrap_or("").to_string()); + }, + "i-cal-uid" => { + request_original_start_time_init(&mut request); + request.i_cal_uid = Some(value.unwrap_or("").to_string()); + }, + "gadget.preferences" => { + request_gadget_init(&mut request); + if request.gadget.as_mut().unwrap().preferences.is_none() { + request.gadget.as_mut().unwrap().preferences = Some(Default::default()); + } + let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); + request.gadget.as_mut().unwrap().preferences.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); + }, + "gadget.title" => { + request_gadget_init(&mut request); + request.gadget.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); + }, + "gadget.height" => { + request_gadget_init(&mut request); + request.gadget.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "gadget.height", "integer")); + }, + "gadget.width" => { + request_gadget_init(&mut request); + request.gadget.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "gadget.width", "integer")); + }, + "gadget.link" => { + request_gadget_init(&mut request); + request.gadget.as_mut().unwrap().link = Some(value.unwrap_or("").to_string()); + }, + "gadget.type" => { + request_gadget_init(&mut request); + request.gadget.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); + }, + "gadget.display" => { + request_gadget_init(&mut request); + request.gadget.as_mut().unwrap().display = Some(value.unwrap_or("").to_string()); + }, + "gadget.icon-link" => { + request_gadget_init(&mut request); + request.gadget.as_mut().unwrap().icon_link = Some(value.unwrap_or("").to_string()); + }, + "end-time-unspecified" => { + request_gadget_init(&mut request); + request.end_time_unspecified = Some(arg_from_str(value.unwrap_or("false"), err, "end-time-unspecified", "boolean")); + }, + "sequence" => { + request_gadget_init(&mut request); + request.sequence = Some(arg_from_str(value.unwrap_or("-0"), err, "sequence", "integer")); + }, + "visibility" => { + request_gadget_init(&mut request); + request.visibility = Some(value.unwrap_or("").to_string()); + }, + "guests-can-modify" => { + request_gadget_init(&mut request); + request.guests_can_modify = Some(arg_from_str(value.unwrap_or("false"), err, "guests-can-modify", "boolean")); + }, + "attendees-omitted" => { + request_gadget_init(&mut request); + request.attendees_omitted = Some(arg_from_str(value.unwrap_or("false"), err, "attendees-omitted", "boolean")); + }, + "kind" => { + request_gadget_init(&mut request); + request.kind = Some(value.unwrap_or("").to_string()); + }, + "locked" => { + request_gadget_init(&mut request); + request.locked = Some(arg_from_str(value.unwrap_or("false"), err, "locked", "boolean")); + }, + "created" => { + request_gadget_init(&mut request); + request.created = Some(value.unwrap_or("").to_string()); + }, + "color-id" => { + request_gadget_init(&mut request); + request.color_id = Some(value.unwrap_or("").to_string()); + }, + "anyone-can-add-self" => { + request_gadget_init(&mut request); + request.anyone_can_add_self = Some(arg_from_str(value.unwrap_or("false"), err, "anyone-can-add-self", "boolean")); + }, + "reminders.use-default" => { + request_reminders_init(&mut request); + request.reminders.as_mut().unwrap().use_default = Some(arg_from_str(value.unwrap_or("false"), err, "reminders.use-default", "boolean")); + }, + "guests-can-see-other-guests" => { + request_reminders_init(&mut request); + request.guests_can_see_other_guests = Some(arg_from_str(value.unwrap_or("false"), err, "guests-can-see-other-guests", "boolean")); + }, + "summary" => { + request_reminders_init(&mut request); + request.summary = Some(value.unwrap_or("").to_string()); + }, + "guests-can-invite-others" => { + request_reminders_init(&mut request); + request.guests_can_invite_others = Some(arg_from_str(value.unwrap_or("false"), err, "guests-can-invite-others", "boolean")); + }, + "transparency" => { + request_reminders_init(&mut request); + request.transparency = Some(value.unwrap_or("").to_string()); + }, + "private-copy" => { + request_reminders_init(&mut request); + request.private_copy = Some(arg_from_str(value.unwrap_or("false"), err, "private-copy", "boolean")); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.events().insert(request, &self.opt.arg_calendar_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2143,317 +2651,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_creator_init(request: &mut api::Event) { - if request.creator.is_none() { - request.creator = Some(Default::default()); - } - } - - fn request_end_init(request: &mut api::Event) { - if request.end.is_none() { - request.end = Some(Default::default()); - } - } - - fn request_extended_properties_init(request: &mut api::Event) { - if request.extended_properties.is_none() { - request.extended_properties = Some(Default::default()); - } - } - - fn request_gadget_init(request: &mut api::Event) { - if request.gadget.is_none() { - request.gadget = Some(Default::default()); - } - } - - fn request_organizer_init(request: &mut api::Event) { - if request.organizer.is_none() { - request.organizer = Some(Default::default()); - } - } - - fn request_original_start_time_init(request: &mut api::Event) { - if request.original_start_time.is_none() { - request.original_start_time = Some(Default::default()); - } - } - - fn request_reminders_init(request: &mut api::Event) { - if request.reminders.is_none() { - request.reminders = Some(Default::default()); - } - } - - fn request_source_init(request: &mut api::Event) { - if request.source.is_none() { - request.source = Some(Default::default()); - } - } - - fn request_start_init(request: &mut api::Event) { - if request.start.is_none() { - request.start = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "extended-properties.shared" => { - request_extended_properties_init(&mut request); - if request.extended_properties.as_mut().unwrap().shared.is_none() { - request.extended_properties.as_mut().unwrap().shared = Some(Default::default()); - } - let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); - request.extended_properties.as_mut().unwrap().shared.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); - }, - "extended-properties.private" => { - request_extended_properties_init(&mut request); - if request.extended_properties.as_mut().unwrap().private.is_none() { - request.extended_properties.as_mut().unwrap().private = Some(Default::default()); - } - let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); - request.extended_properties.as_mut().unwrap().private.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); - }, - "creator.self" => { - request_creator_init(&mut request); - request.creator.as_mut().unwrap().self_ = Some(arg_from_str(value.unwrap_or("false"), err, "creator.self", "boolean")); - }, - "creator.display-name" => { - request_creator_init(&mut request); - request.creator.as_mut().unwrap().display_name = Some(value.unwrap_or("").to_string()); - }, - "creator.email" => { - request_creator_init(&mut request); - request.creator.as_mut().unwrap().email = Some(value.unwrap_or("").to_string()); - }, - "creator.id" => { - request_creator_init(&mut request); - request.creator.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); - }, - "organizer.self" => { - request_organizer_init(&mut request); - request.organizer.as_mut().unwrap().self_ = Some(arg_from_str(value.unwrap_or("false"), err, "organizer.self", "boolean")); - }, - "organizer.display-name" => { - request_organizer_init(&mut request); - request.organizer.as_mut().unwrap().display_name = Some(value.unwrap_or("").to_string()); - }, - "organizer.email" => { - request_organizer_init(&mut request); - request.organizer.as_mut().unwrap().email = Some(value.unwrap_or("").to_string()); - }, - "organizer.id" => { - request_organizer_init(&mut request); - request.organizer.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request_organizer_init(&mut request); - request.id = Some(value.unwrap_or("").to_string()); - }, - "hangout-link" => { - request_organizer_init(&mut request); - request.hangout_link = Some(value.unwrap_or("").to_string()); - }, - "end.date" => { - request_end_init(&mut request); - request.end.as_mut().unwrap().date = Some(value.unwrap_or("").to_string()); - }, - "end.time-zone" => { - request_end_init(&mut request); - request.end.as_mut().unwrap().time_zone = Some(value.unwrap_or("").to_string()); - }, - "end.date-time" => { - request_end_init(&mut request); - request.end.as_mut().unwrap().date_time = Some(value.unwrap_or("").to_string()); - }, - "source.url" => { - request_source_init(&mut request); - request.source.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); - }, - "source.title" => { - request_source_init(&mut request); - request.source.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); - }, - "html-link" => { - request_source_init(&mut request); - request.html_link = Some(value.unwrap_or("").to_string()); - }, - "recurrence" => { - request_source_init(&mut request); - if request.recurrence.is_none() { - request.recurrence = Some(Default::default()); - } - request.recurrence.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "start.date" => { - request_start_init(&mut request); - request.start.as_mut().unwrap().date = Some(value.unwrap_or("").to_string()); - }, - "start.time-zone" => { - request_start_init(&mut request); - request.start.as_mut().unwrap().time_zone = Some(value.unwrap_or("").to_string()); - }, - "start.date-time" => { - request_start_init(&mut request); - request.start.as_mut().unwrap().date_time = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request_start_init(&mut request); - request.etag = Some(value.unwrap_or("").to_string()); - }, - "location" => { - request_start_init(&mut request); - request.location = Some(value.unwrap_or("").to_string()); - }, - "recurring-event-id" => { - request_start_init(&mut request); - request.recurring_event_id = Some(value.unwrap_or("").to_string()); - }, - "original-start-time.date" => { - request_original_start_time_init(&mut request); - request.original_start_time.as_mut().unwrap().date = Some(value.unwrap_or("").to_string()); - }, - "original-start-time.time-zone" => { - request_original_start_time_init(&mut request); - request.original_start_time.as_mut().unwrap().time_zone = Some(value.unwrap_or("").to_string()); - }, - "original-start-time.date-time" => { - request_original_start_time_init(&mut request); - request.original_start_time.as_mut().unwrap().date_time = Some(value.unwrap_or("").to_string()); - }, - "status" => { - request_original_start_time_init(&mut request); - request.status = Some(value.unwrap_or("").to_string()); - }, - "updated" => { - request_original_start_time_init(&mut request); - request.updated = Some(value.unwrap_or("").to_string()); - }, - "description" => { - request_original_start_time_init(&mut request); - request.description = Some(value.unwrap_or("").to_string()); - }, - "i-cal-uid" => { - request_original_start_time_init(&mut request); - request.i_cal_uid = Some(value.unwrap_or("").to_string()); - }, - "gadget.preferences" => { - request_gadget_init(&mut request); - if request.gadget.as_mut().unwrap().preferences.is_none() { - request.gadget.as_mut().unwrap().preferences = Some(Default::default()); - } - let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); - request.gadget.as_mut().unwrap().preferences.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); - }, - "gadget.title" => { - request_gadget_init(&mut request); - request.gadget.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); - }, - "gadget.height" => { - request_gadget_init(&mut request); - request.gadget.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "gadget.height", "integer")); - }, - "gadget.width" => { - request_gadget_init(&mut request); - request.gadget.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "gadget.width", "integer")); - }, - "gadget.link" => { - request_gadget_init(&mut request); - request.gadget.as_mut().unwrap().link = Some(value.unwrap_or("").to_string()); - }, - "gadget.type" => { - request_gadget_init(&mut request); - request.gadget.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); - }, - "gadget.display" => { - request_gadget_init(&mut request); - request.gadget.as_mut().unwrap().display = Some(value.unwrap_or("").to_string()); - }, - "gadget.icon-link" => { - request_gadget_init(&mut request); - request.gadget.as_mut().unwrap().icon_link = Some(value.unwrap_or("").to_string()); - }, - "end-time-unspecified" => { - request_gadget_init(&mut request); - request.end_time_unspecified = Some(arg_from_str(value.unwrap_or("false"), err, "end-time-unspecified", "boolean")); - }, - "sequence" => { - request_gadget_init(&mut request); - request.sequence = Some(arg_from_str(value.unwrap_or("-0"), err, "sequence", "integer")); - }, - "visibility" => { - request_gadget_init(&mut request); - request.visibility = Some(value.unwrap_or("").to_string()); - }, - "guests-can-modify" => { - request_gadget_init(&mut request); - request.guests_can_modify = Some(arg_from_str(value.unwrap_or("false"), err, "guests-can-modify", "boolean")); - }, - "attendees-omitted" => { - request_gadget_init(&mut request); - request.attendees_omitted = Some(arg_from_str(value.unwrap_or("false"), err, "attendees-omitted", "boolean")); - }, - "kind" => { - request_gadget_init(&mut request); - request.kind = Some(value.unwrap_or("").to_string()); - }, - "locked" => { - request_gadget_init(&mut request); - request.locked = Some(arg_from_str(value.unwrap_or("false"), err, "locked", "boolean")); - }, - "created" => { - request_gadget_init(&mut request); - request.created = Some(value.unwrap_or("").to_string()); - }, - "color-id" => { - request_gadget_init(&mut request); - request.color_id = Some(value.unwrap_or("").to_string()); - }, - "anyone-can-add-self" => { - request_gadget_init(&mut request); - request.anyone_can_add_self = Some(arg_from_str(value.unwrap_or("false"), err, "anyone-can-add-self", "boolean")); - }, - "reminders.use-default" => { - request_reminders_init(&mut request); - request.reminders.as_mut().unwrap().use_default = Some(arg_from_str(value.unwrap_or("false"), err, "reminders.use-default", "boolean")); - }, - "guests-can-see-other-guests" => { - request_reminders_init(&mut request); - request.guests_can_see_other_guests = Some(arg_from_str(value.unwrap_or("false"), err, "guests-can-see-other-guests", "boolean")); - }, - "summary" => { - request_reminders_init(&mut request); - request.summary = Some(value.unwrap_or("").to_string()); - }, - "guests-can-invite-others" => { - request_reminders_init(&mut request); - request.guests_can_invite_others = Some(arg_from_str(value.unwrap_or("false"), err, "guests-can-invite-others", "boolean")); - }, - "transparency" => { - request_reminders_init(&mut request); - request.transparency = Some(value.unwrap_or("").to_string()); - }, - "private-copy" => { - request_reminders_init(&mut request); - request.private_copy = Some(arg_from_str(value.unwrap_or("false"), err, "private-copy", "boolean")); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2524,6 +2729,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2618,6 +2826,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2664,6 +2875,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2680,45 +2894,23 @@ impl Engine { fn _events_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Event::default(); - let mut call = self.hub.events().patch(&request, &self.opt.arg_calendar_id, &self.opt.arg_event_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "send-notifications" => { - call = call.send_notifications(arg_from_str(value.unwrap_or("false"), err, "send-notifications", "boolean")); - }, - "max-attendees" => { - call = call.max_attendees(arg_from_str(value.unwrap_or("-0"), err, "max-attendees", "integer")); - }, - "always-include-email" => { - call = call.always_include_email(arg_from_str(value.unwrap_or("false"), err, "always-include-email", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Event::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_creator_init(request: &mut api::Event) { if request.creator.is_none() { request.creator = Some(Default::default()); @@ -2773,7 +2965,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "extended-properties.shared" => { request_extended_properties_init(&mut request); if request.extended_properties.as_mut().unwrap().shared.is_none() { @@ -3014,15 +3206,49 @@ impl Engine { request.private_copy = Some(arg_from_str(value.unwrap_or("false"), err, "private-copy", "boolean")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.events().patch(request, &self.opt.arg_calendar_id, &self.opt.arg_event_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "send-notifications" => { + call = call.send_notifications(arg_from_str(value.unwrap_or("false"), err, "send-notifications", "boolean")); + }, + "max-attendees" => { + call = call.max_attendees(arg_from_str(value.unwrap_or("-0"), err, "max-attendees", "integer")); + }, + "always-include-email" => { + call = call.always_include_email(arg_from_str(value.unwrap_or("false"), err, "always-include-email", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3069,6 +3295,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3085,45 +3314,23 @@ impl Engine { fn _events_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Event::default(); - let mut call = self.hub.events().update(&request, &self.opt.arg_calendar_id, &self.opt.arg_event_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "send-notifications" => { - call = call.send_notifications(arg_from_str(value.unwrap_or("false"), err, "send-notifications", "boolean")); - }, - "max-attendees" => { - call = call.max_attendees(arg_from_str(value.unwrap_or("-0"), err, "max-attendees", "integer")); - }, - "always-include-email" => { - call = call.always_include_email(arg_from_str(value.unwrap_or("false"), err, "always-include-email", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Event::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_creator_init(request: &mut api::Event) { if request.creator.is_none() { request.creator = Some(Default::default()); @@ -3178,7 +3385,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "extended-properties.shared" => { request_extended_properties_init(&mut request); if request.extended_properties.as_mut().unwrap().shared.is_none() { @@ -3419,15 +3626,49 @@ impl Engine { request.private_copy = Some(arg_from_str(value.unwrap_or("false"), err, "private-copy", "boolean")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.events().update(request, &self.opt.arg_calendar_id, &self.opt.arg_event_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "send-notifications" => { + call = call.send_notifications(arg_from_str(value.unwrap_or("false"), err, "send-notifications", "boolean")); + }, + "max-attendees" => { + call = call.max_attendees(arg_from_str(value.unwrap_or("-0"), err, "max-attendees", "integer")); + }, + "always-include-email" => { + call = call.always_include_email(arg_from_str(value.unwrap_or("false"), err, "always-include-email", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3444,8 +3685,64 @@ impl Engine { fn _events_watch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Channel::default(); - let mut call = self.hub.events().watch(&request, &self.opt.arg_calendar_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "resource-uri" => { + request.resource_uri = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "resource-id" => { + request.resource_id = Some(value.unwrap_or("").to_string()); + }, + "payload" => { + request.payload = Some(arg_from_str(value.unwrap_or("false"), err, "payload", "boolean")); + }, + "token" => { + request.token = Some(value.unwrap_or("").to_string()); + }, + "params" => { + if request.params.is_none() { + request.params = Some(Default::default()); + } + let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); + request.params.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); + }, + "expiration" => { + request.expiration = Some(value.unwrap_or("").to_string()); + }, + "address" => { + request.address = Some(value.unwrap_or("").to_string()); + }, + "type" => { + request.type_ = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.events().watch(request, &self.opt.arg_calendar_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -3518,58 +3815,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "resource-uri" => { - request.resource_uri = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "resource-id" => { - request.resource_id = Some(value.unwrap_or("").to_string()); - }, - "payload" => { - request.payload = Some(arg_from_str(value.unwrap_or("false"), err, "payload", "boolean")); - }, - "token" => { - request.token = Some(value.unwrap_or("").to_string()); - }, - "params" => { - if request.params.is_none() { - request.params = Some(Default::default()); - } - let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); - request.params.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); - }, - "expiration" => { - request.expiration = Some(value.unwrap_or("").to_string()); - }, - "address" => { - request.address = Some(value.unwrap_or("").to_string()); - }, - "type" => { - request.type_ = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3586,8 +3839,45 @@ impl Engine { fn _freebusy_query(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::FreeBusyRequest::default(); - let mut call = self.hub.freebusy().query(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "time-max" => { + request.time_max = Some(value.unwrap_or("").to_string()); + }, + "calendar-expansion-max" => { + request.calendar_expansion_max = Some(arg_from_str(value.unwrap_or("-0"), err, "calendar-expansion-max", "integer")); + }, + "time-zone" => { + request.time_zone = Some(value.unwrap_or("").to_string()); + }, + "time-min" => { + request.time_min = Some(value.unwrap_or("").to_string()); + }, + "group-expansion-max" => { + request.group_expansion_max = Some(arg_from_str(value.unwrap_or("-0"), err, "group-expansion-max", "integer")); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.freebusy().query(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -3609,39 +3899,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "time-max" => { - request.time_max = Some(value.unwrap_or("").to_string()); - }, - "calendar-expansion-max" => { - request.calendar_expansion_max = Some(arg_from_str(value.unwrap_or("-0"), err, "calendar-expansion-max", "integer")); - }, - "time-zone" => { - request.time_zone = Some(value.unwrap_or("").to_string()); - }, - "time-min" => { - request.time_min = Some(value.unwrap_or("").to_string()); - }, - "group-expansion-max" => { - request.group_expansion_max = Some(arg_from_str(value.unwrap_or("-0"), err, "group-expansion-max", "integer")); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3685,6 +3950,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3737,6 +4005,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3753,46 +4024,24 @@ impl Engine { fn _settings_watch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Channel::default(); - let mut call = self.hub.settings().watch(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "sync-token" => { - call = call.sync_token(value.unwrap_or("")); - }, - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Channel::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "resource-uri" => { request.resource_uri = Some(value.unwrap_or("").to_string()); }, @@ -3828,15 +4077,49 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.settings().watch(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "sync-token" => { + call = call.sync_token(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4037,6 +4320,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -4044,8 +4328,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/calendar3/Cargo.toml b/gen/calendar3/Cargo.toml index f198c8b8e8..e8eab7f2e7 100644 --- a/gen/calendar3/Cargo.toml +++ b/gen/calendar3/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-calendar3" -version = "0.1.5+20150326" +version = "0.1.6+20150326" authors = ["Sebastian Thiel "] description = "A complete library to interact with calendar (protocol v3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/calendar3" diff --git a/gen/calendar3/README.md b/gen/calendar3/README.md index 292a927f4f..00075fd0b6 100644 --- a/gen/calendar3/README.md +++ b/gen/calendar3/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-calendar3` library allows access to all features of the *Google calendar* service. -This documentation was generated from *calendar* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *calendar:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *calendar* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *calendar:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *calendar* *v3* API can be found at the [official documentation site](https://developers.google.com/google-apps/calendar/firstapp). @@ -134,7 +134,7 @@ let mut req = Channel::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.events().watch(&req, "calendarId") +let result = hub.events().watch(req, "calendarId") .updated_min("sit") .time_zone("Stet") .time_min("sed") @@ -158,14 +158,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/calendar3/src/cmn.rs b/gen/calendar3/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/calendar3/src/cmn.rs +++ b/gen/calendar3/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option, + location: Option +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option, _: Option) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec]) -> Option { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/calendar3/src/lib.rs b/gen/calendar3/src/lib.rs index 0481846a8d..98efc85d5c 100644 --- a/gen/calendar3/src/lib.rs +++ b/gen/calendar3/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *calendar* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *calendar:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *calendar* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *calendar:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *calendar* *v3* API can be found at the //! [official documentation site](https://developers.google.com/google-apps/calendar/firstapp). @@ -135,7 +135,7 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.events().watch(&req, "calendarId") +//! let result = hub.events().watch(req, "calendarId") //! .updated_min("ea") //! .time_zone("no") //! .time_min("justo") @@ -159,14 +159,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -254,7 +255,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -331,7 +332,7 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.events().watch(&req, "calendarId") +/// let result = hub.events().watch(req, "calendarId") /// .updated_min("eirmod") /// .time_zone("elitr") /// .time_min("amet") @@ -355,14 +356,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -383,7 +385,7 @@ impl<'a, C, A> CalendarHub CalendarHub { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -413,7 +415,7 @@ impl<'a, C, A> CalendarHub } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -1385,10 +1387,10 @@ impl<'a, C, A> FreebusyMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn query(&self, request: &FreeBusyRequest) -> FreebusyQueryCall<'a, C, A> { + pub fn query(&self, request: FreeBusyRequest) -> FreebusyQueryCall<'a, C, A> { FreebusyQueryCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1458,10 +1460,10 @@ impl<'a, C, A> SettingMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn watch(&self, request: &Channel) -> SettingWatchCall<'a, C, A> { + pub fn watch(&self, request: Channel) -> SettingWatchCall<'a, C, A> { SettingWatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _sync_token: Default::default(), _page_token: Default::default(), _max_results: Default::default(), @@ -1537,10 +1539,10 @@ impl<'a, C, A> CalendarListMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `calendarId` - Calendar identifier. - pub fn update(&self, request: &CalendarListEntry, calendar_id: &str) -> CalendarListUpdateCall<'a, C, A> { + pub fn update(&self, request: CalendarListEntry, calendar_id: &str) -> CalendarListUpdateCall<'a, C, A> { CalendarListUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _calendar_id: calendar_id.to_string(), _color_rgb_format: Default::default(), _delegate: Default::default(), @@ -1608,10 +1610,10 @@ impl<'a, C, A> CalendarListMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &CalendarListEntry) -> CalendarListInsertCall<'a, C, A> { + pub fn insert(&self, request: CalendarListEntry) -> CalendarListInsertCall<'a, C, A> { CalendarListInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _color_rgb_format: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -1627,10 +1629,10 @@ impl<'a, C, A> CalendarListMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `calendarId` - Calendar identifier. - pub fn patch(&self, request: &CalendarListEntry, calendar_id: &str) -> CalendarListPatchCall<'a, C, A> { + pub fn patch(&self, request: CalendarListEntry, calendar_id: &str) -> CalendarListPatchCall<'a, C, A> { CalendarListPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _calendar_id: calendar_id.to_string(), _color_rgb_format: Default::default(), _delegate: Default::default(), @@ -1646,10 +1648,10 @@ impl<'a, C, A> CalendarListMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn watch(&self, request: &Channel) -> CalendarListWatchCall<'a, C, A> { + pub fn watch(&self, request: Channel) -> CalendarListWatchCall<'a, C, A> { CalendarListWatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _sync_token: Default::default(), _show_hidden: Default::default(), _show_deleted: Default::default(), @@ -1711,10 +1713,10 @@ impl<'a, C, A> CalendarMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `calendarId` - Calendar identifier. - pub fn patch(&self, request: &Calendar, calendar_id: &str) -> CalendarPatchCall<'a, C, A> { + pub fn patch(&self, request: Calendar, calendar_id: &str) -> CalendarPatchCall<'a, C, A> { CalendarPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _calendar_id: calendar_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1780,10 +1782,10 @@ impl<'a, C, A> CalendarMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &Calendar) -> CalendarInsertCall<'a, C, A> { + pub fn insert(&self, request: Calendar) -> CalendarInsertCall<'a, C, A> { CalendarInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1798,10 +1800,10 @@ impl<'a, C, A> CalendarMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `calendarId` - Calendar identifier. - pub fn update(&self, request: &Calendar, calendar_id: &str) -> CalendarUpdateCall<'a, C, A> { + pub fn update(&self, request: Calendar, calendar_id: &str) -> CalendarUpdateCall<'a, C, A> { CalendarUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _calendar_id: calendar_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1858,10 +1860,10 @@ impl<'a, C, A> AclMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `calendarId` - Calendar identifier. - pub fn watch(&self, request: &Channel, calendar_id: &str) -> AclWatchCall<'a, C, A> { + pub fn watch(&self, request: Channel, calendar_id: &str) -> AclWatchCall<'a, C, A> { AclWatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _calendar_id: calendar_id.to_string(), _sync_token: Default::default(), _show_deleted: Default::default(), @@ -1881,10 +1883,10 @@ impl<'a, C, A> AclMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `calendarId` - Calendar identifier. - pub fn insert(&self, request: &AclRule, calendar_id: &str) -> AclInsertCall<'a, C, A> { + pub fn insert(&self, request: AclRule, calendar_id: &str) -> AclInsertCall<'a, C, A> { AclInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _calendar_id: calendar_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1901,10 +1903,10 @@ impl<'a, C, A> AclMethods<'a, C, A> { /// * `request` - No description provided. /// * `calendarId` - Calendar identifier. /// * `ruleId` - ACL rule identifier. - pub fn update(&self, request: &AclRule, calendar_id: &str, rule_id: &str) -> AclUpdateCall<'a, C, A> { + pub fn update(&self, request: AclRule, calendar_id: &str, rule_id: &str) -> AclUpdateCall<'a, C, A> { AclUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _calendar_id: calendar_id.to_string(), _rule_id: rule_id.to_string(), _delegate: Default::default(), @@ -1922,10 +1924,10 @@ impl<'a, C, A> AclMethods<'a, C, A> { /// * `request` - No description provided. /// * `calendarId` - Calendar identifier. /// * `ruleId` - ACL rule identifier. - pub fn patch(&self, request: &AclRule, calendar_id: &str, rule_id: &str) -> AclPatchCall<'a, C, A> { + pub fn patch(&self, request: AclRule, calendar_id: &str, rule_id: &str) -> AclPatchCall<'a, C, A> { AclPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _calendar_id: calendar_id.to_string(), _rule_id: rule_id.to_string(), _delegate: Default::default(), @@ -2041,10 +2043,10 @@ impl<'a, C, A> ChannelMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn stop(&self, request: &Channel) -> ChannelStopCall<'a, C, A> { + pub fn stop(&self, request: Channel) -> ChannelStopCall<'a, C, A> { ChannelStopCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2173,10 +2175,10 @@ impl<'a, C, A> EventMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `calendarId` - Calendar identifier. - pub fn insert(&self, request: &Event, calendar_id: &str) -> EventInsertCall<'a, C, A> { + pub fn insert(&self, request: Event, calendar_id: &str) -> EventInsertCall<'a, C, A> { EventInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _calendar_id: calendar_id.to_string(), _send_notifications: Default::default(), _max_attendees: Default::default(), @@ -2194,10 +2196,10 @@ impl<'a, C, A> EventMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `calendarId` - Calendar identifier. - pub fn import(&self, request: &Event, calendar_id: &str) -> EventImportCall<'a, C, A> { + pub fn import(&self, request: Event, calendar_id: &str) -> EventImportCall<'a, C, A> { EventImportCall { hub: self.hub, - _request: request.clone(), + _request: request, _calendar_id: calendar_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2298,10 +2300,10 @@ impl<'a, C, A> EventMethods<'a, C, A> { /// * `request` - No description provided. /// * `calendarId` - Calendar identifier. /// * `eventId` - Event identifier. - pub fn patch(&self, request: &Event, calendar_id: &str, event_id: &str) -> EventPatchCall<'a, C, A> { + pub fn patch(&self, request: Event, calendar_id: &str, event_id: &str) -> EventPatchCall<'a, C, A> { EventPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _calendar_id: calendar_id.to_string(), _event_id: event_id.to_string(), _send_notifications: Default::default(), @@ -2344,10 +2346,10 @@ impl<'a, C, A> EventMethods<'a, C, A> { /// * `request` - No description provided. /// * `calendarId` - Calendar identifier. /// * `eventId` - Event identifier. - pub fn update(&self, request: &Event, calendar_id: &str, event_id: &str) -> EventUpdateCall<'a, C, A> { + pub fn update(&self, request: Event, calendar_id: &str, event_id: &str) -> EventUpdateCall<'a, C, A> { EventUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _calendar_id: calendar_id.to_string(), _event_id: event_id.to_string(), _send_notifications: Default::default(), @@ -2367,10 +2369,10 @@ impl<'a, C, A> EventMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `calendarId` - Calendar identifier. - pub fn watch(&self, request: &Channel, calendar_id: &str) -> EventWatchCall<'a, C, A> { + pub fn watch(&self, request: Channel, calendar_id: &str) -> EventWatchCall<'a, C, A> { EventWatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _calendar_id: calendar_id.to_string(), _updated_min: Default::default(), _time_zone: Default::default(), @@ -2456,7 +2458,7 @@ impl<'a, C, A> EventMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.freebusy().query(&req) +/// let result = hub.freebusy().query(req) /// .doit(); /// # } /// ``` @@ -2558,12 +2560,17 @@ impl<'a, C, A> FreebusyQueryCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2572,7 +2579,7 @@ impl<'a, C, A> FreebusyQueryCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2590,8 +2597,8 @@ impl<'a, C, A> FreebusyQueryCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &FreeBusyRequest) -> FreebusyQueryCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: FreeBusyRequest) -> FreebusyQueryCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -2780,12 +2787,17 @@ impl<'a, C, A> SettingListCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2794,7 +2806,7 @@ impl<'a, C, A> SettingListCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2915,7 +2927,7 @@ impl<'a, C, A> SettingListCall<'a, C, A> where C: BorrowMut, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.settings().watch(&req) +/// let result = hub.settings().watch(req) /// .sync_token("consetetur") /// .page_token("ut") /// .max_results(-16) @@ -3032,12 +3044,17 @@ impl<'a, C, A> SettingWatchCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3046,7 +3063,7 @@ impl<'a, C, A> SettingWatchCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3064,8 +3081,8 @@ impl<'a, C, A> SettingWatchCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Channel) -> SettingWatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Channel) -> SettingWatchCall<'a, C, A> { + self._request = new_value; self } /// Token obtained from the nextSyncToken field returned on the last page of results from the previous list request. It makes the result of this list request contain only entries that have changed since then. @@ -3289,12 +3306,17 @@ impl<'a, C, A> SettingGetCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3303,7 +3325,7 @@ impl<'a, C, A> SettingGetCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3410,7 +3432,7 @@ impl<'a, C, A> SettingGetCall<'a, C, A> where C: BorrowMut, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.calendar_list().update(&req, "calendarId") +/// let result = hub.calendar_list().update(req, "calendarId") /// .color_rgb_format(true) /// .doit(); /// # } @@ -3543,12 +3565,17 @@ impl<'a, C, A> CalendarListUpdateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3557,7 +3584,7 @@ impl<'a, C, A> CalendarListUpdateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3575,8 +3602,8 @@ impl<'a, C, A> CalendarListUpdateCall<'a, C, A> where C: BorrowMut CalendarListUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CalendarListEntry) -> CalendarListUpdateCall<'a, C, A> { + self._request = new_value; self } /// Calendar identifier. @@ -3792,12 +3819,17 @@ impl<'a, C, A> CalendarListDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -4016,12 +4048,17 @@ impl<'a, C, A> CalendarListGetCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4030,7 +4067,7 @@ impl<'a, C, A> CalendarListGetCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4254,12 +4291,17 @@ impl<'a, C, A> CalendarListListCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4268,7 +4310,7 @@ impl<'a, C, A> CalendarListListCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4411,7 +4453,7 @@ impl<'a, C, A> CalendarListListCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.calendar_list().insert(&req) +/// let result = hub.calendar_list().insert(req) /// .color_rgb_format(false) /// .doit(); /// # } @@ -4518,12 +4560,17 @@ impl<'a, C, A> CalendarListInsertCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4532,7 +4579,7 @@ impl<'a, C, A> CalendarListInsertCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4550,8 +4597,8 @@ impl<'a, C, A> CalendarListInsertCall<'a, C, A> where C: BorrowMut CalendarListInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CalendarListEntry) -> CalendarListInsertCall<'a, C, A> { + self._request = new_value; self } /// Whether to use the foregroundColor and backgroundColor fields to write the calendar colors (RGB). If this feature is used, the index-based colorId field will be set to the best matching option automatically. Optional. The default is False. @@ -4645,7 +4692,7 @@ impl<'a, C, A> CalendarListInsertCall<'a, C, A> where C: BorrowMut CalendarListPatchCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4792,7 +4844,7 @@ impl<'a, C, A> CalendarListPatchCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4810,8 +4862,8 @@ impl<'a, C, A> CalendarListPatchCall<'a, C, A> where C: BorrowMut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &CalendarListEntry) -> CalendarListPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CalendarListEntry) -> CalendarListPatchCall<'a, C, A> { + self._request = new_value; self } /// Calendar identifier. @@ -4915,7 +4967,7 @@ impl<'a, C, A> CalendarListPatchCall<'a, C, A> where C: BorrowMut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.calendar_list().watch(&req) +/// let result = hub.calendar_list().watch(req) /// .sync_token("rebum.") /// .show_hidden(true) /// .show_deleted(true) @@ -5047,12 +5099,17 @@ impl<'a, C, A> CalendarListWatchCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5061,7 +5118,7 @@ impl<'a, C, A> CalendarListWatchCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5079,8 +5136,8 @@ impl<'a, C, A> CalendarListWatchCall<'a, C, A> where C: BorrowMut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Channel) -> CalendarListWatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Channel) -> CalendarListWatchCall<'a, C, A> { + self._request = new_value; self } /// Token obtained from the nextSyncToken field returned on the last page of results from the previous list request. It makes the result of this list request contain only entries that have changed since then. If only read-only fields such as calendar properties or ACLs have changed, the entry won't be returned. All entries deleted and hidden since the previous list request will always be in the result set and it is not allowed to set showDeleted neither showHidden to False. @@ -5213,7 +5270,7 @@ impl<'a, C, A> CalendarListWatchCall<'a, C, A> where C: BorrowMut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.calendars().patch(&req, "calendarId") +/// let result = hub.calendars().patch(req, "calendarId") /// .doit(); /// # } /// ``` @@ -5341,12 +5398,17 @@ impl<'a, C, A> CalendarPatchCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5355,7 +5417,7 @@ impl<'a, C, A> CalendarPatchCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5373,8 +5435,8 @@ impl<'a, C, A> CalendarPatchCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Calendar) -> CalendarPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Calendar) -> CalendarPatchCall<'a, C, A> { + self._request = new_value; self } /// Calendar identifier. @@ -5583,12 +5645,17 @@ impl<'a, C, A> CalendarDeleteCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -5807,12 +5874,17 @@ impl<'a, C, A> CalendarGetCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5821,7 +5893,7 @@ impl<'a, C, A> CalendarGetCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6040,12 +6112,17 @@ impl<'a, C, A> CalendarClearCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -6151,7 +6228,7 @@ impl<'a, C, A> CalendarClearCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.calendars().insert(&req) +/// let result = hub.calendars().insert(req) /// .doit(); /// # } /// ``` @@ -6253,12 +6330,17 @@ impl<'a, C, A> CalendarInsertCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6267,7 +6349,7 @@ impl<'a, C, A> CalendarInsertCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6285,8 +6367,8 @@ impl<'a, C, A> CalendarInsertCall<'a, C, A> where C: BorrowMut, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Calendar) -> CalendarInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Calendar) -> CalendarInsertCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -6373,7 +6455,7 @@ impl<'a, C, A> CalendarInsertCall<'a, C, A> where C: BorrowMut, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.calendars().update(&req, "calendarId") +/// let result = hub.calendars().update(req, "calendarId") /// .doit(); /// # } /// ``` @@ -6501,12 +6583,17 @@ impl<'a, C, A> CalendarUpdateCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6515,7 +6602,7 @@ impl<'a, C, A> CalendarUpdateCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6533,8 +6620,8 @@ impl<'a, C, A> CalendarUpdateCall<'a, C, A> where C: BorrowMut, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Calendar) -> CalendarUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Calendar) -> CalendarUpdateCall<'a, C, A> { + self._request = new_value; self } /// Calendar identifier. @@ -6631,7 +6718,7 @@ impl<'a, C, A> CalendarUpdateCall<'a, C, A> where C: BorrowMut, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.acl().watch(&req, "calendarId") +/// let result = hub.acl().watch(req, "calendarId") /// .sync_token("clita") /// .show_deleted(true) /// .page_token("takimata") @@ -6779,12 +6866,17 @@ impl<'a, C, A> AclWatchCall<'a, C, A> where C: BorrowMut, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6793,7 +6885,7 @@ impl<'a, C, A> AclWatchCall<'a, C, A> where C: BorrowMut, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6811,8 +6903,8 @@ impl<'a, C, A> AclWatchCall<'a, C, A> where C: BorrowMut, A: oaut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Channel) -> AclWatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Channel) -> AclWatchCall<'a, C, A> { + self._request = new_value; self } /// Calendar identifier. @@ -6940,7 +7032,7 @@ impl<'a, C, A> AclWatchCall<'a, C, A> where C: BorrowMut, A: oaut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.acl().insert(&req, "calendarId") +/// let result = hub.acl().insert(req, "calendarId") /// .doit(); /// # } /// ``` @@ -7068,12 +7160,17 @@ impl<'a, C, A> AclInsertCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7082,7 +7179,7 @@ impl<'a, C, A> AclInsertCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7100,8 +7197,8 @@ impl<'a, C, A> AclInsertCall<'a, C, A> where C: BorrowMut, A: oau /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AclRule) -> AclInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AclRule) -> AclInsertCall<'a, C, A> { + self._request = new_value; self } /// Calendar identifier. @@ -7198,7 +7295,7 @@ impl<'a, C, A> AclInsertCall<'a, C, A> where C: BorrowMut, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.acl().update(&req, "calendarId", "ruleId") +/// let result = hub.acl().update(req, "calendarId", "ruleId") /// .doit(); /// # } /// ``` @@ -7328,12 +7425,17 @@ impl<'a, C, A> AclUpdateCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7342,7 +7444,7 @@ impl<'a, C, A> AclUpdateCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7360,8 +7462,8 @@ impl<'a, C, A> AclUpdateCall<'a, C, A> where C: BorrowMut, A: oau /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AclRule) -> AclUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AclRule) -> AclUpdateCall<'a, C, A> { + self._request = new_value; self } /// Calendar identifier. @@ -7468,7 +7570,7 @@ impl<'a, C, A> AclUpdateCall<'a, C, A> where C: BorrowMut, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.acl().patch(&req, "calendarId", "ruleId") +/// let result = hub.acl().patch(req, "calendarId", "ruleId") /// .doit(); /// # } /// ``` @@ -7598,12 +7700,17 @@ impl<'a, C, A> AclPatchCall<'a, C, A> where C: BorrowMut, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7612,7 +7719,7 @@ impl<'a, C, A> AclPatchCall<'a, C, A> where C: BorrowMut, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7630,8 +7737,8 @@ impl<'a, C, A> AclPatchCall<'a, C, A> where C: BorrowMut, A: oaut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AclRule) -> AclPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AclRule) -> AclPatchCall<'a, C, A> { + self._request = new_value; self } /// Calendar identifier. @@ -7871,12 +7978,17 @@ impl<'a, C, A> AclListCall<'a, C, A> where C: BorrowMut, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7885,7 +7997,7 @@ impl<'a, C, A> AclListCall<'a, C, A> where C: BorrowMut, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8137,12 +8249,17 @@ impl<'a, C, A> AclDeleteCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -8373,12 +8490,17 @@ impl<'a, C, A> AclGetCall<'a, C, A> where C: BorrowMut, A: oauth2 if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8387,7 +8509,7 @@ impl<'a, C, A> AclGetCall<'a, C, A> where C: BorrowMut, A: oauth2 Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8504,7 +8626,7 @@ impl<'a, C, A> AclGetCall<'a, C, A> where C: BorrowMut, A: oauth2 /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.channels().stop(&req) +/// let result = hub.channels().stop(req) /// .doit(); /// # } /// ``` @@ -8605,12 +8727,17 @@ impl<'a, C, A> ChannelStopCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -8627,8 +8754,8 @@ impl<'a, C, A> ChannelStopCall<'a, C, A> where C: BorrowMut, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Channel) -> ChannelStopCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Channel) -> ChannelStopCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -8802,12 +8929,17 @@ impl<'a, C, A> ColorGetCall<'a, C, A> where C: BorrowMut, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8816,7 +8948,7 @@ impl<'a, C, A> ColorGetCall<'a, C, A> where C: BorrowMut, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9032,12 +9164,17 @@ impl<'a, C, A> EventDeleteCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -9160,7 +9297,7 @@ impl<'a, C, A> EventDeleteCall<'a, C, A> where C: BorrowMut, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.events().insert(&req, "calendarId") +/// let result = hub.events().insert(req, "calendarId") /// .send_notifications(true) /// .max_attendees(-62) /// .doit(); @@ -9298,12 +9435,17 @@ impl<'a, C, A> EventInsertCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9312,7 +9454,7 @@ impl<'a, C, A> EventInsertCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9330,8 +9472,8 @@ impl<'a, C, A> EventInsertCall<'a, C, A> where C: BorrowMut, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Event) -> EventInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Event) -> EventInsertCall<'a, C, A> { + self._request = new_value; self } /// Calendar identifier. @@ -9442,7 +9584,7 @@ impl<'a, C, A> EventInsertCall<'a, C, A> where C: BorrowMut, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.events().import(&req, "calendarId") +/// let result = hub.events().import(req, "calendarId") /// .doit(); /// # } /// ``` @@ -9570,12 +9712,17 @@ impl<'a, C, A> EventImportCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9584,7 +9731,7 @@ impl<'a, C, A> EventImportCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9602,8 +9749,8 @@ impl<'a, C, A> EventImportCall<'a, C, A> where C: BorrowMut, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Event) -> EventImportCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Event) -> EventImportCall<'a, C, A> { + self._request = new_value; self } /// Calendar identifier. @@ -9860,12 +10007,17 @@ impl<'a, C, A> EventInstanceCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9874,7 +10026,7 @@ impl<'a, C, A> EventInstanceCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10184,12 +10336,17 @@ impl<'a, C, A> EventGetCall<'a, C, A> where C: BorrowMut, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10198,7 +10355,7 @@ impl<'a, C, A> EventGetCall<'a, C, A> where C: BorrowMut, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10542,12 +10699,17 @@ impl<'a, C, A> EventListCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10556,7 +10718,7 @@ impl<'a, C, A> EventListCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10797,7 +10959,7 @@ impl<'a, C, A> EventListCall<'a, C, A> where C: BorrowMut, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.events().patch(&req, "calendarId", "eventId") +/// let result = hub.events().patch(req, "calendarId", "eventId") /// .send_notifications(false) /// .max_attendees(-37) /// .always_include_email(false) @@ -10942,12 +11104,17 @@ impl<'a, C, A> EventPatchCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10956,7 +11123,7 @@ impl<'a, C, A> EventPatchCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10974,8 +11141,8 @@ impl<'a, C, A> EventPatchCall<'a, C, A> where C: BorrowMut, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Event) -> EventPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Event) -> EventPatchCall<'a, C, A> { + self._request = new_value; self } /// Calendar identifier. @@ -11225,12 +11392,17 @@ impl<'a, C, A> EventMoveCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11239,7 +11411,7 @@ impl<'a, C, A> EventMoveCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11373,7 +11545,7 @@ impl<'a, C, A> EventMoveCall<'a, C, A> where C: BorrowMut, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.events().update(&req, "calendarId", "eventId") +/// let result = hub.events().update(req, "calendarId", "eventId") /// .send_notifications(true) /// .max_attendees(-91) /// .always_include_email(true) @@ -11518,12 +11690,17 @@ impl<'a, C, A> EventUpdateCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11532,7 +11709,7 @@ impl<'a, C, A> EventUpdateCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11550,8 +11727,8 @@ impl<'a, C, A> EventUpdateCall<'a, C, A> where C: BorrowMut, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Event) -> EventUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Event) -> EventUpdateCall<'a, C, A> { + self._request = new_value; self } /// Calendar identifier. @@ -11679,7 +11856,7 @@ impl<'a, C, A> EventUpdateCall<'a, C, A> where C: BorrowMut, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.events().watch(&req, "calendarId") +/// let result = hub.events().watch(req, "calendarId") /// .updated_min("Lorem") /// .time_zone("diam") /// .time_min("ut") @@ -11900,12 +12077,17 @@ impl<'a, C, A> EventWatchCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11914,7 +12096,7 @@ impl<'a, C, A> EventWatchCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11932,8 +12114,8 @@ impl<'a, C, A> EventWatchCall<'a, C, A> where C: BorrowMut, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Channel) -> EventWatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Channel) -> EventWatchCall<'a, C, A> { + self._request = new_value; self } /// Calendar identifier. @@ -12284,12 +12466,17 @@ impl<'a, C, A> EventQuickAddCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12298,7 +12485,7 @@ impl<'a, C, A> EventQuickAddCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/civicinfo2-cli/Cargo.toml b/gen/civicinfo2-cli/Cargo.toml index e22288896c..a58cd078d5 100644 --- a/gen/civicinfo2-cli/Cargo.toml +++ b/gen/civicinfo2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-civicinfo2-cli" -version = "0.0.1+20150302" +version = "0.1.0+20150302" authors = ["Sebastian Thiel "] description = "A complete library to interact with Civic Info (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/civicinfo2-cli" diff --git a/gen/civicinfo2-cli/README.md b/gen/civicinfo2-cli/README.md index 6d55c3afcf..94eb08182d 100644 --- a/gen/civicinfo2-cli/README.md +++ b/gen/civicinfo2-cli/README.md @@ -1,4 +1,102 @@ -# HELLO CIVICINFO:V2 + +The `civicinfo2` command-line interface *(CLI)* allows to use most features of the *Google Civic Info* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *Civic Info* API at revision *20150302*. The CLI is at version *0.1.0*. + +```bash + civicinfo2 [options] divisions search [-p ...] [-o ] + civicinfo2 [options] elections election-query [-p ...] [-o ] + civicinfo2 [options] elections voter-info-query
[-p ...] [-o ] + civicinfo2 [options] representatives representative-info-by-address [-p ...] [-o ] + civicinfo2 [options] representatives representative-info-by-division [-p ...] [-o ] + civicinfo2 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_civicinfo2_cli/index.html + +Configuration: + --config-dir + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `civicinfo2-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/civicinfo2-token-.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/civicinfo2-secret.json`, assuming that the required *civicinfo* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `civicinfo2 --debug [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/civicinfo2-cli/mkdocs.yml b/gen/civicinfo2-cli/mkdocs.yml index 3f277970cd..c8a6f6003c 100644 --- a/gen/civicinfo2-cli/mkdocs.yml +++ b/gen/civicinfo2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Civic Info v0.0.1+20150302 +site_name: Civic Info v0.1.0+20150302 site_url: http://byron.github.io/google-apis-rs/google-civicinfo2-cli site_description: Write integrating applications with bcore diff --git a/gen/civicinfo2-cli/src/cmn.rs b/gen/civicinfo2-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/civicinfo2-cli/src/cmn.rs +++ b/gen/civicinfo2-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/civicinfo2-cli/src/main.rs b/gen/civicinfo2-cli/src/main.rs index d59d8c521d..1f1e48cca5 100644 --- a/gen/civicinfo2-cli/src/main.rs +++ b/gen/civicinfo2-cli/src/main.rs @@ -19,26 +19,27 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - civicinfo2 [options] divisions search [-p ]... [-o ] - civicinfo2 [options] elections election-query [-p ]... [-o ] - civicinfo2 [options] elections voter-info-query
[-p ]... [-o ] - civicinfo2 [options] representatives representative-info-by-address [-p ]... [-o ] - civicinfo2 [options] representatives representative-info-by-division [-p ]... [-o ] + civicinfo2 [options] divisions search [-p ...] [-o ] + civicinfo2 [options] elections election-query [-p ...] [-o ] + civicinfo2 [options] elections voter-info-query
[-p ...] [-o ] + civicinfo2 [options] representatives representative-info-by-address [-p ...] [-o ] + civicinfo2 [options] representatives representative-info-by-division [-p ...] [-o ] civicinfo2 --help -All documentation details can be found TODO: +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_civicinfo2_cli/index.html Configuration: --config-dir - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -400,6 +401,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -407,8 +409,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/civicinfo2/Cargo.toml b/gen/civicinfo2/Cargo.toml index f947972afa..071dc47367 100644 --- a/gen/civicinfo2/Cargo.toml +++ b/gen/civicinfo2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-civicinfo2" -version = "0.1.5+20150302" +version = "0.1.6+20150302" authors = ["Sebastian Thiel "] description = "A complete library to interact with Civic Info (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/civicinfo2" diff --git a/gen/civicinfo2/README.md b/gen/civicinfo2/README.md index f219e54072..7c9c6b9c22 100644 --- a/gen/civicinfo2/README.md +++ b/gen/civicinfo2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-civicinfo2` library allows access to all features of the *Google Civic Info* service. -This documentation was generated from *Civic Info* crate version *0.1.5+20150302*, where *20150302* is the exact revision of the *civicinfo:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *Civic Info* crate version *0.1.6+20150302*, where *20150302* is the exact revision of the *civicinfo:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *Civic Info* *v2* API can be found at the [official documentation site](https://developers.google.com/civic-information). @@ -106,14 +106,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/civicinfo2/src/cmn.rs b/gen/civicinfo2/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/civicinfo2/src/cmn.rs +++ b/gen/civicinfo2/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option, + location: Option +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option, _: Option) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec]) -> Option { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/civicinfo2/src/lib.rs b/gen/civicinfo2/src/lib.rs index ef05e5cab3..804f05d9d7 100644 --- a/gen/civicinfo2/src/lib.rs +++ b/gen/civicinfo2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Civic Info* crate version *0.1.5+20150302*, where *20150302* is the exact revision of the *civicinfo:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *Civic Info* crate version *0.1.6+20150302*, where *20150302* is the exact revision of the *civicinfo:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *Civic Info* *v2* API can be found at the //! [official documentation site](https://developers.google.com/civic-information). @@ -107,14 +107,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -202,7 +203,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -256,14 +257,15 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -284,7 +286,7 @@ impl<'a, C, A> CivicInfo CivicInfo { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -299,7 +301,7 @@ impl<'a, C, A> CivicInfo } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -1173,12 +1175,17 @@ impl<'a, C, A> DivisionSearchCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1187,7 +1194,7 @@ impl<'a, C, A> DivisionSearchCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1355,12 +1362,17 @@ impl<'a, C, A> ElectionElectionQueryCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1369,7 +1381,7 @@ impl<'a, C, A> ElectionElectionQueryCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1542,12 +1554,17 @@ impl<'a, C, A> ElectionVoterInfoQueryCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1556,7 +1573,7 @@ impl<'a, C, A> ElectionVoterInfoQueryCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1769,12 +1786,17 @@ impl<'a, C, A> RepresentativeRepresentativeInfoByAddresCall<'a, C, A> where C: B if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1783,7 +1805,7 @@ impl<'a, C, A> RepresentativeRepresentativeInfoByAddresCall<'a, C, A> where C: B Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2023,12 +2045,17 @@ impl<'a, C, A> RepresentativeRepresentativeInfoByDivisionCall<'a, C, A> where C: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2037,7 +2064,7 @@ impl<'a, C, A> RepresentativeRepresentativeInfoByDivisionCall<'a, C, A> where C: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/cloudlatencytest2-cli/Cargo.toml b/gen/cloudlatencytest2-cli/Cargo.toml index 012706f160..24d404a9a4 100644 --- a/gen/cloudlatencytest2-cli/Cargo.toml +++ b/gen/cloudlatencytest2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-cloudlatencytest2-cli" -version = "0.0.1+20150206" +version = "0.1.0+20150206" authors = ["Sebastian Thiel "] description = "A complete library to interact with cloudlatencytest (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/cloudlatencytest2-cli" diff --git a/gen/cloudlatencytest2-cli/README.md b/gen/cloudlatencytest2-cli/README.md index f905faf861..b38a2bfd70 100644 --- a/gen/cloudlatencytest2-cli/README.md +++ b/gen/cloudlatencytest2-cli/README.md @@ -1,4 +1,103 @@ -# HELLO CLOUDLATENCYTEST:V2 + +The `cloudlatencytest2` command-line interface *(CLI)* allows to use most features of the *Google cloudlatencytest* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *cloudlatencytest* API at revision *20150206*. The CLI is at version *0.1.0*. + +```bash + cloudlatencytest2 [options] statscollection updateaggregatedstats -r ... [-p ...] [-o ] + cloudlatencytest2 [options] statscollection updatestats -r ... [-p ...] [-o ] + cloudlatencytest2 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_cloudlatencytest2_cli/index.html + +Configuration: + --scope + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `cloudlatencytest2-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/cloudlatencytest2-token-.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/cloudlatencytest2-secret.json`, assuming that the required *cloudlatencytest* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `cloudlatencytest2 --debug [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/cloudlatencytest2-cli/mkdocs.yml b/gen/cloudlatencytest2-cli/mkdocs.yml index 0c1e2f9a96..4337528929 100644 --- a/gen/cloudlatencytest2-cli/mkdocs.yml +++ b/gen/cloudlatencytest2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: cloudlatencytest v0.0.1+20150206 +site_name: cloudlatencytest v0.1.0+20150206 site_url: http://byron.github.io/google-apis-rs/google-cloudlatencytest2-cli site_description: Write integrating applications with bcore diff --git a/gen/cloudlatencytest2-cli/src/cmn.rs b/gen/cloudlatencytest2-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/cloudlatencytest2-cli/src/cmn.rs +++ b/gen/cloudlatencytest2-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/cloudlatencytest2-cli/src/main.rs b/gen/cloudlatencytest2-cli/src/main.rs index 653d715340..69cd091dbb 100644 --- a/gen/cloudlatencytest2-cli/src/main.rs +++ b/gen/cloudlatencytest2-cli/src/main.rs @@ -19,27 +19,28 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - cloudlatencytest2 [options] statscollection updateaggregatedstats -r ... [-p ]... [-o ] - cloudlatencytest2 [options] statscollection updatestats -r ... [-p ]... [-o ] + cloudlatencytest2 [options] statscollection updateaggregatedstats -r ... [-p ...] [-o ] + cloudlatencytest2 [options] statscollection updatestats -r ... [-p ...] [-o ] cloudlatencytest2 --help -All documentation details can be found TODO: +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_cloudlatencytest2_cli/index.html Configuration: --scope - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -61,8 +62,30 @@ struct Engine { impl Engine { fn _statscollection_updateaggregatedstats(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::AggregatedStats::default(); - let mut call = self.hub.statscollection().updateaggregatedstats(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.statscollection().updateaggregatedstats(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -84,24 +107,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -118,8 +131,33 @@ impl Engine { fn _statscollection_updatestats(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Stats::default(); - let mut call = self.hub.statscollection().updatestats(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "time" => { + request.time = Some(arg_from_str(value.unwrap_or("0.0"), err, "time", "number")); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.statscollection().updatestats(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -141,27 +179,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "time" => { - request.time = Some(arg_from_str(value.unwrap_or("0.0"), err, "time", "number")); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -257,6 +282,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -264,8 +290,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/cloudlatencytest2/Cargo.toml b/gen/cloudlatencytest2/Cargo.toml index 23bf95a2bc..8f8eb3ea1d 100644 --- a/gen/cloudlatencytest2/Cargo.toml +++ b/gen/cloudlatencytest2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-cloudlatencytest2" -version = "0.1.5+20150206" +version = "0.1.6+20150206" authors = ["Sebastian Thiel "] description = "A complete library to interact with cloudlatencytest (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/cloudlatencytest2" diff --git a/gen/cloudlatencytest2/README.md b/gen/cloudlatencytest2/README.md index 3991c2dde8..2e4e50fd37 100644 --- a/gen/cloudlatencytest2/README.md +++ b/gen/cloudlatencytest2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-cloudlatencytest2` library allows access to all features of the *Google cloudlatencytest* service. -This documentation was generated from *cloudlatencytest* crate version *0.1.5+20150206*, where *20150206* is the exact revision of the *cloudlatencytest:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *cloudlatencytest* crate version *0.1.6+20150206*, where *20150206* is the exact revision of the *cloudlatencytest:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. # Features Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_cloudlatencytest2/struct.Cloudlatencytest.html) ... @@ -95,21 +95,22 @@ let mut req = Stats::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.statscollection().updatestats(&req) +let result = hub.statscollection().updatestats(req) .doit(); match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/cloudlatencytest2/src/cmn.rs b/gen/cloudlatencytest2/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/cloudlatencytest2/src/cmn.rs +++ b/gen/cloudlatencytest2/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option, + location: Option +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option, _: Option) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec]) -> Option { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/cloudlatencytest2/src/lib.rs b/gen/cloudlatencytest2/src/lib.rs index 4109352f2d..59048d6ebb 100644 --- a/gen/cloudlatencytest2/src/lib.rs +++ b/gen/cloudlatencytest2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *cloudlatencytest* crate version *0.1.5+20150206*, where *20150206* is the exact revision of the *cloudlatencytest:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *cloudlatencytest* crate version *0.1.6+20150206*, where *20150206* is the exact revision of the *cloudlatencytest:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/cloudlatencytest2). //! # Features //! @@ -96,21 +96,22 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.statscollection().updatestats(&req) +//! let result = hub.statscollection().updatestats(req) //! .doit(); //! //! match result { //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -198,7 +199,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -271,21 +272,22 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.statscollection().updatestats(&req) +/// let result = hub.statscollection().updatestats(req) /// .doit(); /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -306,7 +308,7 @@ impl<'a, C, A> Cloudlatencytest Cloudlatencytest { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -315,7 +317,7 @@ impl<'a, C, A> Cloudlatencytest } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -507,10 +509,10 @@ impl<'a, C, A> StatscollectionMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn updateaggregatedstats(&self, request: &AggregatedStats) -> StatscollectionUpdateaggregatedstatCall<'a, C, A> { + pub fn updateaggregatedstats(&self, request: AggregatedStats) -> StatscollectionUpdateaggregatedstatCall<'a, C, A> { StatscollectionUpdateaggregatedstatCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -524,10 +526,10 @@ impl<'a, C, A> StatscollectionMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn updatestats(&self, request: &Stats) -> StatscollectionUpdatestatCall<'a, C, A> { + pub fn updatestats(&self, request: Stats) -> StatscollectionUpdatestatCall<'a, C, A> { StatscollectionUpdatestatCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -575,7 +577,7 @@ impl<'a, C, A> StatscollectionMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.statscollection().updateaggregatedstats(&req) +/// let result = hub.statscollection().updateaggregatedstats(req) /// .doit(); /// # } /// ``` @@ -677,12 +679,17 @@ impl<'a, C, A> StatscollectionUpdateaggregatedstatCall<'a, C, A> where C: Borrow if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -691,7 +698,7 @@ impl<'a, C, A> StatscollectionUpdateaggregatedstatCall<'a, C, A> where C: Borrow Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -709,8 +716,8 @@ impl<'a, C, A> StatscollectionUpdateaggregatedstatCall<'a, C, A> where C: Borrow /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AggregatedStats) -> StatscollectionUpdateaggregatedstatCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AggregatedStats) -> StatscollectionUpdateaggregatedstatCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -797,7 +804,7 @@ impl<'a, C, A> StatscollectionUpdateaggregatedstatCall<'a, C, A> where C: Borrow /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.statscollection().updatestats(&req) +/// let result = hub.statscollection().updatestats(req) /// .doit(); /// # } /// ``` @@ -899,12 +906,17 @@ impl<'a, C, A> StatscollectionUpdatestatCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -913,7 +925,7 @@ impl<'a, C, A> StatscollectionUpdatestatCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -931,8 +943,8 @@ impl<'a, C, A> StatscollectionUpdatestatCall<'a, C, A> where C: BorrowMut StatscollectionUpdatestatCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Stats) -> StatscollectionUpdatestatCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong diff --git a/gen/cloudmonitoring2_beta2-cli/Cargo.toml b/gen/cloudmonitoring2_beta2-cli/Cargo.toml index e76b49dea0..9cd120ae89 100644 --- a/gen/cloudmonitoring2_beta2-cli/Cargo.toml +++ b/gen/cloudmonitoring2_beta2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-cloudmonitoring2_beta2-cli" -version = "0.0.1+20150401" +version = "0.1.0+20150401" authors = ["Sebastian Thiel "] description = "A complete library to interact with Cloud Monitoring (protocol v2beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/cloudmonitoring2_beta2-cli" diff --git a/gen/cloudmonitoring2_beta2-cli/README.md b/gen/cloudmonitoring2_beta2-cli/README.md index 6a0abc727d..f7cb8b2377 100644 --- a/gen/cloudmonitoring2_beta2-cli/README.md +++ b/gen/cloudmonitoring2_beta2-cli/README.md @@ -1,4 +1,107 @@ -# HELLO CLOUDMONITORING:V2BETA2 + +The `cloudmonitoring2-beta2` command-line interface *(CLI)* allows to use most features of the *Google Cloud Monitoring* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *Cloud Monitoring* API at revision *20150401*. The CLI is at version *0.1.0*. + +```bash + cloudmonitoring2-beta2 [options] metric-descriptors create -r ... [-p ...] [-o ] + cloudmonitoring2-beta2 [options] metric-descriptors delete [-p ...] [-o ] + cloudmonitoring2-beta2 [options] metric-descriptors list -r ... [-p ...] [-o ] + cloudmonitoring2-beta2 [options] timeseries list -r ... [-p ...] [-o ] + cloudmonitoring2-beta2 [options] timeseries write -r ... [-p ...] [-o ] + cloudmonitoring2-beta2 [options] timeseries-descriptors list -r ... [-p ...] [-o ] + cloudmonitoring2-beta2 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_cloudmonitoring2_beta2_cli/index.html + +Configuration: + --scope + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `cloudmonitoring2-beta2-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/cloudmonitoring2-beta2-token-.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/cloudmonitoring2-beta2-secret.json`, assuming that the required *cloudmonitoring* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `cloudmonitoring2-beta2 --debug [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/cloudmonitoring2_beta2-cli/mkdocs.yml b/gen/cloudmonitoring2_beta2-cli/mkdocs.yml index edf8cb8d37..e7500b963c 100644 --- a/gen/cloudmonitoring2_beta2-cli/mkdocs.yml +++ b/gen/cloudmonitoring2_beta2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Cloud Monitoring v0.0.1+20150401 +site_name: Cloud Monitoring v0.1.0+20150401 site_url: http://byron.github.io/google-apis-rs/google-cloudmonitoring2_beta2-cli site_description: Write integrating applications with bcore diff --git a/gen/cloudmonitoring2_beta2-cli/src/cmn.rs b/gen/cloudmonitoring2_beta2-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/cloudmonitoring2_beta2-cli/src/cmn.rs +++ b/gen/cloudmonitoring2_beta2-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/cloudmonitoring2_beta2-cli/src/main.rs b/gen/cloudmonitoring2_beta2-cli/src/main.rs index 7a1c8c8668..e0af43e97a 100644 --- a/gen/cloudmonitoring2_beta2-cli/src/main.rs +++ b/gen/cloudmonitoring2_beta2-cli/src/main.rs @@ -19,31 +19,32 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - cloudmonitoring2-beta2 [options] metric-descriptors create -r ... [-p ]... [-o ] - cloudmonitoring2-beta2 [options] metric-descriptors delete [-p ]... [-o ] - cloudmonitoring2-beta2 [options] metric-descriptors list -r ... [-p ]... [-o ] - cloudmonitoring2-beta2 [options] timeseries list -r ... [-p ]... [-o ] - cloudmonitoring2-beta2 [options] timeseries write -r ... [-p ]... [-o ] - cloudmonitoring2-beta2 [options] timeseries-descriptors list -r ... [-p ]... [-o ] + cloudmonitoring2-beta2 [options] metric-descriptors create -r ... [-p ...] [-o ] + cloudmonitoring2-beta2 [options] metric-descriptors delete [-p ...] [-o ] + cloudmonitoring2-beta2 [options] metric-descriptors list -r ... [-p ...] [-o ] + cloudmonitoring2-beta2 [options] timeseries list -r ... [-p ...] [-o ] + cloudmonitoring2-beta2 [options] timeseries write -r ... [-p ...] [-o ] + cloudmonitoring2-beta2 [options] timeseries-descriptors list -r ... [-p ...] [-o ] cloudmonitoring2-beta2 --help -All documentation details can be found TODO: +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_cloudmonitoring2_beta2_cli/index.html Configuration: --scope - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -65,8 +66,55 @@ struct Engine { impl Engine { fn _metric_descriptors_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::MetricDescriptor::default(); - let mut call = self.hub.metric_descriptors().create(&request, &self.opt.arg_project); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + fn request_type_descriptor_init(request: &mut api::MetricDescriptor) { + if request.type_descriptor.is_none() { + request.type_descriptor = Some(Default::default()); + } + } + + match &temp_cursor.to_string()[..] { + "project" => { + request.project = Some(value.unwrap_or("").to_string()); + }, + "type-descriptor.value-type" => { + request_type_descriptor_init(&mut request); + request.type_descriptor.as_mut().unwrap().value_type = Some(value.unwrap_or("").to_string()); + }, + "type-descriptor.metric-type" => { + request_type_descriptor_init(&mut request); + request.type_descriptor.as_mut().unwrap().metric_type = Some(value.unwrap_or("").to_string()); + }, + "description" => { + request_type_descriptor_init(&mut request); + request.description = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request_type_descriptor_init(&mut request); + request.name = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.metric_descriptors().create(request, &self.opt.arg_project); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -88,49 +136,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_type_descriptor_init(request: &mut api::MetricDescriptor) { - if request.type_descriptor.is_none() { - request.type_descriptor = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "project" => { - request.project = Some(value.unwrap_or("").to_string()); - }, - "type-descriptor.value-type" => { - request_type_descriptor_init(&mut request); - request.type_descriptor.as_mut().unwrap().value_type = Some(value.unwrap_or("").to_string()); - }, - "type-descriptor.metric-type" => { - request_type_descriptor_init(&mut request); - request.type_descriptor.as_mut().unwrap().metric_type = Some(value.unwrap_or("").to_string()); - }, - "description" => { - request_type_descriptor_init(&mut request); - request.description = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request_type_descriptor_init(&mut request); - request.name = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -174,6 +187,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -190,8 +206,33 @@ impl Engine { fn _metric_descriptors_list(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::ListMetricDescriptorsRequest::default(); - let mut call = self.hub.metric_descriptors().list(&request, &self.opt.arg_project); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.metric_descriptors().list(request, &self.opt.arg_project); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -222,27 +263,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -259,8 +287,33 @@ impl Engine { fn _timeseries_list(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::ListTimeseriesRequest::default(); - let mut call = self.hub.timeseries().list(&request, &self.opt.arg_project, &self.opt.arg_metric, &self.opt.arg_youngest); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.timeseries().list(request, &self.opt.arg_project, &self.opt.arg_metric, &self.opt.arg_youngest); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -303,27 +356,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -340,8 +380,37 @@ impl Engine { fn _timeseries_write(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::WriteTimeseriesRequest::default(); - let mut call = self.hub.timeseries().write(&request, &self.opt.arg_project); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "common-labels" => { + if request.common_labels.is_none() { + request.common_labels = Some(Default::default()); + } + let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); + request.common_labels.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.timeseries().write(request, &self.opt.arg_project); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -363,31 +432,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "common-labels" => { - if request.common_labels.is_none() { - request.common_labels = Some(Default::default()); - } - let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); - request.common_labels.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -404,8 +456,33 @@ impl Engine { fn _timeseries_descriptors_list(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::ListTimeseriesDescriptorsRequest::default(); - let mut call = self.hub.timeseries_descriptors().list(&request, &self.opt.arg_project, &self.opt.arg_metric, &self.opt.arg_youngest); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.timeseries_descriptors().list(request, &self.opt.arg_project, &self.opt.arg_metric, &self.opt.arg_youngest); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -448,27 +525,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -582,6 +646,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -589,8 +654,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/cloudmonitoring2_beta2/Cargo.toml b/gen/cloudmonitoring2_beta2/Cargo.toml index d389d725c4..a5d9abdcba 100644 --- a/gen/cloudmonitoring2_beta2/Cargo.toml +++ b/gen/cloudmonitoring2_beta2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-cloudmonitoring2_beta2" -version = "0.1.5+20150401" +version = "0.1.6+20150401" authors = ["Sebastian Thiel "] description = "A complete library to interact with Cloud Monitoring (protocol v2beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/cloudmonitoring2_beta2" diff --git a/gen/cloudmonitoring2_beta2/README.md b/gen/cloudmonitoring2_beta2/README.md index f2d96a3b14..0257e29325 100644 --- a/gen/cloudmonitoring2_beta2/README.md +++ b/gen/cloudmonitoring2_beta2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-cloudmonitoring2_beta2` library allows access to all features of the *Google Cloud Monitoring* service. -This documentation was generated from *Cloud Monitoring* crate version *0.1.5+20150401*, where *20150401* is the exact revision of the *cloudmonitoring:v2beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *Cloud Monitoring* crate version *0.1.6+20150401*, where *20150401* is the exact revision of the *cloudmonitoring:v2beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *Cloud Monitoring* *v2_beta2* API can be found at the [official documentation site](https://cloud.google.com/monitoring/v2beta2/). @@ -104,7 +104,7 @@ let mut req = ListMetricDescriptorsRequest::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.metric_descriptors().list(&req, "project") +let result = hub.metric_descriptors().list(req, "project") .query("sit") .page_token("Stet") .count(-42) @@ -114,14 +114,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/cloudmonitoring2_beta2/src/cmn.rs b/gen/cloudmonitoring2_beta2/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/cloudmonitoring2_beta2/src/cmn.rs +++ b/gen/cloudmonitoring2_beta2/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option, + location: Option +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option, _: Option) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec]) -> Option { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/cloudmonitoring2_beta2/src/lib.rs b/gen/cloudmonitoring2_beta2/src/lib.rs index c15198a5e6..882f455501 100644 --- a/gen/cloudmonitoring2_beta2/src/lib.rs +++ b/gen/cloudmonitoring2_beta2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Cloud Monitoring* crate version *0.1.5+20150401*, where *20150401* is the exact revision of the *cloudmonitoring:v2beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *Cloud Monitoring* crate version *0.1.6+20150401*, where *20150401* is the exact revision of the *cloudmonitoring:v2beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *Cloud Monitoring* *v2_beta2* API can be found at the //! [official documentation site](https://cloud.google.com/monitoring/v2beta2/). @@ -105,7 +105,7 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.metric_descriptors().list(&req, "project") +//! let result = hub.metric_descriptors().list(req, "project") //! .query("dolores") //! .page_token("kasd") //! .count(-22) @@ -115,14 +115,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -210,7 +211,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -283,7 +284,7 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.metric_descriptors().list(&req, "project") +/// let result = hub.metric_descriptors().list(req, "project") /// .query("justo") /// .page_token("amet.") /// .count(-81) @@ -293,14 +294,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -321,7 +323,7 @@ impl<'a, C, A> CloudMonitoring CloudMonitoring { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -336,7 +338,7 @@ impl<'a, C, A> CloudMonitoring } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -808,10 +810,10 @@ impl<'a, C, A> TimeseriesDescriptorMethods<'a, C, A> { /// * `project` - The project ID to which this time series belongs. The value can be the numeric project ID or string-based project name. /// * `metric` - Metric names are protocol-free URLs as listed in the Supported Metrics page. For example, compute.googleapis.com/instance/disk/read_ops_count. /// * `youngest` - End of the time interval (inclusive), which is expressed as an RFC 3339 timestamp. - pub fn list(&self, request: &ListTimeseriesDescriptorsRequest, project: &str, metric: &str, youngest: &str) -> TimeseriesDescriptorListCall<'a, C, A> { + pub fn list(&self, request: ListTimeseriesDescriptorsRequest, project: &str, metric: &str, youngest: &str) -> TimeseriesDescriptorListCall<'a, C, A> { TimeseriesDescriptorListCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _metric: metric.to_string(), _youngest: youngest.to_string(), @@ -877,10 +879,10 @@ impl<'a, C, A> TimeseryMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `project` - The project ID. The value can be the numeric project ID or string-based project name. - pub fn write(&self, request: &WriteTimeseriesRequest, project: &str) -> TimeseryWriteCall<'a, C, A> { + pub fn write(&self, request: WriteTimeseriesRequest, project: &str) -> TimeseryWriteCall<'a, C, A> { TimeseryWriteCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -898,10 +900,10 @@ impl<'a, C, A> TimeseryMethods<'a, C, A> { /// * `project` - The project ID to which this time series belongs. The value can be the numeric project ID or string-based project name. /// * `metric` - Metric names are protocol-free URLs as listed in the Supported Metrics page. For example, compute.googleapis.com/instance/disk/read_ops_count. /// * `youngest` - End of the time interval (inclusive), which is expressed as an RFC 3339 timestamp. - pub fn list(&self, request: &ListTimeseriesRequest, project: &str, metric: &str, youngest: &str) -> TimeseryListCall<'a, C, A> { + pub fn list(&self, request: ListTimeseriesRequest, project: &str, metric: &str, youngest: &str) -> TimeseryListCall<'a, C, A> { TimeseryListCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _metric: metric.to_string(), _youngest: youngest.to_string(), @@ -967,10 +969,10 @@ impl<'a, C, A> MetricDescriptorMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `project` - The project id. The value can be the numeric project ID or string-based project name. - pub fn list(&self, request: &ListMetricDescriptorsRequest, project: &str) -> MetricDescriptorListCall<'a, C, A> { + pub fn list(&self, request: ListMetricDescriptorsRequest, project: &str) -> MetricDescriptorListCall<'a, C, A> { MetricDescriptorListCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _query: Default::default(), _page_token: Default::default(), @@ -1008,10 +1010,10 @@ impl<'a, C, A> MetricDescriptorMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `project` - The project id. The value can be the numeric project ID or string-based project name. - pub fn create(&self, request: &MetricDescriptor, project: &str) -> MetricDescriptorCreateCall<'a, C, A> { + pub fn create(&self, request: MetricDescriptor, project: &str) -> MetricDescriptorCreateCall<'a, C, A> { MetricDescriptorCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1060,7 +1062,7 @@ impl<'a, C, A> MetricDescriptorMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.timeseries_descriptors().list(&req, "project", "metric", "youngest") +/// let result = hub.timeseries_descriptors().list(req, "project", "metric", "youngest") /// .window("dolores") /// .timespan("gubergren") /// .page_token("sadipscing") @@ -1231,12 +1233,17 @@ impl<'a, C, A> TimeseriesDescriptorListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1245,7 +1252,7 @@ impl<'a, C, A> TimeseriesDescriptorListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1263,8 +1270,8 @@ impl<'a, C, A> TimeseriesDescriptorListCall<'a, C, A> where C: BorrowMut TimeseriesDescriptorListCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ListTimeseriesDescriptorsRequest) -> TimeseriesDescriptorListCall<'a, C, A> { + self._request = new_value; self } /// The project ID to which this time series belongs. The value can be the numeric project ID or string-based project name. @@ -1447,7 +1454,7 @@ impl<'a, C, A> TimeseriesDescriptorListCall<'a, C, A> where C: BorrowMut TimeseryWriteCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1589,7 +1601,7 @@ impl<'a, C, A> TimeseryWriteCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1607,8 +1619,8 @@ impl<'a, C, A> TimeseryWriteCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &WriteTimeseriesRequest) -> TimeseryWriteCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: WriteTimeseriesRequest) -> TimeseryWriteCall<'a, C, A> { + self._request = new_value; self } /// The project ID. The value can be the numeric project ID or string-based project name. @@ -1705,7 +1717,7 @@ impl<'a, C, A> TimeseryWriteCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.timeseries().list(&req, "project", "metric", "youngest") +/// let result = hub.timeseries().list(req, "project", "metric", "youngest") /// .window("ipsum") /// .timespan("Lorem") /// .page_token("et") @@ -1876,12 +1888,17 @@ impl<'a, C, A> TimeseryListCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1890,7 +1907,7 @@ impl<'a, C, A> TimeseryListCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1908,8 +1925,8 @@ impl<'a, C, A> TimeseryListCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ListTimeseriesRequest) -> TimeseryListCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ListTimeseriesRequest) -> TimeseryListCall<'a, C, A> { + self._request = new_value; self } /// The project ID to which this time series belongs. The value can be the numeric project ID or string-based project name. @@ -2092,7 +2109,7 @@ impl<'a, C, A> TimeseryListCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.metric_descriptors().list(&req, "project") +/// let result = hub.metric_descriptors().list(req, "project") /// .query("erat") /// .page_token("sadipscing") /// .count(-48) @@ -2235,12 +2252,17 @@ impl<'a, C, A> MetricDescriptorListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2249,7 +2271,7 @@ impl<'a, C, A> MetricDescriptorListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2267,8 +2289,8 @@ impl<'a, C, A> MetricDescriptorListCall<'a, C, A> where C: BorrowMut MetricDescriptorListCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ListMetricDescriptorsRequest) -> MetricDescriptorListCall<'a, C, A> { + self._request = new_value; self } /// The project id. The value can be the numeric project ID or string-based project name. @@ -2501,12 +2523,17 @@ impl<'a, C, A> MetricDescriptorDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2515,7 +2542,7 @@ impl<'a, C, A> MetricDescriptorDeleteCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2632,7 +2659,7 @@ impl<'a, C, A> MetricDescriptorDeleteCall<'a, C, A> where C: BorrowMut MetricDescriptorCreateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2774,7 +2806,7 @@ impl<'a, C, A> MetricDescriptorCreateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2792,8 +2824,8 @@ impl<'a, C, A> MetricDescriptorCreateCall<'a, C, A> where C: BorrowMut MetricDescriptorCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: MetricDescriptor) -> MetricDescriptorCreateCall<'a, C, A> { + self._request = new_value; self } /// The project id. The value can be the numeric project ID or string-based project name. diff --git a/gen/cloudsearch1-cli/Cargo.toml b/gen/cloudsearch1-cli/Cargo.toml index 580966a5f8..9d29499cd6 100644 --- a/gen/cloudsearch1-cli/Cargo.toml +++ b/gen/cloudsearch1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-cloudsearch1-cli" -version = "0.0.1+20150416" +version = "0.1.0+20150416" authors = ["Sebastian Thiel "] description = "A complete library to interact with cloudsearch (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/cloudsearch1-cli" diff --git a/gen/cloudsearch1-cli/README.md b/gen/cloudsearch1-cli/README.md index 7b0247d3fd..1296a46c89 100644 --- a/gen/cloudsearch1-cli/README.md +++ b/gen/cloudsearch1-cli/README.md @@ -1,4 +1,97 @@ -# HELLO CLOUDSEARCH:V1 + +The `cloudsearch1` command-line interface *(CLI)* allows to use most features of the *Google cloudsearch* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *cloudsearch* API at revision *20150416*. The CLI is at version *0.1.0*. + +```bash + cloudsearch1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_cloudsearch1_cli/index.html + +Configuration: + --config-dir + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `cloudsearch1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/cloudsearch1-token-.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/cloudsearch1-secret.json`, assuming that the required *cloudsearch* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `cloudsearch1 --debug [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/cloudsearch1-cli/mkdocs.yml b/gen/cloudsearch1-cli/mkdocs.yml index f30709e098..deb3e655fe 100644 --- a/gen/cloudsearch1-cli/mkdocs.yml +++ b/gen/cloudsearch1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: cloudsearch v0.0.1+20150416 +site_name: cloudsearch v0.1.0+20150416 site_url: http://byron.github.io/google-apis-rs/google-cloudsearch1-cli site_description: Write integrating applications with bcore diff --git a/gen/cloudsearch1-cli/src/cmn.rs b/gen/cloudsearch1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/cloudsearch1-cli/src/cmn.rs +++ b/gen/cloudsearch1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/cloudsearch1-cli/src/main.rs b/gen/cloudsearch1-cli/src/main.rs index d4a790d5d4..75e153a3a7 100644 --- a/gen/cloudsearch1-cli/src/main.rs +++ b/gen/cloudsearch1-cli/src/main.rs @@ -21,19 +21,20 @@ docopt!(Options derive Debug, " Usage: cloudsearch1 --help -All documentation details can be found TODO: +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_cloudsearch1_cli/index.html Configuration: --config-dir - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -125,6 +126,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -132,8 +134,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/cloudsearch1/Cargo.toml b/gen/cloudsearch1/Cargo.toml index dba02cda31..d8281b802b 100644 --- a/gen/cloudsearch1/Cargo.toml +++ b/gen/cloudsearch1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-cloudsearch1" -version = "0.1.5+20150416" +version = "0.1.6+20150416" authors = ["Sebastian Thiel "] description = "A complete library to interact with cloudsearch (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/cloudsearch1" diff --git a/gen/cloudsearch1/README.md b/gen/cloudsearch1/README.md index 085b0d7aec..07bef0b9e4 100644 --- a/gen/cloudsearch1/README.md +++ b/gen/cloudsearch1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-cloudsearch1` library allows access to all features of the *Google cloudsearch* service. -This documentation was generated from *cloudsearch* crate version *0.1.5+20150416*, where *20150416* is the exact revision of the *cloudsearch:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *cloudsearch* crate version *0.1.6+20150416*, where *20150416* is the exact revision of the *cloudsearch:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. # Features It seems there is nothing you can do here ... . diff --git a/gen/cloudsearch1/src/cmn.rs b/gen/cloudsearch1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/cloudsearch1/src/cmn.rs +++ b/gen/cloudsearch1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option, + location: Option +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option, _: Option) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec]) -> Option { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/cloudsearch1/src/lib.rs b/gen/cloudsearch1/src/lib.rs index d6fdfe5bd8..39331f1f40 100644 --- a/gen/cloudsearch1/src/lib.rs +++ b/gen/cloudsearch1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *cloudsearch* crate version *0.1.5+20150416*, where *20150416* is the exact revision of the *cloudsearch:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *cloudsearch* crate version *0.1.6+20150416*, where *20150416* is the exact revision of the *cloudsearch:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/cloudsearch1). //! # Features //! @@ -165,7 +165,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -225,13 +225,13 @@ impl<'a, C, A> Cloudsearch Cloudsearch { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { diff --git a/gen/compute1-cli/Cargo.toml b/gen/compute1-cli/Cargo.toml index 3f771a67b4..1c039b2761 100644 --- a/gen/compute1-cli/Cargo.toml +++ b/gen/compute1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-compute1-cli" -version = "0.0.1+20150326" +version = "0.1.0+20150326" authors = ["Sebastian Thiel "] description = "A complete library to interact with compute (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/compute1-cli" diff --git a/gen/compute1-cli/README.md b/gen/compute1-cli/README.md index 0589fe2c9e..bc8a65237d 100644 --- a/gen/compute1-cli/README.md +++ b/gen/compute1-cli/README.md @@ -1,4 +1,247 @@ -# HELLO COMPUTE:V1 + +The `compute1` command-line interface *(CLI)* allows to use most features of the *Google compute* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *compute* API at revision *20150326*. The CLI is at version *0.1.0*. + +```bash + compute1 [options] addresses aggregated-list [-p ...] [-o ] + compute1 [options] addresses delete
[-p ...] [-o ] + compute1 [options] addresses get
[-p ...] [-o ] + compute1 [options] addresses insert -r ... [-p ...] [-o ] + compute1 [options] addresses list [-p ...] [-o ] + compute1 [options] backend-services delete [-p ...] [-o ] + compute1 [options] backend-services get [-p ...] [-o ] + compute1 [options] backend-services get-health -r ... [-p ...] [-o ] + compute1 [options] backend-services insert -r ... [-p ...] [-o ] + compute1 [options] backend-services list [-p ...] [-o ] + compute1 [options] backend-services patch -r ... [-p ...] [-o ] + compute1 [options] backend-services update -r ... [-p ...] [-o ] + compute1 [options] disk-types aggregated-list [-p ...] [-o ] + compute1 [options] disk-types get [-p ...] [-o ] + compute1 [options] disk-types list [-p ...] [-o ] + compute1 [options] disks aggregated-list [-p ...] [-o ] + compute1 [options] disks create-snapshot -r ... [-p ...] [-o ] + compute1 [options] disks delete [-p ...] [-o ] + compute1 [options] disks get [-p ...] [-o ] + compute1 [options] disks insert -r ... [-p ...] [-o ] + compute1 [options] disks list [-p ...] [-o ] + compute1 [options] firewalls delete [-p ...] [-o ] + compute1 [options] firewalls get [-p ...] [-o ] + compute1 [options] firewalls insert -r ... [-p ...] [-o ] + compute1 [options] firewalls list [-p ...] [-o ] + compute1 [options] firewalls patch -r ... [-p ...] [-o ] + compute1 [options] firewalls update -r ... [-p ...] [-o ] + compute1 [options] forwarding-rules aggregated-list [-p ...] [-o ] + compute1 [options] forwarding-rules delete [-p ...] [-o ] + compute1 [options] forwarding-rules get [-p ...] [-o ] + compute1 [options] forwarding-rules insert -r ... [-p ...] [-o ] + compute1 [options] forwarding-rules list [-p ...] [-o ] + compute1 [options] forwarding-rules set-target -r ... [-p ...] [-o ] + compute1 [options] global-addresses delete
[-p ...] [-o ] + compute1 [options] global-addresses get
[-p ...] [-o ] + compute1 [options] global-addresses insert -r ... [-p ...] [-o ] + compute1 [options] global-addresses list [-p ...] [-o ] + compute1 [options] global-forwarding-rules delete [-p ...] [-o ] + compute1 [options] global-forwarding-rules get [-p ...] [-o ] + compute1 [options] global-forwarding-rules insert -r ... [-p ...] [-o ] + compute1 [options] global-forwarding-rules list [-p ...] [-o ] + compute1 [options] global-forwarding-rules set-target -r ... [-p ...] [-o ] + compute1 [options] global-operations aggregated-list [-p ...] [-o ] + compute1 [options] global-operations delete [-p ...] + compute1 [options] global-operations get [-p ...] [-o ] + compute1 [options] global-operations list [-p ...] [-o ] + compute1 [options] http-health-checks delete [-p ...] [-o ] + compute1 [options] http-health-checks get [-p ...] [-o ] + compute1 [options] http-health-checks insert -r ... [-p ...] [-o ] + compute1 [options] http-health-checks list [-p ...] [-o ] + compute1 [options] http-health-checks patch -r ... [-p ...] [-o ] + compute1 [options] http-health-checks update -r ... [-p ...] [-o ] + compute1 [options] images delete [-p ...] [-o ] + compute1 [options] images deprecate -r ... [-p ...] [-o ] + compute1 [options] images get [-p ...] [-o ] + compute1 [options] images insert -r ... [-p ...] [-o ] + compute1 [options] images list [-p ...] [-o ] + compute1 [options] instance-templates delete [-p ...] [-o ] + compute1 [options] instance-templates get [-p ...] [-o ] + compute1 [options] instance-templates insert -r ... [-p ...] [-o ] + compute1 [options] instance-templates list [-p ...] [-o ] + compute1 [options] instances add-access-config -r ... [-p ...] [-o ] + compute1 [options] instances aggregated-list [-p ...] [-o ] + compute1 [options] instances attach-disk -r ... [-p ...] [-o ] + compute1 [options] instances delete [-p ...] [-o ] + compute1 [options] instances delete-access-config [-p ...] [-o ] + compute1 [options] instances detach-disk [-p ...] [-o ] + compute1 [options] instances get [-p ...] [-o ] + compute1 [options] instances get-serial-port-output [-p ...] [-o ] + compute1 [options] instances insert -r ... [-p ...] [-o ] + compute1 [options] instances list [-p ...] [-o ] + compute1 [options] instances reset [-p ...] [-o ] + compute1 [options] instances set-disk-auto-delete [-p ...] [-o ] + compute1 [options] instances set-metadata -r ... [-p ...] [-o ] + compute1 [options] instances set-scheduling -r ... [-p ...] [-o ] + compute1 [options] instances set-tags -r ... [-p ...] [-o ] + compute1 [options] instances start [-p ...] [-o ] + compute1 [options] instances stop [-p ...] [-o ] + compute1 [options] licenses get [-p ...] [-o ] + compute1 [options] machine-types aggregated-list [-p ...] [-o ] + compute1 [options] machine-types get [-p ...] [-o ] + compute1 [options] machine-types list [-p ...] [-o ] + compute1 [options] networks delete [-p ...] [-o ] + compute1 [options] networks get [-p ...] [-o ] + compute1 [options] networks insert -r ... [-p ...] [-o ] + compute1 [options] networks list [-p ...] [-o ] + compute1 [options] projects get [-p ...] [-o ] + compute1 [options] projects move-disk -r ... [-p ...] [-o ] + compute1 [options] projects move-instance -r ... [-p ...] [-o ] + compute1 [options] projects set-common-instance-metadata -r ... [-p ...] [-o ] + compute1 [options] projects set-usage-export-bucket -r ... [-p ...] [-o ] + compute1 [options] region-operations delete [-p ...] + compute1 [options] region-operations get [-p ...] [-o ] + compute1 [options] region-operations list [-p ...] [-o ] + compute1 [options] regions get [-p ...] [-o ] + compute1 [options] regions list [-p ...] [-o ] + compute1 [options] routes delete [-p ...] [-o ] + compute1 [options] routes get [-p ...] [-o ] + compute1 [options] routes insert -r ... [-p ...] [-o ] + compute1 [options] routes list [-p ...] [-o ] + compute1 [options] snapshots delete [-p ...] [-o ] + compute1 [options] snapshots get [-p ...] [-o ] + compute1 [options] snapshots list [-p ...] [-o ] + compute1 [options] target-http-proxies delete [-p ...] [-o ] + compute1 [options] target-http-proxies get [-p ...] [-o ] + compute1 [options] target-http-proxies insert -r ... [-p ...] [-o ] + compute1 [options] target-http-proxies list [-p ...] [-o ] + compute1 [options] target-http-proxies set-url-map -r ... [-p ...] [-o ] + compute1 [options] target-instances aggregated-list [-p ...] [-o ] + compute1 [options] target-instances delete [-p ...] [-o ] + compute1 [options] target-instances get [-p ...] [-o ] + compute1 [options] target-instances insert -r ... [-p ...] [-o ] + compute1 [options] target-instances list [-p ...] [-o ] + compute1 [options] target-pools add-health-check -r ... [-p ...] [-o ] + compute1 [options] target-pools add-instance -r ... [-p ...] [-o ] + compute1 [options] target-pools aggregated-list [-p ...] [-o ] + compute1 [options] target-pools delete [-p ...] [-o ] + compute1 [options] target-pools get [-p ...] [-o ] + compute1 [options] target-pools get-health -r ... [-p ...] [-o ] + compute1 [options] target-pools insert -r ... [-p ...] [-o ] + compute1 [options] target-pools list [-p ...] [-o ] + compute1 [options] target-pools remove-health-check -r ... [-p ...] [-o ] + compute1 [options] target-pools remove-instance -r ... [-p ...] [-o ] + compute1 [options] target-pools set-backup -r ... [-p ...] [-o ] + compute1 [options] target-vpn-gateways aggregated-list [-p ...] [-o ] + compute1 [options] target-vpn-gateways delete [-p ...] [-o ] + compute1 [options] target-vpn-gateways get [-p ...] [-o ] + compute1 [options] target-vpn-gateways insert -r ... [-p ...] [-o ] + compute1 [options] target-vpn-gateways list [-p ...] [-o ] + compute1 [options] url-maps delete [-p ...] [-o ] + compute1 [options] url-maps get [-p ...] [-o ] + compute1 [options] url-maps insert -r ... [-p ...] [-o ] + compute1 [options] url-maps list [-p ...] [-o ] + compute1 [options] url-maps patch -r ... [-p ...] [-o ] + compute1 [options] url-maps update -r ... [-p ...] [-o ] + compute1 [options] url-maps validate -r ... [-p ...] [-o ] + compute1 [options] vpn-tunnels aggregated-list [-p ...] [-o ] + compute1 [options] vpn-tunnels delete [-p ...] [-o ] + compute1 [options] vpn-tunnels get [-p ...] [-o ] + compute1 [options] vpn-tunnels insert -r ... [-p ...] [-o ] + compute1 [options] vpn-tunnels list [-p ...] [-o ] + compute1 [options] zone-operations delete [-p ...] + compute1 [options] zone-operations get [-p ...] [-o ] + compute1 [options] zone-operations list [-p ...] [-o ] + compute1 [options] zones get [-p ...] [-o ] + compute1 [options] zones list [-p ...] [-o ] + compute1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_compute1_cli/index.html + +Configuration: + --scope + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `compute1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/compute1-token-.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/compute1-secret.json`, assuming that the required *compute* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `compute1 --debug [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/compute1-cli/mkdocs.yml b/gen/compute1-cli/mkdocs.yml index 62d86dc9e0..6d94e9211b 100644 --- a/gen/compute1-cli/mkdocs.yml +++ b/gen/compute1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: compute v0.0.1+20150326 +site_name: compute v0.1.0+20150326 site_url: http://byron.github.io/google-apis-rs/google-compute1-cli site_description: Write integrating applications with bcore diff --git a/gen/compute1-cli/src/cmn.rs b/gen/compute1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/compute1-cli/src/cmn.rs +++ b/gen/compute1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/compute1-cli/src/main.rs b/gen/compute1-cli/src/main.rs index ee1654fd5d..dbe435f712 100644 --- a/gen/compute1-cli/src/main.rs +++ b/gen/compute1-cli/src/main.rs @@ -19,171 +19,172 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - compute1 [options] addresses aggregated-list [-p ]... [-o ] - compute1 [options] addresses delete
[-p ]... [-o ] - compute1 [options] addresses get
[-p ]... [-o ] - compute1 [options] addresses insert -r ... [-p ]... [-o ] - compute1 [options] addresses list [-p ]... [-o ] - compute1 [options] backend-services delete [-p ]... [-o ] - compute1 [options] backend-services get [-p ]... [-o ] - compute1 [options] backend-services get-health -r ... [-p ]... [-o ] - compute1 [options] backend-services insert -r ... [-p ]... [-o ] - compute1 [options] backend-services list [-p ]... [-o ] - compute1 [options] backend-services patch -r ... [-p ]... [-o ] - compute1 [options] backend-services update -r ... [-p ]... [-o ] - compute1 [options] disk-types aggregated-list [-p ]... [-o ] - compute1 [options] disk-types get [-p ]... [-o ] - compute1 [options] disk-types list [-p ]... [-o ] - compute1 [options] disks aggregated-list [-p ]... [-o ] - compute1 [options] disks create-snapshot -r ... [-p ]... [-o ] - compute1 [options] disks delete [-p ]... [-o ] - compute1 [options] disks get [-p ]... [-o ] - compute1 [options] disks insert -r ... [-p ]... [-o ] - compute1 [options] disks list [-p ]... [-o ] - compute1 [options] firewalls delete [-p ]... [-o ] - compute1 [options] firewalls get [-p ]... [-o ] - compute1 [options] firewalls insert -r ... [-p ]... [-o ] - compute1 [options] firewalls list [-p ]... [-o ] - compute1 [options] firewalls patch -r ... [-p ]... [-o ] - compute1 [options] firewalls update -r ... [-p ]... [-o ] - compute1 [options] forwarding-rules aggregated-list [-p ]... [-o ] - compute1 [options] forwarding-rules delete [-p ]... [-o ] - compute1 [options] forwarding-rules get [-p ]... [-o ] - compute1 [options] forwarding-rules insert -r ... [-p ]... [-o ] - compute1 [options] forwarding-rules list [-p ]... [-o ] - compute1 [options] forwarding-rules set-target -r ... [-p ]... [-o ] - compute1 [options] global-addresses delete
[-p ]... [-o ] - compute1 [options] global-addresses get
[-p ]... [-o ] - compute1 [options] global-addresses insert -r ... [-p ]... [-o ] - compute1 [options] global-addresses list [-p ]... [-o ] - compute1 [options] global-forwarding-rules delete [-p ]... [-o ] - compute1 [options] global-forwarding-rules get [-p ]... [-o ] - compute1 [options] global-forwarding-rules insert -r ... [-p ]... [-o ] - compute1 [options] global-forwarding-rules list [-p ]... [-o ] - compute1 [options] global-forwarding-rules set-target -r ... [-p ]... [-o ] - compute1 [options] global-operations aggregated-list [-p ]... [-o ] - compute1 [options] global-operations delete [-p ]... - compute1 [options] global-operations get [-p ]... [-o ] - compute1 [options] global-operations list [-p ]... [-o ] - compute1 [options] http-health-checks delete [-p ]... [-o ] - compute1 [options] http-health-checks get [-p ]... [-o ] - compute1 [options] http-health-checks insert -r ... [-p ]... [-o ] - compute1 [options] http-health-checks list [-p ]... [-o ] - compute1 [options] http-health-checks patch -r ... [-p ]... [-o ] - compute1 [options] http-health-checks update -r ... [-p ]... [-o ] - compute1 [options] images delete [-p ]... [-o ] - compute1 [options] images deprecate -r ... [-p ]... [-o ] - compute1 [options] images get [-p ]... [-o ] - compute1 [options] images insert -r ... [-p ]... [-o ] - compute1 [options] images list [-p ]... [-o ] - compute1 [options] instance-templates delete [-p ]... [-o ] - compute1 [options] instance-templates get [-p ]... [-o ] - compute1 [options] instance-templates insert -r ... [-p ]... [-o ] - compute1 [options] instance-templates list [-p ]... [-o ] - compute1 [options] instances add-access-config -r ... [-p ]... [-o ] - compute1 [options] instances aggregated-list [-p ]... [-o ] - compute1 [options] instances attach-disk -r ... [-p ]... [-o ] - compute1 [options] instances delete [-p ]... [-o ] - compute1 [options] instances delete-access-config [-p ]... [-o ] - compute1 [options] instances detach-disk [-p ]... [-o ] - compute1 [options] instances get [-p ]... [-o ] - compute1 [options] instances get-serial-port-output [-p ]... [-o ] - compute1 [options] instances insert -r ... [-p ]... [-o ] - compute1 [options] instances list [-p ]... [-o ] - compute1 [options] instances reset [-p ]... [-o ] - compute1 [options] instances set-disk-auto-delete [-p ]... [-o ] - compute1 [options] instances set-metadata -r ... [-p ]... [-o ] - compute1 [options] instances set-scheduling -r ... [-p ]... [-o ] - compute1 [options] instances set-tags -r ... [-p ]... [-o ] - compute1 [options] instances start [-p ]... [-o ] - compute1 [options] instances stop [-p ]... [-o ] - compute1 [options] licenses get [-p ]... [-o ] - compute1 [options] machine-types aggregated-list [-p ]... [-o ] - compute1 [options] machine-types get [-p ]... [-o ] - compute1 [options] machine-types list [-p ]... [-o ] - compute1 [options] networks delete [-p ]... [-o ] - compute1 [options] networks get [-p ]... [-o ] - compute1 [options] networks insert -r ... [-p ]... [-o ] - compute1 [options] networks list [-p ]... [-o ] - compute1 [options] projects get [-p ]... [-o ] - compute1 [options] projects move-disk -r ... [-p ]... [-o ] - compute1 [options] projects move-instance -r ... [-p ]... [-o ] - compute1 [options] projects set-common-instance-metadata -r ... [-p ]... [-o ] - compute1 [options] projects set-usage-export-bucket -r ... [-p ]... [-o ] - compute1 [options] region-operations delete [-p ]... - compute1 [options] region-operations get [-p ]... [-o ] - compute1 [options] region-operations list [-p ]... [-o ] - compute1 [options] regions get [-p ]... [-o ] - compute1 [options] regions list [-p ]... [-o ] - compute1 [options] routes delete [-p ]... [-o ] - compute1 [options] routes get [-p ]... [-o ] - compute1 [options] routes insert -r ... [-p ]... [-o ] - compute1 [options] routes list [-p ]... [-o ] - compute1 [options] snapshots delete [-p ]... [-o ] - compute1 [options] snapshots get [-p ]... [-o ] - compute1 [options] snapshots list [-p ]... [-o ] - compute1 [options] target-http-proxies delete [-p ]... [-o ] - compute1 [options] target-http-proxies get [-p ]... [-o ] - compute1 [options] target-http-proxies insert -r ... [-p ]... [-o ] - compute1 [options] target-http-proxies list [-p ]... [-o ] - compute1 [options] target-http-proxies set-url-map -r ... [-p ]... [-o ] - compute1 [options] target-instances aggregated-list [-p ]... [-o ] - compute1 [options] target-instances delete [-p ]... [-o ] - compute1 [options] target-instances get [-p ]... [-o ] - compute1 [options] target-instances insert -r ... [-p ]... [-o ] - compute1 [options] target-instances list [-p ]... [-o ] - compute1 [options] target-pools add-health-check -r ... [-p ]... [-o ] - compute1 [options] target-pools add-instance -r ... [-p ]... [-o ] - compute1 [options] target-pools aggregated-list [-p ]... [-o ] - compute1 [options] target-pools delete [-p ]... [-o ] - compute1 [options] target-pools get [-p ]... [-o ] - compute1 [options] target-pools get-health -r ... [-p ]... [-o ] - compute1 [options] target-pools insert -r ... [-p ]... [-o ] - compute1 [options] target-pools list [-p ]... [-o ] - compute1 [options] target-pools remove-health-check -r ... [-p ]... [-o ] - compute1 [options] target-pools remove-instance -r ... [-p ]... [-o ] - compute1 [options] target-pools set-backup -r ... [-p ]... [-o ] - compute1 [options] target-vpn-gateways aggregated-list [-p ]... [-o ] - compute1 [options] target-vpn-gateways delete [-p ]... [-o ] - compute1 [options] target-vpn-gateways get [-p ]... [-o ] - compute1 [options] target-vpn-gateways insert -r ... [-p ]... [-o ] - compute1 [options] target-vpn-gateways list [-p ]... [-o ] - compute1 [options] url-maps delete [-p ]... [-o ] - compute1 [options] url-maps get [-p ]... [-o ] - compute1 [options] url-maps insert -r ... [-p ]... [-o ] - compute1 [options] url-maps list [-p ]... [-o ] - compute1 [options] url-maps patch -r ... [-p ]... [-o ] - compute1 [options] url-maps update -r ... [-p ]... [-o ] - compute1 [options] url-maps validate -r ... [-p ]... [-o ] - compute1 [options] vpn-tunnels aggregated-list [-p ]... [-o ] - compute1 [options] vpn-tunnels delete [-p ]... [-o ] - compute1 [options] vpn-tunnels get [-p ]... [-o ] - compute1 [options] vpn-tunnels insert -r ... [-p ]... [-o ] - compute1 [options] vpn-tunnels list [-p ]... [-o ] - compute1 [options] zone-operations delete [-p ]... - compute1 [options] zone-operations get [-p ]... [-o ] - compute1 [options] zone-operations list [-p ]... [-o ] - compute1 [options] zones get [-p ]... [-o ] - compute1 [options] zones list [-p ]... [-o ] + compute1 [options] addresses aggregated-list [-p ...] [-o ] + compute1 [options] addresses delete
[-p ...] [-o ] + compute1 [options] addresses get
[-p ...] [-o ] + compute1 [options] addresses insert -r ... [-p ...] [-o ] + compute1 [options] addresses list [-p ...] [-o ] + compute1 [options] backend-services delete [-p ...] [-o ] + compute1 [options] backend-services get [-p ...] [-o ] + compute1 [options] backend-services get-health -r ... [-p ...] [-o ] + compute1 [options] backend-services insert -r ... [-p ...] [-o ] + compute1 [options] backend-services list [-p ...] [-o ] + compute1 [options] backend-services patch -r ... [-p ...] [-o ] + compute1 [options] backend-services update -r ... [-p ...] [-o ] + compute1 [options] disk-types aggregated-list [-p ...] [-o ] + compute1 [options] disk-types get [-p ...] [-o ] + compute1 [options] disk-types list [-p ...] [-o ] + compute1 [options] disks aggregated-list [-p ...] [-o ] + compute1 [options] disks create-snapshot -r ... [-p ...] [-o ] + compute1 [options] disks delete [-p ...] [-o ] + compute1 [options] disks get [-p ...] [-o ] + compute1 [options] disks insert -r ... [-p ...] [-o ] + compute1 [options] disks list [-p ...] [-o ] + compute1 [options] firewalls delete [-p ...] [-o ] + compute1 [options] firewalls get [-p ...] [-o ] + compute1 [options] firewalls insert -r ... [-p ...] [-o ] + compute1 [options] firewalls list [-p ...] [-o ] + compute1 [options] firewalls patch -r ... [-p ...] [-o ] + compute1 [options] firewalls update -r ... [-p ...] [-o ] + compute1 [options] forwarding-rules aggregated-list [-p ...] [-o ] + compute1 [options] forwarding-rules delete [-p ...] [-o ] + compute1 [options] forwarding-rules get [-p ...] [-o ] + compute1 [options] forwarding-rules insert -r ... [-p ...] [-o ] + compute1 [options] forwarding-rules list [-p ...] [-o ] + compute1 [options] forwarding-rules set-target -r ... [-p ...] [-o ] + compute1 [options] global-addresses delete
[-p ...] [-o ] + compute1 [options] global-addresses get
[-p ...] [-o ] + compute1 [options] global-addresses insert -r ... [-p ...] [-o ] + compute1 [options] global-addresses list [-p ...] [-o ] + compute1 [options] global-forwarding-rules delete [-p ...] [-o ] + compute1 [options] global-forwarding-rules get [-p ...] [-o ] + compute1 [options] global-forwarding-rules insert -r ... [-p ...] [-o ] + compute1 [options] global-forwarding-rules list [-p ...] [-o ] + compute1 [options] global-forwarding-rules set-target -r ... [-p ...] [-o ] + compute1 [options] global-operations aggregated-list [-p ...] [-o ] + compute1 [options] global-operations delete [-p ...] + compute1 [options] global-operations get [-p ...] [-o ] + compute1 [options] global-operations list [-p ...] [-o ] + compute1 [options] http-health-checks delete [-p ...] [-o ] + compute1 [options] http-health-checks get [-p ...] [-o ] + compute1 [options] http-health-checks insert -r ... [-p ...] [-o ] + compute1 [options] http-health-checks list [-p ...] [-o ] + compute1 [options] http-health-checks patch -r ... [-p ...] [-o ] + compute1 [options] http-health-checks update -r ... [-p ...] [-o ] + compute1 [options] images delete [-p ...] [-o ] + compute1 [options] images deprecate -r ... [-p ...] [-o ] + compute1 [options] images get [-p ...] [-o ] + compute1 [options] images insert -r ... [-p ...] [-o ] + compute1 [options] images list [-p ...] [-o ] + compute1 [options] instance-templates delete [-p ...] [-o ] + compute1 [options] instance-templates get [-p ...] [-o ] + compute1 [options] instance-templates insert -r ... [-p ...] [-o ] + compute1 [options] instance-templates list [-p ...] [-o ] + compute1 [options] instances add-access-config -r ... [-p ...] [-o ] + compute1 [options] instances aggregated-list [-p ...] [-o ] + compute1 [options] instances attach-disk -r ... [-p ...] [-o ] + compute1 [options] instances delete [-p ...] [-o ] + compute1 [options] instances delete-access-config [-p ...] [-o ] + compute1 [options] instances detach-disk [-p ...] [-o ] + compute1 [options] instances get [-p ...] [-o ] + compute1 [options] instances get-serial-port-output [-p ...] [-o ] + compute1 [options] instances insert -r ... [-p ...] [-o ] + compute1 [options] instances list [-p ...] [-o ] + compute1 [options] instances reset [-p ...] [-o ] + compute1 [options] instances set-disk-auto-delete [-p ...] [-o ] + compute1 [options] instances set-metadata -r ... [-p ...] [-o ] + compute1 [options] instances set-scheduling -r ... [-p ...] [-o ] + compute1 [options] instances set-tags -r ... [-p ...] [-o ] + compute1 [options] instances start [-p ...] [-o ] + compute1 [options] instances stop [-p ...] [-o ] + compute1 [options] licenses get [-p ...] [-o ] + compute1 [options] machine-types aggregated-list [-p ...] [-o ] + compute1 [options] machine-types get [-p ...] [-o ] + compute1 [options] machine-types list [-p ...] [-o ] + compute1 [options] networks delete [-p ...] [-o ] + compute1 [options] networks get [-p ...] [-o ] + compute1 [options] networks insert -r ... [-p ...] [-o ] + compute1 [options] networks list [-p ...] [-o ] + compute1 [options] projects get [-p ...] [-o ] + compute1 [options] projects move-disk -r ... [-p ...] [-o ] + compute1 [options] projects move-instance -r ... [-p ...] [-o ] + compute1 [options] projects set-common-instance-metadata -r ... [-p ...] [-o ] + compute1 [options] projects set-usage-export-bucket -r ... [-p ...] [-o ] + compute1 [options] region-operations delete [-p ...] + compute1 [options] region-operations get [-p ...] [-o ] + compute1 [options] region-operations list [-p ...] [-o ] + compute1 [options] regions get [-p ...] [-o ] + compute1 [options] regions list [-p ...] [-o ] + compute1 [options] routes delete [-p ...] [-o ] + compute1 [options] routes get [-p ...] [-o ] + compute1 [options] routes insert -r ... [-p ...] [-o ] + compute1 [options] routes list [-p ...] [-o ] + compute1 [options] snapshots delete [-p ...] [-o ] + compute1 [options] snapshots get [-p ...] [-o ] + compute1 [options] snapshots list [-p ...] [-o ] + compute1 [options] target-http-proxies delete [-p ...] [-o ] + compute1 [options] target-http-proxies get [-p ...] [-o ] + compute1 [options] target-http-proxies insert -r ... [-p ...] [-o ] + compute1 [options] target-http-proxies list [-p ...] [-o ] + compute1 [options] target-http-proxies set-url-map -r ... [-p ...] [-o ] + compute1 [options] target-instances aggregated-list [-p ...] [-o ] + compute1 [options] target-instances delete [-p ...] [-o ] + compute1 [options] target-instances get [-p ...] [-o ] + compute1 [options] target-instances insert -r ... [-p ...] [-o ] + compute1 [options] target-instances list [-p ...] [-o ] + compute1 [options] target-pools add-health-check -r ... [-p ...] [-o ] + compute1 [options] target-pools add-instance -r ... [-p ...] [-o ] + compute1 [options] target-pools aggregated-list [-p ...] [-o ] + compute1 [options] target-pools delete [-p ...] [-o ] + compute1 [options] target-pools get [-p ...] [-o ] + compute1 [options] target-pools get-health -r ... [-p ...] [-o ] + compute1 [options] target-pools insert -r ... [-p ...] [-o ] + compute1 [options] target-pools list [-p ...] [-o ] + compute1 [options] target-pools remove-health-check -r ... [-p ...] [-o ] + compute1 [options] target-pools remove-instance -r ... [-p ...] [-o ] + compute1 [options] target-pools set-backup -r ... [-p ...] [-o ] + compute1 [options] target-vpn-gateways aggregated-list [-p ...] [-o ] + compute1 [options] target-vpn-gateways delete [-p ...] [-o ] + compute1 [options] target-vpn-gateways get [-p ...] [-o ] + compute1 [options] target-vpn-gateways insert -r ... [-p ...] [-o ] + compute1 [options] target-vpn-gateways list [-p ...] [-o ] + compute1 [options] url-maps delete [-p ...] [-o ] + compute1 [options] url-maps get [-p ...] [-o ] + compute1 [options] url-maps insert -r ... [-p ...] [-o ] + compute1 [options] url-maps list [-p ...] [-o ] + compute1 [options] url-maps patch -r ... [-p ...] [-o ] + compute1 [options] url-maps update -r ... [-p ...] [-o ] + compute1 [options] url-maps validate -r ... [-p ...] [-o ] + compute1 [options] vpn-tunnels aggregated-list [-p ...] [-o ] + compute1 [options] vpn-tunnels delete [-p ...] [-o ] + compute1 [options] vpn-tunnels get [-p ...] [-o ] + compute1 [options] vpn-tunnels insert -r ... [-p ...] [-o ] + compute1 [options] vpn-tunnels list [-p ...] [-o ] + compute1 [options] zone-operations delete [-p ...] + compute1 [options] zone-operations get [-p ...] [-o ] + compute1 [options] zone-operations list [-p ...] [-o ] + compute1 [options] zones get [-p ...] [-o ] + compute1 [options] zones list [-p ...] [-o ] compute1 --help -All documentation details can be found TODO: +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_compute1_cli/index.html Configuration: --scope - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -241,6 +242,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -284,6 +288,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -327,6 +334,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -343,37 +353,24 @@ impl Engine { fn _addresses_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Address::default(); - let mut call = self.hub.addresses().insert(&request, &self.opt.arg_project, &self.opt.arg_region); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Address::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -408,15 +405,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.addresses().insert(request, &self.opt.arg_project, &self.opt.arg_region); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -469,6 +491,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -512,6 +537,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -555,6 +583,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -571,8 +602,33 @@ impl Engine { fn _backend_services_get_health(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::ResourceGroupReference::default(); - let mut call = self.hub.backend_services().get_health(&request, &self.opt.arg_project, &self.opt.arg_backend_service); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "group" => { + request.group = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.backend_services().get_health(request, &self.opt.arg_project, &self.opt.arg_backend_service); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -594,27 +650,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "group" => { - request.group = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -631,37 +674,24 @@ impl Engine { fn _backend_services_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::BackendService::default(); - let mut call = self.hub.backend_services().insert(&request, &self.opt.arg_project); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::BackendService::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -702,15 +732,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.backend_services().insert(request, &self.opt.arg_project); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -763,6 +818,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -779,37 +837,24 @@ impl Engine { fn _backend_services_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::BackendService::default(); - let mut call = self.hub.backend_services().patch(&request, &self.opt.arg_project, &self.opt.arg_backend_service); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::BackendService::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -850,15 +895,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.backend_services().patch(request, &self.opt.arg_project, &self.opt.arg_backend_service); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -875,37 +945,24 @@ impl Engine { fn _backend_services_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::BackendService::default(); - let mut call = self.hub.backend_services().update(&request, &self.opt.arg_project, &self.opt.arg_backend_service); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::BackendService::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -946,15 +1003,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.backend_services().update(request, &self.opt.arg_project, &self.opt.arg_backend_service); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1007,6 +1089,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1050,6 +1135,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1102,6 +1190,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1154,6 +1245,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1170,37 +1264,24 @@ impl Engine { fn _disks_create_snapshot(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Snapshot::default(); - let mut call = self.hub.disks().create_snapshot(&request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_disk); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Snapshot::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -1244,15 +1325,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.disks().create_snapshot(request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_disk); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1296,6 +1402,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1339,6 +1448,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1355,40 +1467,24 @@ impl Engine { fn _disks_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Disk::default(); - let mut call = self.hub.disks().insert(&request, &self.opt.arg_project, &self.opt.arg_zone); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "source-image" => { - call = call.source_image(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Disk::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -1441,15 +1537,43 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.disks().insert(request, &self.opt.arg_project, &self.opt.arg_zone); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "source-image" => { + call = call.source_image(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1502,6 +1626,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1545,6 +1672,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1588,6 +1718,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1604,37 +1737,24 @@ impl Engine { fn _firewalls_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Firewall::default(); - let mut call = self.hub.firewalls().insert(&request, &self.opt.arg_project); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Firewall::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1675,15 +1795,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.firewalls().insert(request, &self.opt.arg_project); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1736,6 +1881,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1752,37 +1900,24 @@ impl Engine { fn _firewalls_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Firewall::default(); - let mut call = self.hub.firewalls().patch(&request, &self.opt.arg_project, &self.opt.arg_firewall); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Firewall::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1823,15 +1958,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.firewalls().patch(request, &self.opt.arg_project, &self.opt.arg_firewall); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1848,37 +2008,24 @@ impl Engine { fn _firewalls_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Firewall::default(); - let mut call = self.hub.firewalls().update(&request, &self.opt.arg_project, &self.opt.arg_firewall); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Firewall::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1919,15 +2066,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.firewalls().update(request, &self.opt.arg_project, &self.opt.arg_firewall); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1980,6 +2152,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2023,6 +2198,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2066,6 +2244,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2082,37 +2263,24 @@ impl Engine { fn _forwarding_rules_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::ForwardingRule::default(); - let mut call = self.hub.forwarding_rules().insert(&request, &self.opt.arg_project, &self.opt.arg_region); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ForwardingRule::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -2147,15 +2315,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.forwarding_rules().insert(request, &self.opt.arg_project, &self.opt.arg_region); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2208,6 +2401,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2224,8 +2420,33 @@ impl Engine { fn _forwarding_rules_set_target(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::TargetReference::default(); - let mut call = self.hub.forwarding_rules().set_target(&request, &self.opt.arg_project, &self.opt.arg_region, &self.opt.arg_forwarding_rule); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "target" => { + request.target = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.forwarding_rules().set_target(request, &self.opt.arg_project, &self.opt.arg_region, &self.opt.arg_forwarding_rule); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2247,27 +2468,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "target" => { - request.target = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2311,6 +2519,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2354,6 +2565,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2370,37 +2584,24 @@ impl Engine { fn _global_addresses_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Address::default(); - let mut call = self.hub.global_addresses().insert(&request, &self.opt.arg_project); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Address::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -2435,15 +2636,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.global_addresses().insert(request, &self.opt.arg_project); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2496,6 +2722,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2539,6 +2768,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2582,6 +2814,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2598,37 +2833,24 @@ impl Engine { fn _global_forwarding_rules_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::ForwardingRule::default(); - let mut call = self.hub.global_forwarding_rules().insert(&request, &self.opt.arg_project); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ForwardingRule::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -2663,15 +2885,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.global_forwarding_rules().insert(request, &self.opt.arg_project); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2724,6 +2971,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2740,8 +2990,33 @@ impl Engine { fn _global_forwarding_rules_set_target(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::TargetReference::default(); - let mut call = self.hub.global_forwarding_rules().set_target(&request, &self.opt.arg_project, &self.opt.arg_forwarding_rule); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "target" => { + request.target = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.global_forwarding_rules().set_target(request, &self.opt.arg_project, &self.opt.arg_forwarding_rule); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2763,27 +3038,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "target" => { - request.target = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2836,6 +3098,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2879,6 +3144,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2920,6 +3188,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2972,6 +3243,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3015,6 +3289,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3058,6 +3335,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3074,37 +3354,24 @@ impl Engine { fn _http_health_checks_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::HttpHealthCheck::default(); - let mut call = self.hub.http_health_checks().insert(&request, &self.opt.arg_project); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::HttpHealthCheck::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -3145,15 +3412,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.http_health_checks().insert(request, &self.opt.arg_project); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3206,6 +3498,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3222,37 +3517,24 @@ impl Engine { fn _http_health_checks_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::HttpHealthCheck::default(); - let mut call = self.hub.http_health_checks().patch(&request, &self.opt.arg_project, &self.opt.arg_http_health_check); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::HttpHealthCheck::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -3293,15 +3575,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.http_health_checks().patch(request, &self.opt.arg_project, &self.opt.arg_http_health_check); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3318,37 +3625,24 @@ impl Engine { fn _http_health_checks_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::HttpHealthCheck::default(); - let mut call = self.hub.http_health_checks().update(&request, &self.opt.arg_project, &self.opt.arg_http_health_check); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::HttpHealthCheck::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -3389,15 +3683,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.http_health_checks().update(request, &self.opt.arg_project, &self.opt.arg_http_health_check); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3441,6 +3760,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3457,8 +3779,45 @@ impl Engine { fn _images_deprecate(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::DeprecationStatus::default(); - let mut call = self.hub.images().deprecate(&request, &self.opt.arg_project, &self.opt.arg_image); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "deleted" => { + request.deleted = Some(value.unwrap_or("").to_string()); + }, + "deprecated" => { + request.deprecated = Some(value.unwrap_or("").to_string()); + }, + "state" => { + request.state = Some(value.unwrap_or("").to_string()); + }, + "obsolete" => { + request.obsolete = Some(value.unwrap_or("").to_string()); + }, + "replacement" => { + request.replacement = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.images().deprecate(request, &self.opt.arg_project, &self.opt.arg_image); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -3480,39 +3839,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "deleted" => { - request.deleted = Some(value.unwrap_or("").to_string()); - }, - "deprecated" => { - request.deprecated = Some(value.unwrap_or("").to_string()); - }, - "state" => { - request.state = Some(value.unwrap_or("").to_string()); - }, - "obsolete" => { - request.obsolete = Some(value.unwrap_or("").to_string()); - }, - "replacement" => { - request.replacement = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3556,6 +3890,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3572,36 +3909,23 @@ impl Engine { fn _images_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Image::default(); - let mut call = self.hub.images().insert(&request, &self.opt.arg_project); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Image::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_deprecated_init(request: &mut api::Image) { if request.deprecated.is_none() { request.deprecated = Some(Default::default()); @@ -3614,7 +3938,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -3700,15 +4024,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.images().insert(request, &self.opt.arg_project); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3761,6 +4110,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3804,6 +4156,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3847,6 +4202,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3863,36 +4221,23 @@ impl Engine { fn _instance_templates_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::InstanceTemplate::default(); - let mut call = self.hub.instance_templates().insert(&request, &self.opt.arg_project); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::InstanceTemplate::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_properties_init(request: &mut api::InstanceTemplate) { if request.properties.is_none() { request.properties = Some(Default::default()); @@ -3920,7 +4265,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -3981,15 +4326,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.instance_templates().insert(request, &self.opt.arg_project); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4042,6 +4412,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4058,8 +4431,42 @@ impl Engine { fn _instances_add_access_config(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::AccessConfig::default(); - let mut call = self.hub.instances().add_access_config(&request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_instance, &self.opt.arg_network_interface); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "type" => { + request.type_ = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + "nat-ip" => { + request.nat_ip = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.instances().add_access_config(request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_instance, &self.opt.arg_network_interface); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -4081,36 +4488,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "type" => { - request.type_ = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "nat-ip" => { - request.nat_ip = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4163,6 +4548,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4179,43 +4567,30 @@ impl Engine { fn _instances_attach_disk(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::AttachedDisk::default(); - let mut call = self.hub.instances().attach_disk(&request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_instance); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::AttachedDisk::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_initialize_params_init(request: &mut api::AttachedDisk) { if request.initialize_params.is_none() { request.initialize_params = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "device-name" => { request.device_name = Some(value.unwrap_or("").to_string()); }, @@ -4274,15 +4649,40 @@ impl Engine { request.source = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.instances().attach_disk(request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_instance); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4326,6 +4726,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4369,6 +4772,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4412,6 +4818,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4455,6 +4864,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4501,6 +4913,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4517,36 +4932,23 @@ impl Engine { fn _instances_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Instance::default(); - let mut call = self.hub.instances().insert(&request, &self.opt.arg_project, &self.opt.arg_zone); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Instance::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_metadata_init(request: &mut api::Instance) { if request.metadata.is_none() { request.metadata = Some(Default::default()); @@ -4565,7 +4967,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "cpu-platform" => { request.cpu_platform = Some(value.unwrap_or("").to_string()); }, @@ -4636,15 +5038,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.instances().insert(request, &self.opt.arg_project, &self.opt.arg_zone); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4697,6 +5124,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4740,6 +5170,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4784,6 +5217,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4800,8 +5236,36 @@ impl Engine { fn _instances_set_metadata(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Metadata::default(); - let mut call = self.hub.instances().set_metadata(&request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_instance); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "fingerprint" => { + request.fingerprint = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.instances().set_metadata(request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_instance); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -4823,30 +5287,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "fingerprint" => { - request.fingerprint = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4863,8 +5311,36 @@ impl Engine { fn _instances_set_scheduling(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Scheduling::default(); - let mut call = self.hub.instances().set_scheduling(&request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_instance); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "automatic-restart" => { + request.automatic_restart = Some(arg_from_str(value.unwrap_or("false"), err, "automatic-restart", "boolean")); + }, + "on-host-maintenance" => { + request.on_host_maintenance = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.instances().set_scheduling(request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_instance); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -4886,30 +5362,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "automatic-restart" => { - request.automatic_restart = Some(arg_from_str(value.unwrap_or("false"), err, "automatic-restart", "boolean")); - }, - "on-host-maintenance" => { - request.on_host_maintenance = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4926,8 +5386,39 @@ impl Engine { fn _instances_set_tags(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Tags::default(); - let mut call = self.hub.instances().set_tags(&request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_instance); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "items" => { + if request.items.is_none() { + request.items = Some(Default::default()); + } + request.items.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "fingerprint" => { + request.fingerprint = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.instances().set_tags(request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_instance); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -4949,33 +5440,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "items" => { - if request.items.is_none() { - request.items = Some(Default::default()); - } - request.items.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "fingerprint" => { - request.fingerprint = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5019,6 +5491,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5062,6 +5537,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5105,6 +5583,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5157,6 +5638,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5200,6 +5684,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5252,6 +5739,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5295,6 +5785,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5338,6 +5831,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5354,37 +5850,24 @@ impl Engine { fn _networks_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Network::default(); - let mut call = self.hub.networks().insert(&request, &self.opt.arg_project); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Network::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -5410,15 +5893,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.networks().insert(request, &self.opt.arg_project); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5471,6 +5979,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5514,6 +6025,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5530,8 +6044,36 @@ impl Engine { fn _projects_move_disk(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::DiskMoveRequest::default(); - let mut call = self.hub.projects().move_disk(&request, &self.opt.arg_project); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "target-disk" => { + request.target_disk = Some(value.unwrap_or("").to_string()); + }, + "destination-zone" => { + request.destination_zone = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.projects().move_disk(request, &self.opt.arg_project); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -5553,30 +6095,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "target-disk" => { - request.target_disk = Some(value.unwrap_or("").to_string()); - }, - "destination-zone" => { - request.destination_zone = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5593,8 +6119,36 @@ impl Engine { fn _projects_move_instance(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::InstanceMoveRequest::default(); - let mut call = self.hub.projects().move_instance(&request, &self.opt.arg_project); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "target-instance" => { + request.target_instance = Some(value.unwrap_or("").to_string()); + }, + "destination-zone" => { + request.destination_zone = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.projects().move_instance(request, &self.opt.arg_project); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -5616,30 +6170,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "target-instance" => { - request.target_instance = Some(value.unwrap_or("").to_string()); - }, - "destination-zone" => { - request.destination_zone = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5656,8 +6194,36 @@ impl Engine { fn _projects_set_common_instance_metadata(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::Metadata::default(); - let mut call = self.hub.projects().set_common_instance_metadata(&request, &self.opt.arg_project); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "fingerprint" => { + request.fingerprint = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.projects().set_common_instance_metadata(request, &self.opt.arg_project); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -5679,30 +6245,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "fingerprint" => { - request.fingerprint = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5719,8 +6269,36 @@ impl Engine { fn _projects_set_usage_export_bucket(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::UsageExportLocation::default(); - let mut call = self.hub.projects().set_usage_export_bucket(&request, &self.opt.arg_project); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "bucket-name" => { + request.bucket_name = Some(value.unwrap_or("").to_string()); + }, + "report-name-prefix" => { + request.report_name_prefix = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.projects().set_usage_export_bucket(request, &self.opt.arg_project); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -5742,30 +6320,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "bucket-name" => { - request.bucket_name = Some(value.unwrap_or("").to_string()); - }, - "report-name-prefix" => { - request.report_name_prefix = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5809,6 +6371,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -5850,6 +6415,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5902,6 +6470,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5945,6 +6516,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5997,6 +6571,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6040,6 +6617,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6083,6 +6663,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6099,37 +6682,24 @@ impl Engine { fn _routes_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Route::default(); - let mut call = self.hub.routes().insert(&request, &self.opt.arg_project); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Route::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "next-hop-gateway" => { request.next_hop_gateway = Some(value.unwrap_or("").to_string()); }, @@ -6179,15 +6749,40 @@ impl Engine { request.network = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.routes().insert(request, &self.opt.arg_project); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6240,6 +6835,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6283,6 +6881,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6326,6 +6927,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6378,6 +6982,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6421,6 +7028,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6464,6 +7074,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6480,37 +7093,24 @@ impl Engine { fn _target_http_proxies_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::TargetHttpProxy::default(); - let mut call = self.hub.target_http_proxies().insert(&request, &self.opt.arg_project); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::TargetHttpProxy::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -6533,15 +7133,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.target_http_proxies().insert(request, &self.opt.arg_project); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6594,6 +7219,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6610,8 +7238,33 @@ impl Engine { fn _target_http_proxies_set_url_map(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::UrlMapReference::default(); - let mut call = self.hub.target_http_proxies().set_url_map(&request, &self.opt.arg_project, &self.opt.arg_target_http_proxy); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "url-map" => { + request.url_map = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.target_http_proxies().set_url_map(request, &self.opt.arg_project, &self.opt.arg_target_http_proxy); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -6633,27 +7286,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "url-map" => { - request.url_map = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6706,6 +7346,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6749,6 +7392,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6792,6 +7438,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6808,37 +7457,24 @@ impl Engine { fn _target_instances_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::TargetInstance::default(); - let mut call = self.hub.target_instances().insert(&request, &self.opt.arg_project, &self.opt.arg_zone); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::TargetInstance::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "nat-policy" => { request.nat_policy = Some(value.unwrap_or("").to_string()); }, @@ -6867,15 +7503,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.target_instances().insert(request, &self.opt.arg_project, &self.opt.arg_zone); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6928,6 +7589,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6944,8 +7608,30 @@ impl Engine { fn _target_pools_add_health_check(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::TargetPoolsAddHealthCheckRequest::default(); - let mut call = self.hub.target_pools().add_health_check(&request, &self.opt.arg_project, &self.opt.arg_region, &self.opt.arg_target_pool); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.target_pools().add_health_check(request, &self.opt.arg_project, &self.opt.arg_region, &self.opt.arg_target_pool); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -6967,24 +7653,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7001,8 +7677,30 @@ impl Engine { fn _target_pools_add_instance(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::TargetPoolsAddInstanceRequest::default(); - let mut call = self.hub.target_pools().add_instance(&request, &self.opt.arg_project, &self.opt.arg_region, &self.opt.arg_target_pool); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.target_pools().add_instance(request, &self.opt.arg_project, &self.opt.arg_region, &self.opt.arg_target_pool); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -7024,24 +7722,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7094,6 +7782,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7137,6 +7828,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7180,6 +7874,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7196,8 +7893,33 @@ impl Engine { fn _target_pools_get_health(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::InstanceReference::default(); - let mut call = self.hub.target_pools().get_health(&request, &self.opt.arg_project, &self.opt.arg_region, &self.opt.arg_target_pool); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "instance" => { + request.instance = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.target_pools().get_health(request, &self.opt.arg_project, &self.opt.arg_region, &self.opt.arg_target_pool); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -7219,27 +7941,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "instance" => { - request.instance = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7256,37 +7965,24 @@ impl Engine { fn _target_pools_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::TargetPool::default(); - let mut call = self.hub.target_pools().insert(&request, &self.opt.arg_project, &self.opt.arg_region); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::TargetPool::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "failover-ratio" => { request.failover_ratio = Some(arg_from_str(value.unwrap_or("0.0"), err, "failover-ratio", "number")); }, @@ -7330,15 +8026,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.target_pools().insert(request, &self.opt.arg_project, &self.opt.arg_region); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7391,6 +8112,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7407,8 +8131,30 @@ impl Engine { fn _target_pools_remove_health_check(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::TargetPoolsRemoveHealthCheckRequest::default(); - let mut call = self.hub.target_pools().remove_health_check(&request, &self.opt.arg_project, &self.opt.arg_region, &self.opt.arg_target_pool); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.target_pools().remove_health_check(request, &self.opt.arg_project, &self.opt.arg_region, &self.opt.arg_target_pool); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -7430,24 +8176,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7464,8 +8200,30 @@ impl Engine { fn _target_pools_remove_instance(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::TargetPoolsRemoveInstanceRequest::default(); - let mut call = self.hub.target_pools().remove_instance(&request, &self.opt.arg_project, &self.opt.arg_region, &self.opt.arg_target_pool); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.target_pools().remove_instance(request, &self.opt.arg_project, &self.opt.arg_region, &self.opt.arg_target_pool); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -7487,24 +8245,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7521,8 +8269,33 @@ impl Engine { fn _target_pools_set_backup(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::TargetReference::default(); - let mut call = self.hub.target_pools().set_backup(&request, &self.opt.arg_project, &self.opt.arg_region, &self.opt.arg_target_pool); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "target" => { + request.target = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.target_pools().set_backup(request, &self.opt.arg_project, &self.opt.arg_region, &self.opt.arg_target_pool); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -7547,27 +8320,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "target" => { - request.target = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7620,6 +8380,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7663,6 +8426,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7706,6 +8472,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7722,37 +8491,24 @@ impl Engine { fn _target_vpn_gateways_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::TargetVpnGateway::default(); - let mut call = self.hub.target_vpn_gateways().insert(&request, &self.opt.arg_project, &self.opt.arg_region); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::TargetVpnGateway::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -7793,15 +8549,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.target_vpn_gateways().insert(request, &self.opt.arg_project, &self.opt.arg_region); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7854,6 +8635,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7897,6 +8681,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7940,6 +8727,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7956,37 +8746,24 @@ impl Engine { fn _url_maps_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::UrlMap::default(); - let mut call = self.hub.url_maps().insert(&request, &self.opt.arg_project); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::UrlMap::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -8012,15 +8789,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.url_maps().insert(request, &self.opt.arg_project); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -8073,6 +8875,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -8089,37 +8894,24 @@ impl Engine { fn _url_maps_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::UrlMap::default(); - let mut call = self.hub.url_maps().patch(&request, &self.opt.arg_project, &self.opt.arg_url_map); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::UrlMap::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -8145,15 +8937,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.url_maps().patch(request, &self.opt.arg_project, &self.opt.arg_url_map); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -8170,37 +8987,24 @@ impl Engine { fn _url_maps_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::UrlMap::default(); - let mut call = self.hub.url_maps().update(&request, &self.opt.arg_project, &self.opt.arg_url_map); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::UrlMap::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -8226,33 +9030,11 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _url_maps_validate(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request = api::UrlMapsValidateRequest::default(); - let mut call = self.hub.url_maps().validate(&request, &self.opt.arg_project, &self.opt.arg_url_map); + let mut call = self.hub.url_maps().update(request, &self.opt.arg_project, &self.opt.arg_url_map); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -8274,20 +9056,54 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _url_maps_validate(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option { - let mut field_name = FieldCursor::default(); + let mut request = api::UrlMapsValidateRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_resource_init(request: &mut api::UrlMapsValidateRequest) { if request.resource.is_none() { request.resource = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "resource.kind" => { request_resource_init(&mut request); request.resource.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); @@ -8321,15 +9137,40 @@ impl Engine { request.resource.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.url_maps().validate(request, &self.opt.arg_project, &self.opt.arg_url_map); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -8382,6 +9223,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -8425,6 +9269,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -8468,6 +9315,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -8484,37 +9334,24 @@ impl Engine { fn _vpn_tunnels_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::VpnTunnel::default(); - let mut call = self.hub.vpn_tunnels().insert(&request, &self.opt.arg_project, &self.opt.arg_region); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::VpnTunnel::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "detailed-status" => { request.detailed_status = Some(value.unwrap_or("").to_string()); }, @@ -8564,15 +9401,40 @@ impl Engine { request.ike_networks.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.vpn_tunnels().insert(request, &self.opt.arg_project, &self.opt.arg_region); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -8625,6 +9487,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -8668,6 +9533,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -8709,6 +9577,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -8761,6 +9632,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -8804,6 +9678,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -8856,6 +9733,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -9379,6 +10259,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -9386,8 +10267,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/compute1/Cargo.toml b/gen/compute1/Cargo.toml index 661c103fca..5e8f000051 100644 --- a/gen/compute1/Cargo.toml +++ b/gen/compute1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-compute1" -version = "0.1.5+20150326" +version = "0.1.6+20150326" authors = ["Sebastian Thiel "] description = "A complete library to interact with compute (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/compute1" diff --git a/gen/compute1/README.md b/gen/compute1/README.md index 7859aa2961..35b68170a3 100644 --- a/gen/compute1/README.md +++ b/gen/compute1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-compute1` library allows access to all features of the *Google compute* service. -This documentation was generated from *compute* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *compute:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *compute* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *compute:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *compute* *v1* API can be found at the [official documentation site](https://developers.google.com/compute/docs/reference/latest/). @@ -229,14 +229,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/compute1/src/cmn.rs b/gen/compute1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/compute1/src/cmn.rs +++ b/gen/compute1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option, + location: Option +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option, _: Option) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec]) -> Option { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/compute1/src/lib.rs b/gen/compute1/src/lib.rs index d5a5377619..d903aaf7e5 100644 --- a/gen/compute1/src/lib.rs +++ b/gen/compute1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *compute* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *compute:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *compute* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *compute:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *compute* *v1* API can be found at the //! [official documentation site](https://developers.google.com/compute/docs/reference/latest/). @@ -230,14 +230,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -325,7 +326,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -419,14 +420,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -447,7 +449,7 @@ impl<'a, C, A> Compute Compute { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -540,7 +542,7 @@ impl<'a, C, A> Compute } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -4547,10 +4549,10 @@ impl<'a, C, A> DiskMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Project ID for this request. /// * `zone` - The name of the zone for this request. - pub fn insert(&self, request: &Disk, project: &str, zone: &str) -> DiskInsertCall<'a, C, A> { + pub fn insert(&self, request: Disk, project: &str, zone: &str) -> DiskInsertCall<'a, C, A> { DiskInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _zone: zone.to_string(), _source_image: Default::default(), @@ -4570,10 +4572,10 @@ impl<'a, C, A> DiskMethods<'a, C, A> { /// * `project` - Project ID for this request. /// * `zone` - The name of the zone for this request. /// * `disk` - Name of the persistent disk to snapshot. - pub fn create_snapshot(&self, request: &Snapshot, project: &str, zone: &str, disk: &str) -> DiskCreateSnapshotCall<'a, C, A> { + pub fn create_snapshot(&self, request: Snapshot, project: &str, zone: &str, disk: &str) -> DiskCreateSnapshotCall<'a, C, A> { DiskCreateSnapshotCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _zone: zone.to_string(), _disk: disk.to_string(), @@ -4717,10 +4719,10 @@ impl<'a, C, A> AddresseMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Project ID for this request. /// * `region` - The name of the region for this request. - pub fn insert(&self, request: &Address, project: &str, region: &str) -> AddresseInsertCall<'a, C, A> { + pub fn insert(&self, request: Address, project: &str, region: &str) -> AddresseInsertCall<'a, C, A> { AddresseInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _region: region.to_string(), _delegate: Default::default(), @@ -4799,10 +4801,10 @@ impl<'a, C, A> UrlMapMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `project` - Name of the project scoping this request. - pub fn insert(&self, request: &UrlMap, project: &str) -> UrlMapInsertCall<'a, C, A> { + pub fn insert(&self, request: UrlMap, project: &str) -> UrlMapInsertCall<'a, C, A> { UrlMapInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -4838,10 +4840,10 @@ impl<'a, C, A> UrlMapMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Name of the project scoping this request. /// * `urlMap` - Name of the UrlMap resource to be validated as. - pub fn validate(&self, request: &UrlMapsValidateRequest, project: &str, url_map: &str) -> UrlMapValidateCall<'a, C, A> { + pub fn validate(&self, request: UrlMapsValidateRequest, project: &str, url_map: &str) -> UrlMapValidateCall<'a, C, A> { UrlMapValidateCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _url_map: url_map.to_string(), _delegate: Default::default(), @@ -4879,10 +4881,10 @@ impl<'a, C, A> UrlMapMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Name of the project scoping this request. /// * `urlMap` - Name of the UrlMap resource to update. - pub fn patch(&self, request: &UrlMap, project: &str, url_map: &str) -> UrlMapPatchCall<'a, C, A> { + pub fn patch(&self, request: UrlMap, project: &str, url_map: &str) -> UrlMapPatchCall<'a, C, A> { UrlMapPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _url_map: url_map.to_string(), _delegate: Default::default(), @@ -4900,10 +4902,10 @@ impl<'a, C, A> UrlMapMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Name of the project scoping this request. /// * `urlMap` - Name of the UrlMap resource to update. - pub fn update(&self, request: &UrlMap, project: &str, url_map: &str) -> UrlMapUpdateCall<'a, C, A> { + pub fn update(&self, request: UrlMap, project: &str, url_map: &str) -> UrlMapUpdateCall<'a, C, A> { UrlMapUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _url_map: url_map.to_string(), _delegate: Default::default(), @@ -4980,10 +4982,10 @@ impl<'a, C, A> GlobalAddresseMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `project` - Project ID for this request. - pub fn insert(&self, request: &Address, project: &str) -> GlobalAddresseInsertCall<'a, C, A> { + pub fn insert(&self, request: Address, project: &str) -> GlobalAddresseInsertCall<'a, C, A> { GlobalAddresseInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -5383,10 +5385,10 @@ impl<'a, C, A> InstanceMethods<'a, C, A> { /// * `project` - Project ID for this request. /// * `zone` - The name of the zone for this request. /// * `instance` - Instance name. - pub fn set_scheduling(&self, request: &Scheduling, project: &str, zone: &str, instance: &str) -> InstanceSetSchedulingCall<'a, C, A> { + pub fn set_scheduling(&self, request: Scheduling, project: &str, zone: &str, instance: &str) -> InstanceSetSchedulingCall<'a, C, A> { InstanceSetSchedulingCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _zone: zone.to_string(), _instance: instance.to_string(), @@ -5475,10 +5477,10 @@ impl<'a, C, A> InstanceMethods<'a, C, A> { /// * `zone` - The name of the zone for this request. /// * `instance` - The instance name for this request. /// * `networkInterface` - The name of the network interface to add to this instance. - pub fn add_access_config(&self, request: &AccessConfig, project: &str, zone: &str, instance: &str, network_interface: &str) -> InstanceAddAccessConfigCall<'a, C, A> { + pub fn add_access_config(&self, request: AccessConfig, project: &str, zone: &str, instance: &str, network_interface: &str) -> InstanceAddAccessConfigCall<'a, C, A> { InstanceAddAccessConfigCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _zone: zone.to_string(), _instance: instance.to_string(), @@ -5541,10 +5543,10 @@ impl<'a, C, A> InstanceMethods<'a, C, A> { /// * `project` - Project ID for this request. /// * `zone` - The name of the zone for this request. /// * `instance` - Name of the instance scoping this request. - pub fn set_tags(&self, request: &Tags, project: &str, zone: &str, instance: &str) -> InstanceSetTagCall<'a, C, A> { + pub fn set_tags(&self, request: Tags, project: &str, zone: &str, instance: &str) -> InstanceSetTagCall<'a, C, A> { InstanceSetTagCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _zone: zone.to_string(), _instance: instance.to_string(), @@ -5564,10 +5566,10 @@ impl<'a, C, A> InstanceMethods<'a, C, A> { /// * `project` - Project ID for this request. /// * `zone` - The name of the zone for this request. /// * `instance` - Name of the instance scoping this request. - pub fn set_metadata(&self, request: &Metadata, project: &str, zone: &str, instance: &str) -> InstanceSetMetadataCall<'a, C, A> { + pub fn set_metadata(&self, request: Metadata, project: &str, zone: &str, instance: &str) -> InstanceSetMetadataCall<'a, C, A> { InstanceSetMetadataCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _zone: zone.to_string(), _instance: instance.to_string(), @@ -5630,10 +5632,10 @@ impl<'a, C, A> InstanceMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Project ID for this request. /// * `zone` - The name of the zone for this request. - pub fn insert(&self, request: &Instance, project: &str, zone: &str) -> InstanceInsertCall<'a, C, A> { + pub fn insert(&self, request: Instance, project: &str, zone: &str) -> InstanceInsertCall<'a, C, A> { InstanceInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _zone: zone.to_string(), _delegate: Default::default(), @@ -5698,10 +5700,10 @@ impl<'a, C, A> InstanceMethods<'a, C, A> { /// * `project` - Project ID for this request. /// * `zone` - The name of the zone for this request. /// * `instance` - Instance name. - pub fn attach_disk(&self, request: &AttachedDisk, project: &str, zone: &str, instance: &str) -> InstanceAttachDiskCall<'a, C, A> { + pub fn attach_disk(&self, request: AttachedDisk, project: &str, zone: &str, instance: &str) -> InstanceAttachDiskCall<'a, C, A> { InstanceAttachDiskCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _zone: zone.to_string(), _instance: instance.to_string(), @@ -5800,10 +5802,10 @@ impl<'a, C, A> BackendServiceMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - No description provided. /// * `backendService` - Name of the BackendService resource to which the queried instance belongs. - pub fn get_health(&self, request: &ResourceGroupReference, project: &str, backend_service: &str) -> BackendServiceGetHealthCall<'a, C, A> { + pub fn get_health(&self, request: ResourceGroupReference, project: &str, backend_service: &str) -> BackendServiceGetHealthCall<'a, C, A> { BackendServiceGetHealthCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _backend_service: backend_service.to_string(), _delegate: Default::default(), @@ -5859,10 +5861,10 @@ impl<'a, C, A> BackendServiceMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Name of the project scoping this request. /// * `backendService` - Name of the BackendService resource to update. - pub fn update(&self, request: &BackendService, project: &str, backend_service: &str) -> BackendServiceUpdateCall<'a, C, A> { + pub fn update(&self, request: BackendService, project: &str, backend_service: &str) -> BackendServiceUpdateCall<'a, C, A> { BackendServiceUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _backend_service: backend_service.to_string(), _delegate: Default::default(), @@ -5900,10 +5902,10 @@ impl<'a, C, A> BackendServiceMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Name of the project scoping this request. /// * `backendService` - Name of the BackendService resource to update. - pub fn patch(&self, request: &BackendService, project: &str, backend_service: &str) -> BackendServicePatchCall<'a, C, A> { + pub fn patch(&self, request: BackendService, project: &str, backend_service: &str) -> BackendServicePatchCall<'a, C, A> { BackendServicePatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _backend_service: backend_service.to_string(), _delegate: Default::default(), @@ -5920,10 +5922,10 @@ impl<'a, C, A> BackendServiceMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `project` - Name of the project scoping this request. - pub fn insert(&self, request: &BackendService, project: &str) -> BackendServiceInsertCall<'a, C, A> { + pub fn insert(&self, request: BackendService, project: &str) -> BackendServiceInsertCall<'a, C, A> { BackendServiceInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -6040,10 +6042,10 @@ impl<'a, C, A> NetworkMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `project` - Project ID for this request. - pub fn insert(&self, request: &Network, project: &str) -> NetworkInsertCall<'a, C, A> { + pub fn insert(&self, request: Network, project: &str) -> NetworkInsertCall<'a, C, A> { NetworkInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -6378,10 +6380,10 @@ impl<'a, C, A> ForwardingRuleMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Name of the project scoping this request. /// * `region` - Name of the region scoping this request. - pub fn insert(&self, request: &ForwardingRule, project: &str, region: &str) -> ForwardingRuleInsertCall<'a, C, A> { + pub fn insert(&self, request: ForwardingRule, project: &str, region: &str) -> ForwardingRuleInsertCall<'a, C, A> { ForwardingRuleInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _region: region.to_string(), _delegate: Default::default(), @@ -6400,10 +6402,10 @@ impl<'a, C, A> ForwardingRuleMethods<'a, C, A> { /// * `project` - Name of the project scoping this request. /// * `region` - Name of the region scoping this request. /// * `forwardingRule` - Name of the ForwardingRule resource in which target is to be set. - pub fn set_target(&self, request: &TargetReference, project: &str, region: &str, forwarding_rule: &str) -> ForwardingRuleSetTargetCall<'a, C, A> { + pub fn set_target(&self, request: TargetReference, project: &str, region: &str, forwarding_rule: &str) -> ForwardingRuleSetTargetCall<'a, C, A> { ForwardingRuleSetTargetCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _region: region.to_string(), _forwarding_rule: forwarding_rule.to_string(), @@ -6550,10 +6552,10 @@ impl<'a, C, A> TargetPoolMethods<'a, C, A> { /// * `project` - No description provided. /// * `region` - Name of the region scoping this request. /// * `targetPool` - Name of the TargetPool resource to which health_check_url is to be added. - pub fn add_health_check(&self, request: &TargetPoolsAddHealthCheckRequest, project: &str, region: &str, target_pool: &str) -> TargetPoolAddHealthCheckCall<'a, C, A> { + pub fn add_health_check(&self, request: TargetPoolsAddHealthCheckRequest, project: &str, region: &str, target_pool: &str) -> TargetPoolAddHealthCheckCall<'a, C, A> { TargetPoolAddHealthCheckCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _region: region.to_string(), _target_pool: target_pool.to_string(), @@ -6572,10 +6574,10 @@ impl<'a, C, A> TargetPoolMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Name of the project scoping this request. /// * `region` - Name of the region scoping this request. - pub fn insert(&self, request: &TargetPool, project: &str, region: &str) -> TargetPoolInsertCall<'a, C, A> { + pub fn insert(&self, request: TargetPool, project: &str, region: &str) -> TargetPoolInsertCall<'a, C, A> { TargetPoolInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _region: region.to_string(), _delegate: Default::default(), @@ -6594,10 +6596,10 @@ impl<'a, C, A> TargetPoolMethods<'a, C, A> { /// * `project` - No description provided. /// * `region` - Name of the region scoping this request. /// * `targetPool` - Name of the TargetPool resource to which health_check_url is to be removed. - pub fn remove_health_check(&self, request: &TargetPoolsRemoveHealthCheckRequest, project: &str, region: &str, target_pool: &str) -> TargetPoolRemoveHealthCheckCall<'a, C, A> { + pub fn remove_health_check(&self, request: TargetPoolsRemoveHealthCheckRequest, project: &str, region: &str, target_pool: &str) -> TargetPoolRemoveHealthCheckCall<'a, C, A> { TargetPoolRemoveHealthCheckCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _region: region.to_string(), _target_pool: target_pool.to_string(), @@ -6617,10 +6619,10 @@ impl<'a, C, A> TargetPoolMethods<'a, C, A> { /// * `project` - No description provided. /// * `region` - Name of the region scoping this request. /// * `targetPool` - Name of the TargetPool resource to which the queried instance belongs. - pub fn get_health(&self, request: &InstanceReference, project: &str, region: &str, target_pool: &str) -> TargetPoolGetHealthCall<'a, C, A> { + pub fn get_health(&self, request: InstanceReference, project: &str, region: &str, target_pool: &str) -> TargetPoolGetHealthCall<'a, C, A> { TargetPoolGetHealthCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _region: region.to_string(), _target_pool: target_pool.to_string(), @@ -6640,10 +6642,10 @@ impl<'a, C, A> TargetPoolMethods<'a, C, A> { /// * `project` - Name of the project scoping this request. /// * `region` - Name of the region scoping this request. /// * `targetPool` - Name of the TargetPool resource for which the backup is to be set. - pub fn set_backup(&self, request: &TargetReference, project: &str, region: &str, target_pool: &str) -> TargetPoolSetBackupCall<'a, C, A> { + pub fn set_backup(&self, request: TargetReference, project: &str, region: &str, target_pool: &str) -> TargetPoolSetBackupCall<'a, C, A> { TargetPoolSetBackupCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _region: region.to_string(), _target_pool: target_pool.to_string(), @@ -6705,10 +6707,10 @@ impl<'a, C, A> TargetPoolMethods<'a, C, A> { /// * `project` - No description provided. /// * `region` - Name of the region scoping this request. /// * `targetPool` - Name of the TargetPool resource to which instance_url is to be added. - pub fn add_instance(&self, request: &TargetPoolsAddInstanceRequest, project: &str, region: &str, target_pool: &str) -> TargetPoolAddInstanceCall<'a, C, A> { + pub fn add_instance(&self, request: TargetPoolsAddInstanceRequest, project: &str, region: &str, target_pool: &str) -> TargetPoolAddInstanceCall<'a, C, A> { TargetPoolAddInstanceCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _region: region.to_string(), _target_pool: target_pool.to_string(), @@ -6728,10 +6730,10 @@ impl<'a, C, A> TargetPoolMethods<'a, C, A> { /// * `project` - No description provided. /// * `region` - Name of the region scoping this request. /// * `targetPool` - Name of the TargetPool resource to which instance_url is to be removed. - pub fn remove_instance(&self, request: &TargetPoolsRemoveInstanceRequest, project: &str, region: &str, target_pool: &str) -> TargetPoolRemoveInstanceCall<'a, C, A> { + pub fn remove_instance(&self, request: TargetPoolsRemoveInstanceRequest, project: &str, region: &str, target_pool: &str) -> TargetPoolRemoveInstanceCall<'a, C, A> { TargetPoolRemoveInstanceCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _region: region.to_string(), _target_pool: target_pool.to_string(), @@ -6834,10 +6836,10 @@ impl<'a, C, A> TargetInstanceMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Name of the project scoping this request. /// * `zone` - Name of the zone scoping this request. - pub fn insert(&self, request: &TargetInstance, project: &str, zone: &str) -> TargetInstanceInsertCall<'a, C, A> { + pub fn insert(&self, request: TargetInstance, project: &str, zone: &str) -> TargetInstanceInsertCall<'a, C, A> { TargetInstanceInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _zone: zone.to_string(), _delegate: Default::default(), @@ -6996,10 +6998,10 @@ impl<'a, C, A> GlobalForwardingRuleMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Name of the project scoping this request. /// * `forwardingRule` - Name of the ForwardingRule resource in which target is to be set. - pub fn set_target(&self, request: &TargetReference, project: &str, forwarding_rule: &str) -> GlobalForwardingRuleSetTargetCall<'a, C, A> { + pub fn set_target(&self, request: TargetReference, project: &str, forwarding_rule: &str) -> GlobalForwardingRuleSetTargetCall<'a, C, A> { GlobalForwardingRuleSetTargetCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _forwarding_rule: forwarding_rule.to_string(), _delegate: Default::default(), @@ -7016,10 +7018,10 @@ impl<'a, C, A> GlobalForwardingRuleMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `project` - Name of the project scoping this request. - pub fn insert(&self, request: &ForwardingRule, project: &str) -> GlobalForwardingRuleInsertCall<'a, C, A> { + pub fn insert(&self, request: ForwardingRule, project: &str) -> GlobalForwardingRuleInsertCall<'a, C, A> { GlobalForwardingRuleInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -7138,10 +7140,10 @@ impl<'a, C, A> ImageMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Project ID for this request. /// * `image` - Image name. - pub fn deprecate(&self, request: &DeprecationStatus, project: &str, image: &str) -> ImageDeprecateCall<'a, C, A> { + pub fn deprecate(&self, request: DeprecationStatus, project: &str, image: &str) -> ImageDeprecateCall<'a, C, A> { ImageDeprecateCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _image: image.to_string(), _delegate: Default::default(), @@ -7158,10 +7160,10 @@ impl<'a, C, A> ImageMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `project` - Project ID for this request. - pub fn insert(&self, request: &Image, project: &str) -> ImageInsertCall<'a, C, A> { + pub fn insert(&self, request: Image, project: &str) -> ImageInsertCall<'a, C, A> { ImageInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -7405,10 +7407,10 @@ impl<'a, C, A> TargetVpnGatewayMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Project ID for this request. /// * `region` - The name of the region for this request. - pub fn insert(&self, request: &TargetVpnGateway, project: &str, region: &str) -> TargetVpnGatewayInsertCall<'a, C, A> { + pub fn insert(&self, request: TargetVpnGateway, project: &str, region: &str) -> TargetVpnGatewayInsertCall<'a, C, A> { TargetVpnGatewayInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _region: region.to_string(), _delegate: Default::default(), @@ -7487,10 +7489,10 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `project` - Project ID for this request. - pub fn move_disk(&self, request: &DiskMoveRequest, project: &str) -> ProjectMoveDiskCall<'a, C, A> { + pub fn move_disk(&self, request: DiskMoveRequest, project: &str) -> ProjectMoveDiskCall<'a, C, A> { ProjectMoveDiskCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -7506,10 +7508,10 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `project` - Project ID for this request. - pub fn set_common_instance_metadata(&self, request: &Metadata, project: &str) -> ProjectSetCommonInstanceMetadataCall<'a, C, A> { + pub fn set_common_instance_metadata(&self, request: Metadata, project: &str) -> ProjectSetCommonInstanceMetadataCall<'a, C, A> { ProjectSetCommonInstanceMetadataCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -7542,10 +7544,10 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `project` - Project ID for this request. - pub fn move_instance(&self, request: &InstanceMoveRequest, project: &str) -> ProjectMoveInstanceCall<'a, C, A> { + pub fn move_instance(&self, request: InstanceMoveRequest, project: &str) -> ProjectMoveInstanceCall<'a, C, A> { ProjectMoveInstanceCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -7561,10 +7563,10 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `project` - Project ID for this request. - pub fn set_usage_export_bucket(&self, request: &UsageExportLocation, project: &str) -> ProjectSetUsageExportBucketCall<'a, C, A> { + pub fn set_usage_export_bucket(&self, request: UsageExportLocation, project: &str) -> ProjectSetUsageExportBucketCall<'a, C, A> { ProjectSetUsageExportBucketCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -7641,10 +7643,10 @@ impl<'a, C, A> HttpHealthCheckMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Name of the project scoping this request. /// * `httpHealthCheck` - Name of the HttpHealthCheck resource to update. - pub fn patch(&self, request: &HttpHealthCheck, project: &str, http_health_check: &str) -> HttpHealthCheckPatchCall<'a, C, A> { + pub fn patch(&self, request: HttpHealthCheck, project: &str, http_health_check: &str) -> HttpHealthCheckPatchCall<'a, C, A> { HttpHealthCheckPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _http_health_check: http_health_check.to_string(), _delegate: Default::default(), @@ -7700,10 +7702,10 @@ impl<'a, C, A> HttpHealthCheckMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `project` - Name of the project scoping this request. - pub fn insert(&self, request: &HttpHealthCheck, project: &str) -> HttpHealthCheckInsertCall<'a, C, A> { + pub fn insert(&self, request: HttpHealthCheck, project: &str) -> HttpHealthCheckInsertCall<'a, C, A> { HttpHealthCheckInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -7720,10 +7722,10 @@ impl<'a, C, A> HttpHealthCheckMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Name of the project scoping this request. /// * `httpHealthCheck` - Name of the HttpHealthCheck resource to update. - pub fn update(&self, request: &HttpHealthCheck, project: &str, http_health_check: &str) -> HttpHealthCheckUpdateCall<'a, C, A> { + pub fn update(&self, request: HttpHealthCheck, project: &str, http_health_check: &str) -> HttpHealthCheckUpdateCall<'a, C, A> { HttpHealthCheckUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _http_health_check: http_health_check.to_string(), _delegate: Default::default(), @@ -7839,10 +7841,10 @@ impl<'a, C, A> InstanceTemplateMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `project` - Name of the project scoping this request. - pub fn insert(&self, request: &InstanceTemplate, project: &str) -> InstanceTemplateInsertCall<'a, C, A> { + pub fn insert(&self, request: InstanceTemplate, project: &str) -> InstanceTemplateInsertCall<'a, C, A> { InstanceTemplateInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -7958,10 +7960,10 @@ impl<'a, C, A> TargetHttpProxyMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Name of the project scoping this request. /// * `targetHttpProxy` - Name of the TargetHttpProxy resource whose URL map is to be set. - pub fn set_url_map(&self, request: &UrlMapReference, project: &str, target_http_proxy: &str) -> TargetHttpProxySetUrlMapCall<'a, C, A> { + pub fn set_url_map(&self, request: UrlMapReference, project: &str, target_http_proxy: &str) -> TargetHttpProxySetUrlMapCall<'a, C, A> { TargetHttpProxySetUrlMapCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _target_http_proxy: target_http_proxy.to_string(), _delegate: Default::default(), @@ -7978,10 +7980,10 @@ impl<'a, C, A> TargetHttpProxyMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `project` - Name of the project scoping this request. - pub fn insert(&self, request: &TargetHttpProxy, project: &str) -> TargetHttpProxyInsertCall<'a, C, A> { + pub fn insert(&self, request: TargetHttpProxy, project: &str) -> TargetHttpProxyInsertCall<'a, C, A> { TargetHttpProxyInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -8162,10 +8164,10 @@ impl<'a, C, A> RouteMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `project` - Name of the project scoping this request. - pub fn insert(&self, request: &Route, project: &str) -> RouteInsertCall<'a, C, A> { + pub fn insert(&self, request: Route, project: &str) -> RouteInsertCall<'a, C, A> { RouteInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -8262,10 +8264,10 @@ impl<'a, C, A> FirewallMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Project ID for this request. /// * `firewall` - Name of the firewall resource to update. - pub fn patch(&self, request: &Firewall, project: &str, firewall: &str) -> FirewallPatchCall<'a, C, A> { + pub fn patch(&self, request: Firewall, project: &str, firewall: &str) -> FirewallPatchCall<'a, C, A> { FirewallPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _firewall: firewall.to_string(), _delegate: Default::default(), @@ -8301,10 +8303,10 @@ impl<'a, C, A> FirewallMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `project` - Project ID for this request. - pub fn insert(&self, request: &Firewall, project: &str) -> FirewallInsertCall<'a, C, A> { + pub fn insert(&self, request: Firewall, project: &str) -> FirewallInsertCall<'a, C, A> { FirewallInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -8321,10 +8323,10 @@ impl<'a, C, A> FirewallMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Project ID for this request. /// * `firewall` - Name of the firewall resource to update. - pub fn update(&self, request: &Firewall, project: &str, firewall: &str) -> FirewallUpdateCall<'a, C, A> { + pub fn update(&self, request: Firewall, project: &str, firewall: &str) -> FirewallUpdateCall<'a, C, A> { FirewallUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _firewall: firewall.to_string(), _delegate: Default::default(), @@ -8486,10 +8488,10 @@ impl<'a, C, A> VpnTunnelMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Project ID for this request. /// * `region` - The name of the region for this request. - pub fn insert(&self, request: &VpnTunnel, project: &str, region: &str) -> VpnTunnelInsertCall<'a, C, A> { + pub fn insert(&self, request: VpnTunnel, project: &str, region: &str) -> VpnTunnelInsertCall<'a, C, A> { VpnTunnelInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _region: region.to_string(), _delegate: Default::default(), @@ -8781,12 +8783,17 @@ impl<'a, C, A> DiskDeleteCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8795,7 +8802,7 @@ impl<'a, C, A> DiskDeleteCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9050,12 +9057,17 @@ impl<'a, C, A> DiskAggregatedListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9064,7 +9076,7 @@ impl<'a, C, A> DiskAggregatedListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9322,12 +9334,17 @@ impl<'a, C, A> DiskListCall<'a, C, A> where C: BorrowMut, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9336,7 +9353,7 @@ impl<'a, C, A> DiskListCall<'a, C, A> where C: BorrowMut, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9474,7 +9491,7 @@ impl<'a, C, A> DiskListCall<'a, C, A> where C: BorrowMut, A: oaut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.disks().insert(&req, "project", "zone") +/// let result = hub.disks().insert(req, "project", "zone") /// .source_image("duo") /// .doit(); /// # } @@ -9609,12 +9626,17 @@ impl<'a, C, A> DiskInsertCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9623,7 +9645,7 @@ impl<'a, C, A> DiskInsertCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9641,8 +9663,8 @@ impl<'a, C, A> DiskInsertCall<'a, C, A> where C: BorrowMut, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Disk) -> DiskInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Disk) -> DiskInsertCall<'a, C, A> { + self._request = new_value; self } /// Project ID for this request. @@ -9756,7 +9778,7 @@ impl<'a, C, A> DiskInsertCall<'a, C, A> where C: BorrowMut, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.disks().create_snapshot(&req, "project", "zone", "disk") +/// let result = hub.disks().create_snapshot(req, "project", "zone", "disk") /// .doit(); /// # } /// ``` @@ -9888,12 +9910,17 @@ impl<'a, C, A> DiskCreateSnapshotCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9902,7 +9929,7 @@ impl<'a, C, A> DiskCreateSnapshotCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9920,8 +9947,8 @@ impl<'a, C, A> DiskCreateSnapshotCall<'a, C, A> where C: BorrowMut DiskCreateSnapshotCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Snapshot) -> DiskCreateSnapshotCall<'a, C, A> { + self._request = new_value; self } /// Project ID for this request. @@ -10155,12 +10182,17 @@ impl<'a, C, A> DiskGetCall<'a, C, A> where C: BorrowMut, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10169,7 +10201,7 @@ impl<'a, C, A> DiskGetCall<'a, C, A> where C: BorrowMut, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10426,12 +10458,17 @@ impl<'a, C, A> AddresseListCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10440,7 +10477,7 @@ impl<'a, C, A> AddresseListCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10706,12 +10743,17 @@ impl<'a, C, A> AddresseAggregatedListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10720,7 +10762,7 @@ impl<'a, C, A> AddresseAggregatedListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10965,12 +11007,17 @@ impl<'a, C, A> AddresseGetCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10979,7 +11026,7 @@ impl<'a, C, A> AddresseGetCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11106,7 +11153,7 @@ impl<'a, C, A> AddresseGetCall<'a, C, A> where C: BorrowMut, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.addresses().insert(&req, "project", "region") +/// let result = hub.addresses().insert(req, "project", "region") /// .doit(); /// # } /// ``` @@ -11236,12 +11283,17 @@ impl<'a, C, A> AddresseInsertCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11250,7 +11302,7 @@ impl<'a, C, A> AddresseInsertCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11268,8 +11320,8 @@ impl<'a, C, A> AddresseInsertCall<'a, C, A> where C: BorrowMut, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Address) -> AddresseInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Address) -> AddresseInsertCall<'a, C, A> { + self._request = new_value; self } /// Project ID for this request. @@ -11493,12 +11545,17 @@ impl<'a, C, A> AddresseDeleteCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11507,7 +11564,7 @@ impl<'a, C, A> AddresseDeleteCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11634,7 +11691,7 @@ impl<'a, C, A> AddresseDeleteCall<'a, C, A> where C: BorrowMut, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.url_maps().insert(&req, "project") +/// let result = hub.url_maps().insert(req, "project") /// .doit(); /// # } /// ``` @@ -11762,12 +11819,17 @@ impl<'a, C, A> UrlMapInsertCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11776,7 +11838,7 @@ impl<'a, C, A> UrlMapInsertCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11794,8 +11856,8 @@ impl<'a, C, A> UrlMapInsertCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &UrlMap) -> UrlMapInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: UrlMap) -> UrlMapInsertCall<'a, C, A> { + self._request = new_value; self } /// Name of the project scoping this request. @@ -12007,12 +12069,17 @@ impl<'a, C, A> UrlMapGetCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12021,7 +12088,7 @@ impl<'a, C, A> UrlMapGetCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12138,7 +12205,7 @@ impl<'a, C, A> UrlMapGetCall<'a, C, A> where C: BorrowMut, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.url_maps().validate(&req, "project", "urlMap") +/// let result = hub.url_maps().validate(req, "project", "urlMap") /// .doit(); /// # } /// ``` @@ -12268,12 +12335,17 @@ impl<'a, C, A> UrlMapValidateCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12282,7 +12354,7 @@ impl<'a, C, A> UrlMapValidateCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12300,8 +12372,8 @@ impl<'a, C, A> UrlMapValidateCall<'a, C, A> where C: BorrowMut, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &UrlMapsValidateRequest) -> UrlMapValidateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: UrlMapsValidateRequest) -> UrlMapValidateCall<'a, C, A> { + self._request = new_value; self } /// Name of the project scoping this request. @@ -12536,12 +12608,17 @@ impl<'a, C, A> UrlMapListCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12550,7 +12627,7 @@ impl<'a, C, A> UrlMapListCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12678,7 +12755,7 @@ impl<'a, C, A> UrlMapListCall<'a, C, A> where C: BorrowMut, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.url_maps().patch(&req, "project", "urlMap") +/// let result = hub.url_maps().patch(req, "project", "urlMap") /// .doit(); /// # } /// ``` @@ -12808,12 +12885,17 @@ impl<'a, C, A> UrlMapPatchCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12822,7 +12904,7 @@ impl<'a, C, A> UrlMapPatchCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12840,8 +12922,8 @@ impl<'a, C, A> UrlMapPatchCall<'a, C, A> where C: BorrowMut, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &UrlMap) -> UrlMapPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: UrlMap) -> UrlMapPatchCall<'a, C, A> { + self._request = new_value; self } /// Name of the project scoping this request. @@ -12948,7 +13030,7 @@ impl<'a, C, A> UrlMapPatchCall<'a, C, A> where C: BorrowMut, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.url_maps().update(&req, "project", "urlMap") +/// let result = hub.url_maps().update(req, "project", "urlMap") /// .doit(); /// # } /// ``` @@ -13078,12 +13160,17 @@ impl<'a, C, A> UrlMapUpdateCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13092,7 +13179,7 @@ impl<'a, C, A> UrlMapUpdateCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13110,8 +13197,8 @@ impl<'a, C, A> UrlMapUpdateCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &UrlMap) -> UrlMapUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: UrlMap) -> UrlMapUpdateCall<'a, C, A> { + self._request = new_value; self } /// Name of the project scoping this request. @@ -13333,12 +13420,17 @@ impl<'a, C, A> UrlMapDeleteCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13347,7 +13439,7 @@ impl<'a, C, A> UrlMapDeleteCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13464,7 +13556,7 @@ impl<'a, C, A> UrlMapDeleteCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.global_addresses().insert(&req, "project") +/// let result = hub.global_addresses().insert(req, "project") /// .doit(); /// # } /// ``` @@ -13592,12 +13684,17 @@ impl<'a, C, A> GlobalAddresseInsertCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13606,7 +13703,7 @@ impl<'a, C, A> GlobalAddresseInsertCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13624,8 +13721,8 @@ impl<'a, C, A> GlobalAddresseInsertCall<'a, C, A> where C: BorrowMut GlobalAddresseInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Address) -> GlobalAddresseInsertCall<'a, C, A> { + self._request = new_value; self } /// Project ID for this request. @@ -13850,12 +13947,17 @@ impl<'a, C, A> GlobalAddresseListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13864,7 +13966,7 @@ impl<'a, C, A> GlobalAddresseListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14107,12 +14209,17 @@ impl<'a, C, A> GlobalAddresseGetCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14121,7 +14228,7 @@ impl<'a, C, A> GlobalAddresseGetCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14353,12 +14460,17 @@ impl<'a, C, A> GlobalAddresseDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14367,7 +14479,7 @@ impl<'a, C, A> GlobalAddresseDeleteCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14599,12 +14711,17 @@ impl<'a, C, A> SnapshotGetCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14613,7 +14730,7 @@ impl<'a, C, A> SnapshotGetCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14858,12 +14975,17 @@ impl<'a, C, A> SnapshotListCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14872,7 +14994,7 @@ impl<'a, C, A> SnapshotListCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15115,12 +15237,17 @@ impl<'a, C, A> SnapshotDeleteCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15129,7 +15256,7 @@ impl<'a, C, A> SnapshotDeleteCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15363,12 +15490,17 @@ impl<'a, C, A> DiskTypeGetCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15377,7 +15509,7 @@ impl<'a, C, A> DiskTypeGetCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15632,12 +15764,17 @@ impl<'a, C, A> DiskTypeAggregatedListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15646,7 +15783,7 @@ impl<'a, C, A> DiskTypeAggregatedListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15904,12 +16041,17 @@ impl<'a, C, A> DiskTypeListCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15918,7 +16060,7 @@ impl<'a, C, A> DiskTypeListCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16171,12 +16313,17 @@ impl<'a, C, A> ZoneGetCall<'a, C, A> where C: BorrowMut, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16185,7 +16332,7 @@ impl<'a, C, A> ZoneGetCall<'a, C, A> where C: BorrowMut, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16430,12 +16577,17 @@ impl<'a, C, A> ZoneListCall<'a, C, A> where C: BorrowMut, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16444,7 +16596,7 @@ impl<'a, C, A> ZoneListCall<'a, C, A> where C: BorrowMut, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16572,7 +16724,7 @@ impl<'a, C, A> ZoneListCall<'a, C, A> where C: BorrowMut, A: oaut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.instances().set_scheduling(&req, "project", "zone", "instance") +/// let result = hub.instances().set_scheduling(req, "project", "zone", "instance") /// .doit(); /// # } /// ``` @@ -16704,12 +16856,17 @@ impl<'a, C, A> InstanceSetSchedulingCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16718,7 +16875,7 @@ impl<'a, C, A> InstanceSetSchedulingCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16736,8 +16893,8 @@ impl<'a, C, A> InstanceSetSchedulingCall<'a, C, A> where C: BorrowMut InstanceSetSchedulingCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Scheduling) -> InstanceSetSchedulingCall<'a, C, A> { + self._request = new_value; self } /// Project ID for this request. @@ -16971,12 +17128,17 @@ impl<'a, C, A> InstanceDeleteCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16985,7 +17147,7 @@ impl<'a, C, A> InstanceDeleteCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -17234,12 +17396,17 @@ impl<'a, C, A> InstanceGetSerialPortOutputCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -17248,7 +17415,7 @@ impl<'a, C, A> InstanceGetSerialPortOutputCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -17503,12 +17670,17 @@ impl<'a, C, A> InstanceSetDiskAutoDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -17517,7 +17689,7 @@ impl<'a, C, A> InstanceSetDiskAutoDeleteCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -17664,7 +17836,7 @@ impl<'a, C, A> InstanceSetDiskAutoDeleteCall<'a, C, A> where C: BorrowMut InstanceAddAccessConfigCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -17812,7 +17989,7 @@ impl<'a, C, A> InstanceAddAccessConfigCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -17830,8 +18007,8 @@ impl<'a, C, A> InstanceAddAccessConfigCall<'a, C, A> where C: BorrowMut InstanceAddAccessConfigCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AccessConfig) -> InstanceAddAccessConfigCall<'a, C, A> { + self._request = new_value; self } /// Project ID for this request. @@ -18075,12 +18252,17 @@ impl<'a, C, A> InstanceStartCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -18089,7 +18271,7 @@ impl<'a, C, A> InstanceStartCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -18333,12 +18515,17 @@ impl<'a, C, A> InstanceGetCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -18347,7 +18534,7 @@ impl<'a, C, A> InstanceGetCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -18474,7 +18661,7 @@ impl<'a, C, A> InstanceGetCall<'a, C, A> where C: BorrowMut, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.instances().set_tags(&req, "project", "zone", "instance") +/// let result = hub.instances().set_tags(req, "project", "zone", "instance") /// .doit(); /// # } /// ``` @@ -18606,12 +18793,17 @@ impl<'a, C, A> InstanceSetTagCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -18620,7 +18812,7 @@ impl<'a, C, A> InstanceSetTagCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -18638,8 +18830,8 @@ impl<'a, C, A> InstanceSetTagCall<'a, C, A> where C: BorrowMut, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Tags) -> InstanceSetTagCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Tags) -> InstanceSetTagCall<'a, C, A> { + self._request = new_value; self } /// Project ID for this request. @@ -18756,7 +18948,7 @@ impl<'a, C, A> InstanceSetTagCall<'a, C, A> where C: BorrowMut, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.instances().set_metadata(&req, "project", "zone", "instance") +/// let result = hub.instances().set_metadata(req, "project", "zone", "instance") /// .doit(); /// # } /// ``` @@ -18888,12 +19080,17 @@ impl<'a, C, A> InstanceSetMetadataCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -18902,7 +19099,7 @@ impl<'a, C, A> InstanceSetMetadataCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -18920,8 +19117,8 @@ impl<'a, C, A> InstanceSetMetadataCall<'a, C, A> where C: BorrowMut InstanceSetMetadataCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Metadata) -> InstanceSetMetadataCall<'a, C, A> { + self._request = new_value; self } /// Project ID for this request. @@ -19157,12 +19354,17 @@ impl<'a, C, A> InstanceDetachDiskCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -19171,7 +19373,7 @@ impl<'a, C, A> InstanceDetachDiskCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -19425,12 +19627,17 @@ impl<'a, C, A> InstanceStopCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -19439,7 +19646,7 @@ impl<'a, C, A> InstanceStopCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -19566,7 +19773,7 @@ impl<'a, C, A> InstanceStopCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.instances().insert(&req, "project", "zone") +/// let result = hub.instances().insert(req, "project", "zone") /// .doit(); /// # } /// ``` @@ -19696,12 +19903,17 @@ impl<'a, C, A> InstanceInsertCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -19710,7 +19922,7 @@ impl<'a, C, A> InstanceInsertCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -19728,8 +19940,8 @@ impl<'a, C, A> InstanceInsertCall<'a, C, A> where C: BorrowMut, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Instance) -> InstanceInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Instance) -> InstanceInsertCall<'a, C, A> { + self._request = new_value; self } /// Project ID for this request. @@ -19953,12 +20165,17 @@ impl<'a, C, A> InstanceResetCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -19967,7 +20184,7 @@ impl<'a, C, A> InstanceResetCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -20215,12 +20432,17 @@ impl<'a, C, A> InstanceDeleteAccessConfigCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -20229,7 +20451,7 @@ impl<'a, C, A> InstanceDeleteAccessConfigCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -20376,7 +20598,7 @@ impl<'a, C, A> InstanceDeleteAccessConfigCall<'a, C, A> where C: BorrowMut InstanceAttachDiskCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -20522,7 +20749,7 @@ impl<'a, C, A> InstanceAttachDiskCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -20540,8 +20767,8 @@ impl<'a, C, A> InstanceAttachDiskCall<'a, C, A> where C: BorrowMut InstanceAttachDiskCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AttachedDisk) -> InstanceAttachDiskCall<'a, C, A> { + self._request = new_value; self } /// Project ID for this request. @@ -20788,12 +21015,17 @@ impl<'a, C, A> InstanceListCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -20802,7 +21034,7 @@ impl<'a, C, A> InstanceListCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -21066,12 +21298,17 @@ impl<'a, C, A> InstanceAggregatedListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -21080,7 +21317,7 @@ impl<'a, C, A> InstanceAggregatedListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -21208,7 +21445,7 @@ impl<'a, C, A> InstanceAggregatedListCall<'a, C, A> where C: BorrowMut BackendServiceGetHealthCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -21352,7 +21594,7 @@ impl<'a, C, A> BackendServiceGetHealthCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -21370,8 +21612,8 @@ impl<'a, C, A> BackendServiceGetHealthCall<'a, C, A> where C: BorrowMut BackendServiceGetHealthCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ResourceGroupReference) -> BackendServiceGetHealthCall<'a, C, A> { + self._request = new_value; self } /// @@ -21592,12 +21834,17 @@ impl<'a, C, A> BackendServiceDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -21606,7 +21853,7 @@ impl<'a, C, A> BackendServiceDeleteCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -21838,12 +22085,17 @@ impl<'a, C, A> BackendServiceGetCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -21852,7 +22104,7 @@ impl<'a, C, A> BackendServiceGetCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -21969,7 +22221,7 @@ impl<'a, C, A> BackendServiceGetCall<'a, C, A> where C: BorrowMut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.backend_services().update(&req, "project", "backendService") +/// let result = hub.backend_services().update(req, "project", "backendService") /// .doit(); /// # } /// ``` @@ -22099,12 +22351,17 @@ impl<'a, C, A> BackendServiceUpdateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -22113,7 +22370,7 @@ impl<'a, C, A> BackendServiceUpdateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -22131,8 +22388,8 @@ impl<'a, C, A> BackendServiceUpdateCall<'a, C, A> where C: BorrowMut BackendServiceUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: BackendService) -> BackendServiceUpdateCall<'a, C, A> { + self._request = new_value; self } /// Name of the project scoping this request. @@ -22367,12 +22624,17 @@ impl<'a, C, A> BackendServiceListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -22381,7 +22643,7 @@ impl<'a, C, A> BackendServiceListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -22509,7 +22771,7 @@ impl<'a, C, A> BackendServiceListCall<'a, C, A> where C: BorrowMut BackendServicePatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -22653,7 +22920,7 @@ impl<'a, C, A> BackendServicePatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -22671,8 +22938,8 @@ impl<'a, C, A> BackendServicePatchCall<'a, C, A> where C: BorrowMut BackendServicePatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: BackendService) -> BackendServicePatchCall<'a, C, A> { + self._request = new_value; self } /// Name of the project scoping this request. @@ -22779,7 +23046,7 @@ impl<'a, C, A> BackendServicePatchCall<'a, C, A> where C: BorrowMut BackendServiceInsertCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -22921,7 +23193,7 @@ impl<'a, C, A> BackendServiceInsertCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -22939,8 +23211,8 @@ impl<'a, C, A> BackendServiceInsertCall<'a, C, A> where C: BorrowMut BackendServiceInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: BackendService) -> BackendServiceInsertCall<'a, C, A> { + self._request = new_value; self } /// Name of the project scoping this request. @@ -23152,12 +23424,17 @@ impl<'a, C, A> LicenseGetCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -23166,7 +23443,7 @@ impl<'a, C, A> LicenseGetCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -23283,7 +23560,7 @@ impl<'a, C, A> LicenseGetCall<'a, C, A> where C: BorrowMut, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.networks().insert(&req, "project") +/// let result = hub.networks().insert(req, "project") /// .doit(); /// # } /// ``` @@ -23411,12 +23688,17 @@ impl<'a, C, A> NetworkInsertCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -23425,7 +23707,7 @@ impl<'a, C, A> NetworkInsertCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -23443,8 +23725,8 @@ impl<'a, C, A> NetworkInsertCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Network) -> NetworkInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Network) -> NetworkInsertCall<'a, C, A> { + self._request = new_value; self } /// Project ID for this request. @@ -23669,12 +23951,17 @@ impl<'a, C, A> NetworkListCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -23683,7 +23970,7 @@ impl<'a, C, A> NetworkListCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -23926,12 +24213,17 @@ impl<'a, C, A> NetworkDeleteCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -23940,7 +24232,7 @@ impl<'a, C, A> NetworkDeleteCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -24172,12 +24464,17 @@ impl<'a, C, A> NetworkGetCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -24186,7 +24483,7 @@ impl<'a, C, A> NetworkGetCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -24431,12 +24728,17 @@ impl<'a, C, A> GlobalOperationListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -24445,7 +24747,7 @@ impl<'a, C, A> GlobalOperationListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -24688,12 +24990,17 @@ impl<'a, C, A> GlobalOperationGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -24702,7 +25009,7 @@ impl<'a, C, A> GlobalOperationGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -24933,12 +25240,17 @@ impl<'a, C, A> GlobalOperationDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -25182,12 +25494,17 @@ impl<'a, C, A> GlobalOperationAggregatedListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -25196,7 +25513,7 @@ impl<'a, C, A> GlobalOperationAggregatedListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -25452,12 +25769,17 @@ impl<'a, C, A> RegionListCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -25466,7 +25788,7 @@ impl<'a, C, A> RegionListCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -25709,12 +26031,17 @@ impl<'a, C, A> RegionGetCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -25723,7 +26050,7 @@ impl<'a, C, A> RegionGetCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -25968,12 +26295,17 @@ impl<'a, C, A> ForwardingRuleAggregatedListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -25982,7 +26314,7 @@ impl<'a, C, A> ForwardingRuleAggregatedListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -26110,7 +26442,7 @@ impl<'a, C, A> ForwardingRuleAggregatedListCall<'a, C, A> where C: BorrowMut ForwardingRuleInsertCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -26254,7 +26591,7 @@ impl<'a, C, A> ForwardingRuleInsertCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -26272,8 +26609,8 @@ impl<'a, C, A> ForwardingRuleInsertCall<'a, C, A> where C: BorrowMut ForwardingRuleInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ForwardingRule) -> ForwardingRuleInsertCall<'a, C, A> { + self._request = new_value; self } /// Name of the project scoping this request. @@ -26380,7 +26717,7 @@ impl<'a, C, A> ForwardingRuleInsertCall<'a, C, A> where C: BorrowMut ForwardingRuleSetTargetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -26526,7 +26868,7 @@ impl<'a, C, A> ForwardingRuleSetTargetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -26544,8 +26886,8 @@ impl<'a, C, A> ForwardingRuleSetTargetCall<'a, C, A> where C: BorrowMut ForwardingRuleSetTargetCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: TargetReference) -> ForwardingRuleSetTargetCall<'a, C, A> { + self._request = new_value; self } /// Name of the project scoping this request. @@ -26779,12 +27121,17 @@ impl<'a, C, A> ForwardingRuleGetCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -26793,7 +27140,7 @@ impl<'a, C, A> ForwardingRuleGetCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -27050,12 +27397,17 @@ impl<'a, C, A> ForwardingRuleListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -27064,7 +27416,7 @@ impl<'a, C, A> ForwardingRuleListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -27319,12 +27671,17 @@ impl<'a, C, A> ForwardingRuleDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -27333,7 +27690,7 @@ impl<'a, C, A> ForwardingRuleDeleteCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -27590,12 +27947,17 @@ impl<'a, C, A> TargetPoolListCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -27604,7 +27966,7 @@ impl<'a, C, A> TargetPoolListCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -27742,7 +28104,7 @@ impl<'a, C, A> TargetPoolListCall<'a, C, A> where C: BorrowMut, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.target_pools().add_health_check(&req, "project", "region", "targetPool") +/// let result = hub.target_pools().add_health_check(req, "project", "region", "targetPool") /// .doit(); /// # } /// ``` @@ -27874,12 +28236,17 @@ impl<'a, C, A> TargetPoolAddHealthCheckCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -27888,7 +28255,7 @@ impl<'a, C, A> TargetPoolAddHealthCheckCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -27906,8 +28273,8 @@ impl<'a, C, A> TargetPoolAddHealthCheckCall<'a, C, A> where C: BorrowMut TargetPoolAddHealthCheckCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: TargetPoolsAddHealthCheckRequest) -> TargetPoolAddHealthCheckCall<'a, C, A> { + self._request = new_value; self } /// @@ -28023,7 +28390,7 @@ impl<'a, C, A> TargetPoolAddHealthCheckCall<'a, C, A> where C: BorrowMut TargetPoolInsertCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -28167,7 +28539,7 @@ impl<'a, C, A> TargetPoolInsertCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -28185,8 +28557,8 @@ impl<'a, C, A> TargetPoolInsertCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &TargetPool) -> TargetPoolInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: TargetPool) -> TargetPoolInsertCall<'a, C, A> { + self._request = new_value; self } /// Name of the project scoping this request. @@ -28293,7 +28665,7 @@ impl<'a, C, A> TargetPoolInsertCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.target_pools().remove_health_check(&req, "project", "region", "targetPool") +/// let result = hub.target_pools().remove_health_check(req, "project", "region", "targetPool") /// .doit(); /// # } /// ``` @@ -28425,12 +28797,17 @@ impl<'a, C, A> TargetPoolRemoveHealthCheckCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -28439,7 +28816,7 @@ impl<'a, C, A> TargetPoolRemoveHealthCheckCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -28457,8 +28834,8 @@ impl<'a, C, A> TargetPoolRemoveHealthCheckCall<'a, C, A> where C: BorrowMut TargetPoolRemoveHealthCheckCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: TargetPoolsRemoveHealthCheckRequest) -> TargetPoolRemoveHealthCheckCall<'a, C, A> { + self._request = new_value; self } /// @@ -28574,7 +28951,7 @@ impl<'a, C, A> TargetPoolRemoveHealthCheckCall<'a, C, A> where C: BorrowMut TargetPoolGetHealthCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -28720,7 +29102,7 @@ impl<'a, C, A> TargetPoolGetHealthCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -28738,8 +29120,8 @@ impl<'a, C, A> TargetPoolGetHealthCall<'a, C, A> where C: BorrowMut TargetPoolGetHealthCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: InstanceReference) -> TargetPoolGetHealthCall<'a, C, A> { + self._request = new_value; self } /// @@ -28855,7 +29237,7 @@ impl<'a, C, A> TargetPoolGetHealthCall<'a, C, A> where C: BorrowMut TargetPoolSetBackupCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -29006,7 +29393,7 @@ impl<'a, C, A> TargetPoolSetBackupCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -29024,8 +29411,8 @@ impl<'a, C, A> TargetPoolSetBackupCall<'a, C, A> where C: BorrowMut TargetPoolSetBackupCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: TargetReference) -> TargetPoolSetBackupCall<'a, C, A> { + self._request = new_value; self } /// Name of the project scoping this request. @@ -29277,12 +29664,17 @@ impl<'a, C, A> TargetPoolAggregatedListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -29291,7 +29683,7 @@ impl<'a, C, A> TargetPoolAggregatedListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -29536,12 +29928,17 @@ impl<'a, C, A> TargetPoolGetCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -29550,7 +29947,7 @@ impl<'a, C, A> TargetPoolGetCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -29677,7 +30074,7 @@ impl<'a, C, A> TargetPoolGetCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.target_pools().add_instance(&req, "project", "region", "targetPool") +/// let result = hub.target_pools().add_instance(req, "project", "region", "targetPool") /// .doit(); /// # } /// ``` @@ -29809,12 +30206,17 @@ impl<'a, C, A> TargetPoolAddInstanceCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -29823,7 +30225,7 @@ impl<'a, C, A> TargetPoolAddInstanceCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -29841,8 +30243,8 @@ impl<'a, C, A> TargetPoolAddInstanceCall<'a, C, A> where C: BorrowMut TargetPoolAddInstanceCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: TargetPoolsAddInstanceRequest) -> TargetPoolAddInstanceCall<'a, C, A> { + self._request = new_value; self } /// @@ -29958,7 +30360,7 @@ impl<'a, C, A> TargetPoolAddInstanceCall<'a, C, A> where C: BorrowMut TargetPoolRemoveInstanceCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -30104,7 +30511,7 @@ impl<'a, C, A> TargetPoolRemoveInstanceCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -30122,8 +30529,8 @@ impl<'a, C, A> TargetPoolRemoveInstanceCall<'a, C, A> where C: BorrowMut TargetPoolRemoveInstanceCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: TargetPoolsRemoveInstanceRequest) -> TargetPoolRemoveInstanceCall<'a, C, A> { + self._request = new_value; self } /// @@ -30356,12 +30763,17 @@ impl<'a, C, A> TargetPoolDeleteCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -30370,7 +30782,7 @@ impl<'a, C, A> TargetPoolDeleteCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -30627,12 +31039,17 @@ impl<'a, C, A> TargetInstanceListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -30641,7 +31058,7 @@ impl<'a, C, A> TargetInstanceListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -30779,7 +31196,7 @@ impl<'a, C, A> TargetInstanceListCall<'a, C, A> where C: BorrowMut TargetInstanceInsertCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -30923,7 +31345,7 @@ impl<'a, C, A> TargetInstanceInsertCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -30941,8 +31363,8 @@ impl<'a, C, A> TargetInstanceInsertCall<'a, C, A> where C: BorrowMut TargetInstanceInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: TargetInstance) -> TargetInstanceInsertCall<'a, C, A> { + self._request = new_value; self } /// Name of the project scoping this request. @@ -31177,12 +31599,17 @@ impl<'a, C, A> TargetInstanceAggregatedListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -31191,7 +31618,7 @@ impl<'a, C, A> TargetInstanceAggregatedListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -31436,12 +31863,17 @@ impl<'a, C, A> TargetInstanceGetCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -31450,7 +31882,7 @@ impl<'a, C, A> TargetInstanceGetCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -31694,12 +32126,17 @@ impl<'a, C, A> TargetInstanceDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -31708,7 +32145,7 @@ impl<'a, C, A> TargetInstanceDeleteCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -31950,12 +32387,17 @@ impl<'a, C, A> GlobalForwardingRuleGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -31964,7 +32406,7 @@ impl<'a, C, A> GlobalForwardingRuleGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -32196,12 +32638,17 @@ impl<'a, C, A> GlobalForwardingRuleDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -32210,7 +32657,7 @@ impl<'a, C, A> GlobalForwardingRuleDeleteCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -32327,7 +32774,7 @@ impl<'a, C, A> GlobalForwardingRuleDeleteCall<'a, C, A> where C: BorrowMut GlobalForwardingRuleSetTargetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -32471,7 +32923,7 @@ impl<'a, C, A> GlobalForwardingRuleSetTargetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -32489,8 +32941,8 @@ impl<'a, C, A> GlobalForwardingRuleSetTargetCall<'a, C, A> where C: BorrowMut GlobalForwardingRuleSetTargetCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: TargetReference) -> GlobalForwardingRuleSetTargetCall<'a, C, A> { + self._request = new_value; self } /// Name of the project scoping this request. @@ -32597,7 +33049,7 @@ impl<'a, C, A> GlobalForwardingRuleSetTargetCall<'a, C, A> where C: BorrowMut GlobalForwardingRuleInsertCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -32739,7 +33196,7 @@ impl<'a, C, A> GlobalForwardingRuleInsertCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -32757,8 +33214,8 @@ impl<'a, C, A> GlobalForwardingRuleInsertCall<'a, C, A> where C: BorrowMut GlobalForwardingRuleInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ForwardingRule) -> GlobalForwardingRuleInsertCall<'a, C, A> { + self._request = new_value; self } /// Name of the project scoping this request. @@ -32983,12 +33440,17 @@ impl<'a, C, A> GlobalForwardingRuleListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -32997,7 +33459,7 @@ impl<'a, C, A> GlobalForwardingRuleListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -33253,12 +33715,17 @@ impl<'a, C, A> ImageListCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -33267,7 +33734,7 @@ impl<'a, C, A> ImageListCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -33510,12 +33977,17 @@ impl<'a, C, A> ImageDeleteCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -33524,7 +33996,7 @@ impl<'a, C, A> ImageDeleteCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -33643,7 +34115,7 @@ impl<'a, C, A> ImageDeleteCall<'a, C, A> where C: BorrowMut, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.images().deprecate(&req, "project", "image") +/// let result = hub.images().deprecate(req, "project", "image") /// .doit(); /// # } /// ``` @@ -33773,12 +34245,17 @@ impl<'a, C, A> ImageDeprecateCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -33787,7 +34264,7 @@ impl<'a, C, A> ImageDeprecateCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -33805,8 +34282,8 @@ impl<'a, C, A> ImageDeprecateCall<'a, C, A> where C: BorrowMut, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &DeprecationStatus) -> ImageDeprecateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: DeprecationStatus) -> ImageDeprecateCall<'a, C, A> { + self._request = new_value; self } /// Project ID for this request. @@ -33913,7 +34390,7 @@ impl<'a, C, A> ImageDeprecateCall<'a, C, A> where C: BorrowMut, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.images().insert(&req, "project") +/// let result = hub.images().insert(req, "project") /// .doit(); /// # } /// ``` @@ -34041,12 +34518,17 @@ impl<'a, C, A> ImageInsertCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -34055,7 +34537,7 @@ impl<'a, C, A> ImageInsertCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -34073,8 +34555,8 @@ impl<'a, C, A> ImageInsertCall<'a, C, A> where C: BorrowMut, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Image) -> ImageInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Image) -> ImageInsertCall<'a, C, A> { + self._request = new_value; self } /// Project ID for this request. @@ -34286,12 +34768,17 @@ impl<'a, C, A> ImageGetCall<'a, C, A> where C: BorrowMut, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -34300,7 +34787,7 @@ impl<'a, C, A> ImageGetCall<'a, C, A> where C: BorrowMut, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -34545,12 +35032,17 @@ impl<'a, C, A> MachineTypeAggregatedListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -34559,7 +35051,7 @@ impl<'a, C, A> MachineTypeAggregatedListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -34804,12 +35296,17 @@ impl<'a, C, A> MachineTypeGetCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -34818,7 +35315,7 @@ impl<'a, C, A> MachineTypeGetCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -35075,12 +35572,17 @@ impl<'a, C, A> MachineTypeListCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -35089,7 +35591,7 @@ impl<'a, C, A> MachineTypeListCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -35355,12 +35857,17 @@ impl<'a, C, A> TargetVpnGatewayAggregatedListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -35369,7 +35876,7 @@ impl<'a, C, A> TargetVpnGatewayAggregatedListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -35614,12 +36121,17 @@ impl<'a, C, A> TargetVpnGatewayGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -35628,7 +36140,7 @@ impl<'a, C, A> TargetVpnGatewayGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -35885,12 +36397,17 @@ impl<'a, C, A> TargetVpnGatewayListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -35899,7 +36416,7 @@ impl<'a, C, A> TargetVpnGatewayListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -36037,7 +36554,7 @@ impl<'a, C, A> TargetVpnGatewayListCall<'a, C, A> where C: BorrowMut TargetVpnGatewayInsertCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -36181,7 +36703,7 @@ impl<'a, C, A> TargetVpnGatewayInsertCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -36199,8 +36721,8 @@ impl<'a, C, A> TargetVpnGatewayInsertCall<'a, C, A> where C: BorrowMut TargetVpnGatewayInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: TargetVpnGateway) -> TargetVpnGatewayInsertCall<'a, C, A> { + self._request = new_value; self } /// Project ID for this request. @@ -36424,12 +36946,17 @@ impl<'a, C, A> TargetVpnGatewayDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -36438,7 +36965,7 @@ impl<'a, C, A> TargetVpnGatewayDeleteCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -36565,7 +37092,7 @@ impl<'a, C, A> TargetVpnGatewayDeleteCall<'a, C, A> where C: BorrowMut ProjectMoveDiskCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -36707,7 +37239,7 @@ impl<'a, C, A> ProjectMoveDiskCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -36725,8 +37257,8 @@ impl<'a, C, A> ProjectMoveDiskCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &DiskMoveRequest) -> ProjectMoveDiskCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: DiskMoveRequest) -> ProjectMoveDiskCall<'a, C, A> { + self._request = new_value; self } /// Project ID for this request. @@ -36823,7 +37355,7 @@ impl<'a, C, A> ProjectMoveDiskCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.projects().set_common_instance_metadata(&req, "project") +/// let result = hub.projects().set_common_instance_metadata(req, "project") /// .doit(); /// # } /// ``` @@ -36951,12 +37483,17 @@ impl<'a, C, A> ProjectSetCommonInstanceMetadataCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -36965,7 +37502,7 @@ impl<'a, C, A> ProjectSetCommonInstanceMetadataCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -36983,8 +37520,8 @@ impl<'a, C, A> ProjectSetCommonInstanceMetadataCall<'a, C, A> where C: BorrowMut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Metadata) -> ProjectSetCommonInstanceMetadataCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Metadata) -> ProjectSetCommonInstanceMetadataCall<'a, C, A> { + self._request = new_value; self } /// Project ID for this request. @@ -37194,12 +37731,17 @@ impl<'a, C, A> ProjectGetCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -37208,7 +37750,7 @@ impl<'a, C, A> ProjectGetCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -37315,7 +37857,7 @@ impl<'a, C, A> ProjectGetCall<'a, C, A> where C: BorrowMut, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.projects().move_instance(&req, "project") +/// let result = hub.projects().move_instance(req, "project") /// .doit(); /// # } /// ``` @@ -37443,12 +37985,17 @@ impl<'a, C, A> ProjectMoveInstanceCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -37457,7 +38004,7 @@ impl<'a, C, A> ProjectMoveInstanceCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -37475,8 +38022,8 @@ impl<'a, C, A> ProjectMoveInstanceCall<'a, C, A> where C: BorrowMut ProjectMoveInstanceCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: InstanceMoveRequest) -> ProjectMoveInstanceCall<'a, C, A> { + self._request = new_value; self } /// Project ID for this request. @@ -37573,7 +38120,7 @@ impl<'a, C, A> ProjectMoveInstanceCall<'a, C, A> where C: BorrowMut ProjectSetUsageExportBucketCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -37715,7 +38267,7 @@ impl<'a, C, A> ProjectSetUsageExportBucketCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -37733,8 +38285,8 @@ impl<'a, C, A> ProjectSetUsageExportBucketCall<'a, C, A> where C: BorrowMut ProjectSetUsageExportBucketCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: UsageExportLocation) -> ProjectSetUsageExportBucketCall<'a, C, A> { + self._request = new_value; self } /// Project ID for this request. @@ -37946,12 +38498,17 @@ impl<'a, C, A> HttpHealthCheckGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -37960,7 +38517,7 @@ impl<'a, C, A> HttpHealthCheckGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -38077,7 +38634,7 @@ impl<'a, C, A> HttpHealthCheckGetCall<'a, C, A> where C: BorrowMut HttpHealthCheckPatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -38221,7 +38783,7 @@ impl<'a, C, A> HttpHealthCheckPatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -38239,8 +38801,8 @@ impl<'a, C, A> HttpHealthCheckPatchCall<'a, C, A> where C: BorrowMut HttpHealthCheckPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: HttpHealthCheck) -> HttpHealthCheckPatchCall<'a, C, A> { + self._request = new_value; self } /// Name of the project scoping this request. @@ -38475,12 +39037,17 @@ impl<'a, C, A> HttpHealthCheckListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -38489,7 +39056,7 @@ impl<'a, C, A> HttpHealthCheckListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -38732,12 +39299,17 @@ impl<'a, C, A> HttpHealthCheckDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -38746,7 +39318,7 @@ impl<'a, C, A> HttpHealthCheckDeleteCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -38863,7 +39435,7 @@ impl<'a, C, A> HttpHealthCheckDeleteCall<'a, C, A> where C: BorrowMut HttpHealthCheckInsertCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -39005,7 +39582,7 @@ impl<'a, C, A> HttpHealthCheckInsertCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -39023,8 +39600,8 @@ impl<'a, C, A> HttpHealthCheckInsertCall<'a, C, A> where C: BorrowMut HttpHealthCheckInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: HttpHealthCheck) -> HttpHealthCheckInsertCall<'a, C, A> { + self._request = new_value; self } /// Name of the project scoping this request. @@ -39121,7 +39698,7 @@ impl<'a, C, A> HttpHealthCheckInsertCall<'a, C, A> where C: BorrowMut HttpHealthCheckUpdateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -39265,7 +39847,7 @@ impl<'a, C, A> HttpHealthCheckUpdateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -39283,8 +39865,8 @@ impl<'a, C, A> HttpHealthCheckUpdateCall<'a, C, A> where C: BorrowMut HttpHealthCheckUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: HttpHealthCheck) -> HttpHealthCheckUpdateCall<'a, C, A> { + self._request = new_value; self } /// Name of the project scoping this request. @@ -39506,12 +40088,17 @@ impl<'a, C, A> InstanceTemplateDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -39520,7 +40107,7 @@ impl<'a, C, A> InstanceTemplateDeleteCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -39752,12 +40339,17 @@ impl<'a, C, A> InstanceTemplateGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -39766,7 +40358,7 @@ impl<'a, C, A> InstanceTemplateGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -40011,12 +40603,17 @@ impl<'a, C, A> InstanceTemplateListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -40025,7 +40622,7 @@ impl<'a, C, A> InstanceTemplateListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -40153,7 +40750,7 @@ impl<'a, C, A> InstanceTemplateListCall<'a, C, A> where C: BorrowMut InstanceTemplateInsertCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -40295,7 +40897,7 @@ impl<'a, C, A> InstanceTemplateInsertCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -40313,8 +40915,8 @@ impl<'a, C, A> InstanceTemplateInsertCall<'a, C, A> where C: BorrowMut InstanceTemplateInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: InstanceTemplate) -> InstanceTemplateInsertCall<'a, C, A> { + self._request = new_value; self } /// Name of the project scoping this request. @@ -40526,12 +41128,17 @@ impl<'a, C, A> TargetHttpProxyDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -40540,7 +41147,7 @@ impl<'a, C, A> TargetHttpProxyDeleteCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -40785,12 +41392,17 @@ impl<'a, C, A> TargetHttpProxyListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -40799,7 +41411,7 @@ impl<'a, C, A> TargetHttpProxyListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -41042,12 +41654,17 @@ impl<'a, C, A> TargetHttpProxyGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -41056,7 +41673,7 @@ impl<'a, C, A> TargetHttpProxyGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -41173,7 +41790,7 @@ impl<'a, C, A> TargetHttpProxyGetCall<'a, C, A> where C: BorrowMut TargetHttpProxySetUrlMapCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -41317,7 +41939,7 @@ impl<'a, C, A> TargetHttpProxySetUrlMapCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -41335,8 +41957,8 @@ impl<'a, C, A> TargetHttpProxySetUrlMapCall<'a, C, A> where C: BorrowMut TargetHttpProxySetUrlMapCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: UrlMapReference) -> TargetHttpProxySetUrlMapCall<'a, C, A> { + self._request = new_value; self } /// Name of the project scoping this request. @@ -41443,7 +42065,7 @@ impl<'a, C, A> TargetHttpProxySetUrlMapCall<'a, C, A> where C: BorrowMut TargetHttpProxyInsertCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -41585,7 +42212,7 @@ impl<'a, C, A> TargetHttpProxyInsertCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -41603,8 +42230,8 @@ impl<'a, C, A> TargetHttpProxyInsertCall<'a, C, A> where C: BorrowMut TargetHttpProxyInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: TargetHttpProxy) -> TargetHttpProxyInsertCall<'a, C, A> { + self._request = new_value; self } /// Name of the project scoping this request. @@ -41817,12 +42444,17 @@ impl<'a, C, A> ZoneOperationDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -42078,12 +42710,17 @@ impl<'a, C, A> ZoneOperationListCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -42092,7 +42729,7 @@ impl<'a, C, A> ZoneOperationListCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -42347,12 +42984,17 @@ impl<'a, C, A> ZoneOperationGetCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -42361,7 +43003,7 @@ impl<'a, C, A> ZoneOperationGetCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -42603,12 +43245,17 @@ impl<'a, C, A> RouteGetCall<'a, C, A> where C: BorrowMut, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -42617,7 +43264,7 @@ impl<'a, C, A> RouteGetCall<'a, C, A> where C: BorrowMut, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -42734,7 +43381,7 @@ impl<'a, C, A> RouteGetCall<'a, C, A> where C: BorrowMut, A: oaut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.routes().insert(&req, "project") +/// let result = hub.routes().insert(req, "project") /// .doit(); /// # } /// ``` @@ -42862,12 +43509,17 @@ impl<'a, C, A> RouteInsertCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -42876,7 +43528,7 @@ impl<'a, C, A> RouteInsertCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -42894,8 +43546,8 @@ impl<'a, C, A> RouteInsertCall<'a, C, A> where C: BorrowMut, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Route) -> RouteInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Route) -> RouteInsertCall<'a, C, A> { + self._request = new_value; self } /// Name of the project scoping this request. @@ -43120,12 +43772,17 @@ impl<'a, C, A> RouteListCall<'a, C, A> where C: BorrowMut, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -43134,7 +43791,7 @@ impl<'a, C, A> RouteListCall<'a, C, A> where C: BorrowMut, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -43377,12 +44034,17 @@ impl<'a, C, A> RouteDeleteCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -43391,7 +44053,7 @@ impl<'a, C, A> RouteDeleteCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -43508,7 +44170,7 @@ impl<'a, C, A> RouteDeleteCall<'a, C, A> where C: BorrowMut, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.firewalls().patch(&req, "project", "firewall") +/// let result = hub.firewalls().patch(req, "project", "firewall") /// .doit(); /// # } /// ``` @@ -43638,12 +44300,17 @@ impl<'a, C, A> FirewallPatchCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -43652,7 +44319,7 @@ impl<'a, C, A> FirewallPatchCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -43670,8 +44337,8 @@ impl<'a, C, A> FirewallPatchCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Firewall) -> FirewallPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Firewall) -> FirewallPatchCall<'a, C, A> { + self._request = new_value; self } /// Project ID for this request. @@ -43893,12 +44560,17 @@ impl<'a, C, A> FirewallGetCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -43907,7 +44579,7 @@ impl<'a, C, A> FirewallGetCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -44024,7 +44696,7 @@ impl<'a, C, A> FirewallGetCall<'a, C, A> where C: BorrowMut, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.firewalls().insert(&req, "project") +/// let result = hub.firewalls().insert(req, "project") /// .doit(); /// # } /// ``` @@ -44152,12 +44824,17 @@ impl<'a, C, A> FirewallInsertCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -44166,7 +44843,7 @@ impl<'a, C, A> FirewallInsertCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -44184,8 +44861,8 @@ impl<'a, C, A> FirewallInsertCall<'a, C, A> where C: BorrowMut, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Firewall) -> FirewallInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Firewall) -> FirewallInsertCall<'a, C, A> { + self._request = new_value; self } /// Project ID for this request. @@ -44282,7 +44959,7 @@ impl<'a, C, A> FirewallInsertCall<'a, C, A> where C: BorrowMut, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.firewalls().update(&req, "project", "firewall") +/// let result = hub.firewalls().update(req, "project", "firewall") /// .doit(); /// # } /// ``` @@ -44412,12 +45089,17 @@ impl<'a, C, A> FirewallUpdateCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -44426,7 +45108,7 @@ impl<'a, C, A> FirewallUpdateCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -44444,8 +45126,8 @@ impl<'a, C, A> FirewallUpdateCall<'a, C, A> where C: BorrowMut, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Firewall) -> FirewallUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Firewall) -> FirewallUpdateCall<'a, C, A> { + self._request = new_value; self } /// Project ID for this request. @@ -44667,12 +45349,17 @@ impl<'a, C, A> FirewallDeleteCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -44681,7 +45368,7 @@ impl<'a, C, A> FirewallDeleteCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -44926,12 +45613,17 @@ impl<'a, C, A> FirewallListCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -44940,7 +45632,7 @@ impl<'a, C, A> FirewallListCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -45185,12 +45877,17 @@ impl<'a, C, A> VpnTunnelDeleteCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -45199,7 +45896,7 @@ impl<'a, C, A> VpnTunnelDeleteCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -45456,12 +46153,17 @@ impl<'a, C, A> VpnTunnelListCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -45470,7 +46172,7 @@ impl<'a, C, A> VpnTunnelListCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -45725,12 +46427,17 @@ impl<'a, C, A> VpnTunnelGetCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -45739,7 +46446,7 @@ impl<'a, C, A> VpnTunnelGetCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -45866,7 +46573,7 @@ impl<'a, C, A> VpnTunnelGetCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.vpn_tunnels().insert(&req, "project", "region") +/// let result = hub.vpn_tunnels().insert(req, "project", "region") /// .doit(); /// # } /// ``` @@ -45996,12 +46703,17 @@ impl<'a, C, A> VpnTunnelInsertCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -46010,7 +46722,7 @@ impl<'a, C, A> VpnTunnelInsertCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -46028,8 +46740,8 @@ impl<'a, C, A> VpnTunnelInsertCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &VpnTunnel) -> VpnTunnelInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: VpnTunnel) -> VpnTunnelInsertCall<'a, C, A> { + self._request = new_value; self } /// Project ID for this request. @@ -46264,12 +46976,17 @@ impl<'a, C, A> VpnTunnelAggregatedListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -46278,7 +46995,7 @@ impl<'a, C, A> VpnTunnelAggregatedListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -46536,12 +47253,17 @@ impl<'a, C, A> RegionOperationListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -46550,7 +47272,7 @@ impl<'a, C, A> RegionOperationListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -46804,12 +47526,17 @@ impl<'a, C, A> RegionOperationDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -47052,12 +47779,17 @@ impl<'a, C, A> RegionOperationGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -47066,7 +47798,7 @@ impl<'a, C, A> RegionOperationGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/container1_beta1-cli/Cargo.toml b/gen/container1_beta1-cli/Cargo.toml index ec5a4d72bb..99501e8fbf 100644 --- a/gen/container1_beta1-cli/Cargo.toml +++ b/gen/container1_beta1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-container1_beta1-cli" -version = "0.0.1+20150420" +version = "0.1.0+20150420" authors = ["Sebastian Thiel "] description = "A complete library to interact with container (protocol v1beta1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/container1_beta1-cli" diff --git a/gen/container1_beta1-cli/README.md b/gen/container1_beta1-cli/README.md index 8b7d47d4a8..9d034a5899 100644 --- a/gen/container1_beta1-cli/README.md +++ b/gen/container1_beta1-cli/README.md @@ -1,4 +1,110 @@ -# HELLO CONTAINER:V1BETA1 + +The `container1-beta1` command-line interface *(CLI)* allows to use most features of the *Google container* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *container* API at revision *20150420*. The CLI is at version *0.1.0*. + +```bash + container1-beta1 [options] projects clusters-list [-p ...] [-o ] + container1-beta1 [options] projects operations-list [-p ...] [-o ] + container1-beta1 [options] projects zones-clusters-create -r ... [-p ...] [-o ] + container1-beta1 [options] projects zones-clusters-delete [-p ...] [-o ] + container1-beta1 [options] projects zones-clusters-get [-p ...] [-o ] + container1-beta1 [options] projects zones-clusters-list [-p ...] [-o ] + container1-beta1 [options] projects zones-operations-get [-p ...] [-o ] + container1-beta1 [options] projects zones-operations-list [-p ...] [-o ] + container1-beta1 [options] projects zones-tokens-get [-p ...] [-o ] + container1-beta1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_container1_beta1_cli/index.html + +Configuration: + --scope + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `container1-beta1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/container1-beta1-token-.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/container1-beta1-secret.json`, assuming that the required *container* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `container1-beta1 --debug [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/container1_beta1-cli/mkdocs.yml b/gen/container1_beta1-cli/mkdocs.yml index dda10ae786..3f42cb1b06 100644 --- a/gen/container1_beta1-cli/mkdocs.yml +++ b/gen/container1_beta1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: container v0.0.1+20150420 +site_name: container v0.1.0+20150420 site_url: http://byron.github.io/google-apis-rs/google-container1_beta1-cli site_description: Write integrating applications with bcore diff --git a/gen/container1_beta1-cli/src/cmn.rs b/gen/container1_beta1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/container1_beta1-cli/src/cmn.rs +++ b/gen/container1_beta1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/container1_beta1-cli/src/main.rs b/gen/container1_beta1-cli/src/main.rs index 6aa2f1e845..40be62d86f 100644 --- a/gen/container1_beta1-cli/src/main.rs +++ b/gen/container1_beta1-cli/src/main.rs @@ -19,34 +19,35 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - container1-beta1 [options] projects clusters-list [-p ]... [-o ] - container1-beta1 [options] projects operations-list [-p ]... [-o ] - container1-beta1 [options] projects zones-clusters-create -r ... [-p ]... [-o ] - container1-beta1 [options] projects zones-clusters-delete [-p ]... [-o ] - container1-beta1 [options] projects zones-clusters-get [-p ]... [-o ] - container1-beta1 [options] projects zones-clusters-list [-p ]... [-o ] - container1-beta1 [options] projects zones-operations-get [-p ]... [-o ] - container1-beta1 [options] projects zones-operations-list [-p ]... [-o ] - container1-beta1 [options] projects zones-tokens-get [-p ]... [-o ] + container1-beta1 [options] projects clusters-list [-p ...] [-o ] + container1-beta1 [options] projects operations-list [-p ...] [-o ] + container1-beta1 [options] projects zones-clusters-create -r ... [-p ...] [-o ] + container1-beta1 [options] projects zones-clusters-delete [-p ...] [-o ] + container1-beta1 [options] projects zones-clusters-get [-p ...] [-o ] + container1-beta1 [options] projects zones-clusters-list [-p ...] [-o ] + container1-beta1 [options] projects zones-operations-get [-p ...] [-o ] + container1-beta1 [options] projects zones-operations-list [-p ...] [-o ] + container1-beta1 [options] projects zones-tokens-get [-p ...] [-o ] container1-beta1 --help -All documentation details can be found TODO: +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_container1_beta1_cli/index.html Configuration: --scope - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -95,6 +96,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -138,6 +142,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -154,36 +161,23 @@ impl Engine { fn _projects_zones_clusters_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::CreateClusterRequest::default(); - let mut call = self.hub.projects().zones_clusters_create(&request, &self.opt.arg_project_id, &self.opt.arg_zone_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::CreateClusterRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_cluster_init(request: &mut api::CreateClusterRequest) { if request.cluster.is_none() { request.cluster = Some(Default::default()); @@ -204,7 +198,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "cluster.status" => { request_cluster_init(&mut request); request.cluster.as_mut().unwrap().status = Some(value.unwrap_or("").to_string()); @@ -286,15 +280,40 @@ impl Engine { request.cluster.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.projects().zones_clusters_create(request, &self.opt.arg_project_id, &self.opt.arg_zone_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -338,6 +357,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -381,6 +403,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -424,6 +449,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -467,6 +495,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -510,6 +541,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -662,6 +696,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -669,8 +704,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/container1_beta1/Cargo.toml b/gen/container1_beta1/Cargo.toml index 5cea9d0555..ddcd8bdc9c 100644 --- a/gen/container1_beta1/Cargo.toml +++ b/gen/container1_beta1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-container1_beta1" -version = "0.1.5+20150420" +version = "0.1.6+20150420" authors = ["Sebastian Thiel "] description = "A complete library to interact with container (protocol v1beta1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/container1_beta1" diff --git a/gen/container1_beta1/README.md b/gen/container1_beta1/README.md index be6c4472b9..e9fc88738b 100644 --- a/gen/container1_beta1/README.md +++ b/gen/container1_beta1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-container1_beta1` library allows access to all features of the *Google container* service. -This documentation was generated from *container* crate version *0.1.5+20150420*, where *20150420* is the exact revision of the *container:v1beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *container* crate version *0.1.6+20150420*, where *20150420* is the exact revision of the *container:v1beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *container* *v1_beta1* API can be found at the [official documentation site](https://cloud.google.com/container-engine/docs/v1beta1/). @@ -101,14 +101,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/container1_beta1/src/cmn.rs b/gen/container1_beta1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/container1_beta1/src/cmn.rs +++ b/gen/container1_beta1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option, + location: Option +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option, _: Option) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec]) -> Option { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/container1_beta1/src/lib.rs b/gen/container1_beta1/src/lib.rs index c83c48f931..aefa8c6069 100644 --- a/gen/container1_beta1/src/lib.rs +++ b/gen/container1_beta1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *container* crate version *0.1.5+20150420*, where *20150420* is the exact revision of the *container:v1beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *container* crate version *0.1.6+20150420*, where *20150420* is the exact revision of the *container:v1beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *container* *v1_beta1* API can be found at the //! [official documentation site](https://cloud.google.com/container-engine/docs/v1beta1/). @@ -102,14 +102,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -197,7 +198,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -271,14 +272,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -299,7 +301,7 @@ impl<'a, C, A> Container Container { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -308,7 +310,7 @@ impl<'a, C, A> Container } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -815,10 +817,10 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// * `request` - No description provided. /// * `projectId` - The Google Developers Console project ID or project number. /// * `zoneId` - The name of the Google Compute Engine zone in which the cluster resides. - pub fn zones_clusters_create(&self, request: &CreateClusterRequest, project_id: &str, zone_id: &str) -> ProjectZoneClusterCreateCall<'a, C, A> { + pub fn zones_clusters_create(&self, request: CreateClusterRequest, project_id: &str, zone_id: &str) -> ProjectZoneClusterCreateCall<'a, C, A> { ProjectZoneClusterCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _project_id: project_id.to_string(), _zone_id: zone_id.to_string(), _delegate: Default::default(), @@ -985,12 +987,17 @@ impl<'a, C, A> ProjectZoneClusterGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -999,7 +1006,7 @@ impl<'a, C, A> ProjectZoneClusterGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1239,12 +1246,17 @@ impl<'a, C, A> ProjectOperationListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1253,7 +1265,7 @@ impl<'a, C, A> ProjectOperationListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1473,12 +1485,17 @@ impl<'a, C, A> ProjectZoneTokenGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1487,7 +1504,7 @@ impl<'a, C, A> ProjectZoneTokenGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1727,12 +1744,17 @@ impl<'a, C, A> ProjectZoneClusterDeleteCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1741,7 +1763,7 @@ impl<'a, C, A> ProjectZoneClusterDeleteCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1981,12 +2003,17 @@ impl<'a, C, A> ProjectClusterListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1995,7 +2022,7 @@ impl<'a, C, A> ProjectClusterListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2219,12 +2246,17 @@ impl<'a, C, A> ProjectZoneOperationGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2233,7 +2265,7 @@ impl<'a, C, A> ProjectZoneOperationGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2475,12 +2507,17 @@ impl<'a, C, A> ProjectZoneOperationListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2489,7 +2526,7 @@ impl<'a, C, A> ProjectZoneOperationListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2721,12 +2758,17 @@ impl<'a, C, A> ProjectZoneClusterListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2735,7 +2777,7 @@ impl<'a, C, A> ProjectZoneClusterListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2858,7 +2900,7 @@ impl<'a, C, A> ProjectZoneClusterListCall<'a, C, A> where C: BorrowMut ProjectZoneClusterCreateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3002,7 +3049,7 @@ impl<'a, C, A> ProjectZoneClusterCreateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3020,8 +3067,8 @@ impl<'a, C, A> ProjectZoneClusterCreateCall<'a, C, A> where C: BorrowMut ProjectZoneClusterCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CreateClusterRequest) -> ProjectZoneClusterCreateCall<'a, C, A> { + self._request = new_value; self } /// The Google Developers Console project ID or project number. diff --git a/gen/content2-cli/Cargo.toml b/gen/content2-cli/Cargo.toml index 03414f7b25..f958457630 100644 --- a/gen/content2-cli/Cargo.toml +++ b/gen/content2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-content2-cli" -version = "0.0.1+20150421" +version = "0.1.0+20150421" authors = ["Sebastian Thiel "] description = "A complete library to interact with Shopping Content (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/content2-cli" diff --git a/gen/content2-cli/README.md b/gen/content2-cli/README.md index 5538bc18d2..e51e60ce99 100644 --- a/gen/content2-cli/README.md +++ b/gen/content2-cli/README.md @@ -1,4 +1,142 @@ -# HELLO CONTENT:V2 + +The `content2` command-line interface *(CLI)* allows to use most features of the *Google Shopping Content* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *Shopping Content* API at revision *20150421*. The CLI is at version *0.1.0*. + +```bash + content2 [options] accounts authinfo [-p ...] [-o ] + content2 [options] accounts custombatch -r ... [-p ...] [-o ] + content2 [options] accounts delete [-p ...] + content2 [options] accounts get [-p ...] [-o ] + content2 [options] accounts insert -r ... [-p ...] [-o ] + content2 [options] accounts list [-p ...] [-o ] + content2 [options] accounts patch -r ... [-p ...] [-o ] + content2 [options] accounts update -r ... [-p ...] [-o ] + content2 [options] accountshipping custombatch -r ... [-p ...] [-o ] + content2 [options] accountshipping get [-p ...] [-o ] + content2 [options] accountshipping list [-p ...] [-o ] + content2 [options] accountshipping patch -r ... [-p ...] [-o ] + content2 [options] accountshipping update -r ... [-p ...] [-o ] + content2 [options] accountstatuses custombatch -r ... [-p ...] [-o ] + content2 [options] accountstatuses get [-p ...] [-o ] + content2 [options] accountstatuses list [-p ...] [-o ] + content2 [options] accounttax custombatch -r ... [-p ...] [-o ] + content2 [options] accounttax get [-p ...] [-o ] + content2 [options] accounttax list [-p ...] [-o ] + content2 [options] accounttax patch -r ... [-p ...] [-o ] + content2 [options] accounttax update -r ... [-p ...] [-o ] + content2 [options] datafeeds custombatch -r ... [-p ...] [-o ] + content2 [options] datafeeds delete [-p ...] + content2 [options] datafeeds get [-p ...] [-o ] + content2 [options] datafeeds insert -r ... [-p ...] [-o ] + content2 [options] datafeeds list [-p ...] [-o ] + content2 [options] datafeeds patch -r ... [-p ...] [-o ] + content2 [options] datafeeds update -r ... [-p ...] [-o ] + content2 [options] datafeedstatuses custombatch -r ... [-p ...] [-o ] + content2 [options] datafeedstatuses get [-p ...] [-o ] + content2 [options] datafeedstatuses list [-p ...] [-o ] + content2 [options] inventory custombatch -r ... [-p ...] [-o ] + content2 [options] inventory set -r ... [-p ...] [-o ] + content2 [options] products custombatch -r ... [-p ...] [-o ] + content2 [options] products delete [-p ...] + content2 [options] products get [-p ...] [-o ] + content2 [options] products insert -r ... [-p ...] [-o ] + content2 [options] products list [-p ...] [-o ] + content2 [options] productstatuses custombatch -r ... [-p ...] [-o ] + content2 [options] productstatuses get [-p ...] [-o ] + content2 [options] productstatuses list [-p ...] [-o ] + content2 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_content2_cli/index.html + +Configuration: + --scope + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `content2-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/content2-token-.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/content2-secret.json`, assuming that the required *content* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `content2 --debug [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/content2-cli/mkdocs.yml b/gen/content2-cli/mkdocs.yml index 01367bc243..aa18e02ba8 100644 --- a/gen/content2-cli/mkdocs.yml +++ b/gen/content2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Shopping Content v0.0.1+20150421 +site_name: Shopping Content v0.1.0+20150421 site_url: http://byron.github.io/google-apis-rs/google-content2-cli site_description: Write integrating applications with bcore diff --git a/gen/content2-cli/src/cmn.rs b/gen/content2-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/content2-cli/src/cmn.rs +++ b/gen/content2-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/content2-cli/src/main.rs b/gen/content2-cli/src/main.rs index 6f9758e38b..be44ec9bbc 100644 --- a/gen/content2-cli/src/main.rs +++ b/gen/content2-cli/src/main.rs @@ -19,66 +19,67 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - content2 [options] accounts authinfo [-p ]... [-o ] - content2 [options] accounts custombatch -r ... [-p ]... [-o ] - content2 [options] accounts delete [-p ]... - content2 [options] accounts get [-p ]... [-o ] - content2 [options] accounts insert -r ... [-p ]... [-o ] - content2 [options] accounts list [-p ]... [-o ] - content2 [options] accounts patch -r ... [-p ]... [-o ] - content2 [options] accounts update -r ... [-p ]... [-o ] - content2 [options] accountshipping custombatch -r ... [-p ]... [-o ] - content2 [options] accountshipping get [-p ]... [-o ] - content2 [options] accountshipping list [-p ]... [-o ] - content2 [options] accountshipping patch -r ... [-p ]... [-o ] - content2 [options] accountshipping update -r ... [-p ]... [-o ] - content2 [options] accountstatuses custombatch -r ... [-p ]... [-o ] - content2 [options] accountstatuses get [-p ]... [-o ] - content2 [options] accountstatuses list [-p ]... [-o ] - content2 [options] accounttax custombatch -r ... [-p ]... [-o ] - content2 [options] accounttax get [-p ]... [-o ] - content2 [options] accounttax list [-p ]... [-o ] - content2 [options] accounttax patch -r ... [-p ]... [-o ] - content2 [options] accounttax update -r ... [-p ]... [-o ] - content2 [options] datafeeds custombatch -r ... [-p ]... [-o ] - content2 [options] datafeeds delete [-p ]... - content2 [options] datafeeds get [-p ]... [-o ] - content2 [options] datafeeds insert -r ... [-p ]... [-o ] - content2 [options] datafeeds list [-p ]... [-o ] - content2 [options] datafeeds patch -r ... [-p ]... [-o ] - content2 [options] datafeeds update -r ... [-p ]... [-o ] - content2 [options] datafeedstatuses custombatch -r ... [-p ]... [-o ] - content2 [options] datafeedstatuses get [-p ]... [-o ] - content2 [options] datafeedstatuses list [-p ]... [-o ] - content2 [options] inventory custombatch -r ... [-p ]... [-o ] - content2 [options] inventory set -r ... [-p ]... [-o ] - content2 [options] products custombatch -r ... [-p ]... [-o ] - content2 [options] products delete [-p ]... - content2 [options] products get [-p ]... [-o ] - content2 [options] products insert -r ... [-p ]... [-o ] - content2 [options] products list [-p ]... [-o ] - content2 [options] productstatuses custombatch -r ... [-p ]... [-o ] - content2 [options] productstatuses get [-p ]... [-o ] - content2 [options] productstatuses list [-p ]... [-o ] + content2 [options] accounts authinfo [-p ...] [-o ] + content2 [options] accounts custombatch -r ... [-p ...] [-o ] + content2 [options] accounts delete [-p ...] + content2 [options] accounts get [-p ...] [-o ] + content2 [options] accounts insert -r ... [-p ...] [-o ] + content2 [options] accounts list [-p ...] [-o ] + content2 [options] accounts patch -r ... [-p ...] [-o ] + content2 [options] accounts update -r ... [-p ...] [-o ] + content2 [options] accountshipping custombatch -r ... [-p ...] [-o ] + content2 [options] accountshipping get [-p ...] [-o ] + content2 [options] accountshipping list [-p ...] [-o ] + content2 [options] accountshipping patch -r ... [-p ...] [-o ] + content2 [options] accountshipping update -r ... [-p ...] [-o ] + content2 [options] accountstatuses custombatch -r ... [-p ...] [-o ] + content2 [options] accountstatuses get [-p ...] [-o ] + content2 [options] accountstatuses list [-p ...] [-o ] + content2 [options] accounttax custombatch -r ... [-p ...] [-o ] + content2 [options] accounttax get [-p ...] [-o ] + content2 [options] accounttax list [-p ...] [-o ] + content2 [options] accounttax patch -r ... [-p ...] [-o ] + content2 [options] accounttax update -r ... [-p ...] [-o ] + content2 [options] datafeeds custombatch -r ... [-p ...] [-o ] + content2 [options] datafeeds delete [-p ...] + content2 [options] datafeeds get [-p ...] [-o ] + content2 [options] datafeeds insert -r ... [-p ...] [-o ] + content2 [options] datafeeds list [-p ...] [-o ] + content2 [options] datafeeds patch -r ... [-p ...] [-o ] + content2 [options] datafeeds update -r ... [-p ...] [-o ] + content2 [options] datafeedstatuses custombatch -r ... [-p ...] [-o ] + content2 [options] datafeedstatuses get [-p ...] [-o ] + content2 [options] datafeedstatuses list [-p ...] [-o ] + content2 [options] inventory custombatch -r ... [-p ...] [-o ] + content2 [options] inventory set -r ... [-p ...] [-o ] + content2 [options] products custombatch -r ... [-p ...] [-o ] + content2 [options] products delete [-p ...] + content2 [options] products get [-p ...] [-o ] + content2 [options] products insert -r ... [-p ...] [-o ] + content2 [options] products list [-p ...] [-o ] + content2 [options] productstatuses custombatch -r ... [-p ...] [-o ] + content2 [options] productstatuses get [-p ...] [-o ] + content2 [options] productstatuses list [-p ...] [-o ] content2 --help -All documentation details can be found TODO: +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_content2_cli/index.html Configuration: --scope - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -127,6 +128,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -143,8 +147,30 @@ impl Engine { fn _accounts_custombatch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::AccountsCustomBatchRequest::default(); - let mut call = self.hub.accounts().custombatch(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.accounts().custombatch(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -166,24 +192,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -227,6 +243,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -268,6 +287,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -284,37 +306,24 @@ impl Engine { fn _accounts_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Account::default(); - let mut call = self.hub.accounts().insert(&request, &self.opt.arg_merchant_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Account::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "reviews-url" => { request.reviews_url = Some(value.unwrap_or("").to_string()); }, @@ -337,15 +346,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.accounts().insert(request, &self.opt.arg_merchant_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -395,6 +429,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -411,37 +448,24 @@ impl Engine { fn _accounts_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Account::default(); - let mut call = self.hub.accounts().patch(&request, &self.opt.arg_merchant_id, &self.opt.arg_account_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Account::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "reviews-url" => { request.reviews_url = Some(value.unwrap_or("").to_string()); }, @@ -464,15 +488,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.accounts().patch(request, &self.opt.arg_merchant_id, &self.opt.arg_account_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -489,37 +538,24 @@ impl Engine { fn _accounts_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Account::default(); - let mut call = self.hub.accounts().update(&request, &self.opt.arg_merchant_id, &self.opt.arg_account_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Account::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "reviews-url" => { request.reviews_url = Some(value.unwrap_or("").to_string()); }, @@ -542,15 +578,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.accounts().update(request, &self.opt.arg_merchant_id, &self.opt.arg_account_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -567,8 +628,30 @@ impl Engine { fn _accountshipping_custombatch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::AccountshippingCustomBatchRequest::default(); - let mut call = self.hub.accountshipping().custombatch(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.accountshipping().custombatch(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -593,24 +676,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -654,6 +727,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -703,6 +779,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -719,8 +798,36 @@ impl Engine { fn _accountshipping_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::AccountShipping::default(); - let mut call = self.hub.accountshipping().patch(&request, &self.opt.arg_merchant_id, &self.opt.arg_account_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request.account_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.accountshipping().patch(request, &self.opt.arg_merchant_id, &self.opt.arg_account_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -745,30 +852,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request.account_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -785,8 +876,36 @@ impl Engine { fn _accountshipping_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::AccountShipping::default(); - let mut call = self.hub.accountshipping().update(&request, &self.opt.arg_merchant_id, &self.opt.arg_account_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request.account_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.accountshipping().update(request, &self.opt.arg_merchant_id, &self.opt.arg_account_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -811,30 +930,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request.account_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -851,8 +954,30 @@ impl Engine { fn _accountstatuses_custombatch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::AccountstatusesCustomBatchRequest::default(); - let mut call = self.hub.accountstatuses().custombatch(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.accountstatuses().custombatch(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -874,24 +999,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -935,6 +1050,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -984,6 +1102,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1000,8 +1121,30 @@ impl Engine { fn _accounttax_custombatch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::AccounttaxCustomBatchRequest::default(); - let mut call = self.hub.accounttax().custombatch(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.accounttax().custombatch(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1026,24 +1169,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1087,6 +1220,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1136,6 +1272,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1152,8 +1291,36 @@ impl Engine { fn _accounttax_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::AccountTax::default(); - let mut call = self.hub.accounttax().patch(&request, &self.opt.arg_merchant_id, &self.opt.arg_account_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request.account_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.accounttax().patch(request, &self.opt.arg_merchant_id, &self.opt.arg_account_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1178,30 +1345,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request.account_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1218,8 +1369,36 @@ impl Engine { fn _accounttax_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::AccountTax::default(); - let mut call = self.hub.accounttax().update(&request, &self.opt.arg_merchant_id, &self.opt.arg_account_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request.account_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.accounttax().update(request, &self.opt.arg_merchant_id, &self.opt.arg_account_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1244,30 +1423,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request.account_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1284,8 +1447,30 @@ impl Engine { fn _datafeeds_custombatch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::DatafeedsCustomBatchRequest::default(); - let mut call = self.hub.datafeeds().custombatch(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.datafeeds().custombatch(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1307,24 +1492,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1368,6 +1543,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1409,6 +1587,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1425,36 +1606,23 @@ impl Engine { fn _datafeeds_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Datafeed::default(); - let mut call = self.hub.datafeeds().insert(&request, &self.opt.arg_merchant_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Datafeed::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_fetch_schedule_init(request: &mut api::Datafeed) { if request.fetch_schedule.is_none() { request.fetch_schedule = Some(Default::default()); @@ -1467,7 +1635,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1544,15 +1712,40 @@ impl Engine { request.attribute_language = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.datafeeds().insert(request, &self.opt.arg_merchant_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1602,6 +1795,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1618,36 +1814,23 @@ impl Engine { fn _datafeeds_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Datafeed::default(); - let mut call = self.hub.datafeeds().patch(&request, &self.opt.arg_merchant_id, &self.opt.arg_datafeed_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Datafeed::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_fetch_schedule_init(request: &mut api::Datafeed) { if request.fetch_schedule.is_none() { request.fetch_schedule = Some(Default::default()); @@ -1660,7 +1843,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1737,15 +1920,40 @@ impl Engine { request.attribute_language = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.datafeeds().patch(request, &self.opt.arg_merchant_id, &self.opt.arg_datafeed_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1762,36 +1970,23 @@ impl Engine { fn _datafeeds_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Datafeed::default(); - let mut call = self.hub.datafeeds().update(&request, &self.opt.arg_merchant_id, &self.opt.arg_datafeed_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Datafeed::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_fetch_schedule_init(request: &mut api::Datafeed) { if request.fetch_schedule.is_none() { request.fetch_schedule = Some(Default::default()); @@ -1804,7 +1999,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1881,33 +2076,11 @@ impl Engine { request.attribute_language = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _datafeedstatuses_custombatch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request = api::DatafeedstatusesCustomBatchRequest::default(); - let mut call = self.hub.datafeedstatuses().custombatch(&request); + let mut call = self.hub.datafeeds().update(request, &self.opt.arg_merchant_id, &self.opt.arg_datafeed_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1929,17 +2102,73 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _datafeedstatuses_custombatch(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option { - let mut field_name = FieldCursor::default(); + let mut request = api::DatafeedstatusesCustomBatchRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); } + continue; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.datafeedstatuses().custombatch(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } let protocol = "standard-request"; @@ -1947,6 +2176,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1990,6 +2222,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2039,6 +2274,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2055,8 +2293,30 @@ impl Engine { fn _inventory_custombatch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::InventoryCustomBatchRequest::default(); - let mut call = self.hub.inventory().custombatch(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.inventory().custombatch(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2078,24 +2338,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2112,36 +2362,23 @@ impl Engine { fn _inventory_set(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::InventorySetRequest::default(); - let mut call = self.hub.inventory().set(&request, &self.opt.arg_merchant_id, &self.opt.arg_store_code, &self.opt.arg_product_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::InventorySetRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_price_init(request: &mut api::InventorySetRequest) { if request.price.is_none() { request.price = Some(Default::default()); @@ -2154,7 +2391,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "sale-price-effective-date" => { request.sale_price_effective_date = Some(value.unwrap_or("").to_string()); }, @@ -2183,15 +2420,40 @@ impl Engine { request.quantity = Some(arg_from_str(value.unwrap_or("-0"), err, "quantity", "integer")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.inventory().set(request, &self.opt.arg_merchant_id, &self.opt.arg_store_code, &self.opt.arg_product_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2208,8 +2470,30 @@ impl Engine { fn _products_custombatch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::ProductsCustomBatchRequest::default(); - let mut call = self.hub.products().custombatch(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.products().custombatch(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2234,24 +2518,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2298,6 +2572,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2339,6 +2616,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2355,39 +2635,23 @@ impl Engine { fn _products_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request = api::Product::default(); - let mut call = self.hub.products().insert(&request, &self.opt.arg_merchant_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "dry-run" => { - call = call.dry_run(arg_from_str(value.unwrap_or("false"), err, "dry-run", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Product::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_installment_amount_init(request: &mut api::Product) { request_installment_init(request); if request.installment.as_mut().unwrap().amount.is_none() { @@ -2455,7 +2719,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "display-ads-title" => { request.display_ads_title = Some(value.unwrap_or("").to_string()); }, @@ -2749,15 +3013,43 @@ impl Engine { request.adwords_redirect = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.products().insert(request, &self.opt.arg_merchant_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "dry-run" => { + call = call.dry_run(arg_from_str(value.unwrap_or("false"), err, "dry-run", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2807,6 +3099,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2823,8 +3118,30 @@ impl Engine { fn _productstatuses_custombatch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { + let mut request = api::ProductstatusesCustomBatchRequest::default(); - let mut call = self.hub.productstatuses().custombatch(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.productstatuses().custombatch(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2846,24 +3163,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2907,6 +3214,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2956,6 +3266,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3169,6 +3482,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -3176,8 +3490,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/content2/Cargo.toml b/gen/content2/Cargo.toml index 911b7e4f41..545a866ece 100644 --- a/gen/content2/Cargo.toml +++ b/gen/content2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-content2" -version = "0.1.5+20150421" +version = "0.1.6+20150421" authors = ["Sebastian Thiel "] description = "A complete library to interact with Shopping Content (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/content2" diff --git a/gen/content2/README.md b/gen/content2/README.md index 689b800b7b..b94705f469 100644 --- a/gen/content2/README.md +++ b/gen/content2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-content2` library allows access to all features of the *Google Shopping Content* service. -This documentation was generated from *Shopping Content* crate version *0.1.5+20150421*, where *20150421* is the exact revision of the *content:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *Shopping Content* crate version *0.1.6+20150421*, where *20150421* is the exact revision of the *content:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *Shopping Content* *v2* API can be found at the [official documentation site](https://developers.google.com/shopping-content/v2/). @@ -121,21 +121,22 @@ let mut req = Account::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.accounts().patch(&req, "merchantId", "accountId") +let result = hub.accounts().patch(req, "merchantId", "accountId") .doit(); match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/content2/src/cmn.rs b/gen/content2/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/content2/src/cmn.rs +++ b/gen/content2/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option, + location: Option +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option, _: Option) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec]) -> Option { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/content2/src/lib.rs b/gen/content2/src/lib.rs index 714d300a01..6cd70bf400 100644 --- a/gen/content2/src/lib.rs +++ b/gen/content2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Shopping Content* crate version *0.1.5+20150421*, where *20150421* is the exact revision of the *content:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *Shopping Content* crate version *0.1.6+20150421*, where *20150421* is the exact revision of the *content:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *Shopping Content* *v2* API can be found at the //! [official documentation site](https://developers.google.com/shopping-content/v2/). @@ -122,21 +122,22 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.accounts().patch(&req, "merchantId", "accountId") +//! let result = hub.accounts().patch(req, "merchantId", "accountId") //! .doit(); //! //! match result { //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -224,7 +225,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -297,21 +298,22 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().patch(&req, "merchantId", "accountId") +/// let result = hub.accounts().patch(req, "merchantId", "accountId") /// .doit(); /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -332,7 +334,7 @@ impl<'a, C, A> ShoppingContent ShoppingContent { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -365,7 +367,7 @@ impl<'a, C, A> ShoppingContent } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -2665,10 +2667,10 @@ impl<'a, C, A> AccounttaxMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn custombatch(&self, request: &AccounttaxCustomBatchRequest) -> AccounttaxCustombatchCall<'a, C, A> { + pub fn custombatch(&self, request: AccounttaxCustomBatchRequest) -> AccounttaxCustombatchCall<'a, C, A> { AccounttaxCustombatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _dry_run: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -2685,10 +2687,10 @@ impl<'a, C, A> AccounttaxMethods<'a, C, A> { /// * `request` - No description provided. /// * `merchantId` - The ID of the managing account. /// * `accountId` - The ID of the account for which to get/update account tax settings. - pub fn patch(&self, request: &AccountTax, merchant_id: &str, account_id: &str) -> AccounttaxPatchCall<'a, C, A> { + pub fn patch(&self, request: AccountTax, merchant_id: &str, account_id: &str) -> AccounttaxPatchCall<'a, C, A> { AccounttaxPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _merchant_id: merchant_id.to_string(), _account_id: account_id.to_string(), _dry_run: Default::default(), @@ -2726,10 +2728,10 @@ impl<'a, C, A> AccounttaxMethods<'a, C, A> { /// * `request` - No description provided. /// * `merchantId` - The ID of the managing account. /// * `accountId` - The ID of the account for which to get/update account tax settings. - pub fn update(&self, request: &AccountTax, merchant_id: &str, account_id: &str) -> AccounttaxUpdateCall<'a, C, A> { + pub fn update(&self, request: AccountTax, merchant_id: &str, account_id: &str) -> AccounttaxUpdateCall<'a, C, A> { AccounttaxUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _merchant_id: merchant_id.to_string(), _account_id: account_id.to_string(), _dry_run: Default::default(), @@ -2841,10 +2843,10 @@ impl<'a, C, A> DatafeedstatuseMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn custombatch(&self, request: &DatafeedstatusesCustomBatchRequest) -> DatafeedstatuseCustombatchCall<'a, C, A> { + pub fn custombatch(&self, request: DatafeedstatusesCustomBatchRequest) -> DatafeedstatuseCustombatchCall<'a, C, A> { DatafeedstatuseCustombatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2896,10 +2898,10 @@ impl<'a, C, A> DatafeedMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn custombatch(&self, request: &DatafeedsCustomBatchRequest) -> DatafeedCustombatchCall<'a, C, A> { + pub fn custombatch(&self, request: DatafeedsCustomBatchRequest) -> DatafeedCustombatchCall<'a, C, A> { DatafeedCustombatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2934,10 +2936,10 @@ impl<'a, C, A> DatafeedMethods<'a, C, A> { /// * `request` - No description provided. /// * `merchantId` - No description provided. /// * `datafeedId` - No description provided. - pub fn patch(&self, request: &Datafeed, merchant_id: &str, datafeed_id: &str) -> DatafeedPatchCall<'a, C, A> { + pub fn patch(&self, request: Datafeed, merchant_id: &str, datafeed_id: &str) -> DatafeedPatchCall<'a, C, A> { DatafeedPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _merchant_id: merchant_id.to_string(), _datafeed_id: datafeed_id.to_string(), _delegate: Default::default(), @@ -2973,10 +2975,10 @@ impl<'a, C, A> DatafeedMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `merchantId` - No description provided. - pub fn insert(&self, request: &Datafeed, merchant_id: &str) -> DatafeedInsertCall<'a, C, A> { + pub fn insert(&self, request: Datafeed, merchant_id: &str) -> DatafeedInsertCall<'a, C, A> { DatafeedInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _merchant_id: merchant_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3012,10 +3014,10 @@ impl<'a, C, A> DatafeedMethods<'a, C, A> { /// * `request` - No description provided. /// * `merchantId` - No description provided. /// * `datafeedId` - No description provided. - pub fn update(&self, request: &Datafeed, merchant_id: &str, datafeed_id: &str) -> DatafeedUpdateCall<'a, C, A> { + pub fn update(&self, request: Datafeed, merchant_id: &str, datafeed_id: &str) -> DatafeedUpdateCall<'a, C, A> { DatafeedUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _merchant_id: merchant_id.to_string(), _datafeed_id: datafeed_id.to_string(), _delegate: Default::default(), @@ -3110,10 +3112,10 @@ impl<'a, C, A> ProductstatuseMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn custombatch(&self, request: &ProductstatusesCustomBatchRequest) -> ProductstatuseCustombatchCall<'a, C, A> { + pub fn custombatch(&self, request: ProductstatusesCustomBatchRequest) -> ProductstatuseCustombatchCall<'a, C, A> { ProductstatuseCustombatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3182,10 +3184,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// * `request` - No description provided. /// * `merchantId` - The ID of the managing account. /// * `accountId` - The ID of the account. - pub fn patch(&self, request: &Account, merchant_id: &str, account_id: &str) -> AccountPatchCall<'a, C, A> { + pub fn patch(&self, request: Account, merchant_id: &str, account_id: &str) -> AccountPatchCall<'a, C, A> { AccountPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _merchant_id: merchant_id.to_string(), _account_id: account_id.to_string(), _delegate: Default::default(), @@ -3222,10 +3224,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// * `request` - No description provided. /// * `merchantId` - The ID of the managing account. /// * `accountId` - The ID of the account. - pub fn update(&self, request: &Account, merchant_id: &str, account_id: &str) -> AccountUpdateCall<'a, C, A> { + pub fn update(&self, request: Account, merchant_id: &str, account_id: &str) -> AccountUpdateCall<'a, C, A> { AccountUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _merchant_id: merchant_id.to_string(), _account_id: account_id.to_string(), _delegate: Default::default(), @@ -3279,10 +3281,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn custombatch(&self, request: &AccountsCustomBatchRequest) -> AccountCustombatchCall<'a, C, A> { + pub fn custombatch(&self, request: AccountsCustomBatchRequest) -> AccountCustombatchCall<'a, C, A> { AccountCustombatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3297,10 +3299,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `merchantId` - The ID of the managing account. - pub fn insert(&self, request: &Account, merchant_id: &str) -> AccountInsertCall<'a, C, A> { + pub fn insert(&self, request: Account, merchant_id: &str) -> AccountInsertCall<'a, C, A> { AccountInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _merchant_id: merchant_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3359,10 +3361,10 @@ impl<'a, C, A> InventoryMethods<'a, C, A> { /// * `merchantId` - The ID of the managing account. /// * `storeCode` - The code of the store for which to update price and availability. Use online to update price and availability of an online product. /// * `productId` - The ID of the product for which to update price and availability. - pub fn set(&self, request: &InventorySetRequest, merchant_id: &str, store_code: &str, product_id: &str) -> InventorySetCall<'a, C, A> { + pub fn set(&self, request: InventorySetRequest, merchant_id: &str, store_code: &str, product_id: &str) -> InventorySetCall<'a, C, A> { InventorySetCall { hub: self.hub, - _request: request.clone(), + _request: request, _merchant_id: merchant_id.to_string(), _store_code: store_code.to_string(), _product_id: product_id.to_string(), @@ -3379,10 +3381,10 @@ impl<'a, C, A> InventoryMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn custombatch(&self, request: &InventoryCustomBatchRequest) -> InventoryCustombatchCall<'a, C, A> { + pub fn custombatch(&self, request: InventoryCustomBatchRequest) -> InventoryCustombatchCall<'a, C, A> { InventoryCustombatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3472,10 +3474,10 @@ impl<'a, C, A> AccountstatuseMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn custombatch(&self, request: &AccountstatusesCustomBatchRequest) -> AccountstatuseCustombatchCall<'a, C, A> { + pub fn custombatch(&self, request: AccountstatusesCustomBatchRequest) -> AccountstatuseCustombatchCall<'a, C, A> { AccountstatuseCustombatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3588,10 +3590,10 @@ impl<'a, C, A> ProductMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn custombatch(&self, request: &ProductsCustomBatchRequest) -> ProductCustombatchCall<'a, C, A> { + pub fn custombatch(&self, request: ProductsCustomBatchRequest) -> ProductCustombatchCall<'a, C, A> { ProductCustombatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _dry_run: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -3607,10 +3609,10 @@ impl<'a, C, A> ProductMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `merchantId` - The ID of the managing account. - pub fn insert(&self, request: &Product, merchant_id: &str) -> ProductInsertCall<'a, C, A> { + pub fn insert(&self, request: Product, merchant_id: &str) -> ProductInsertCall<'a, C, A> { ProductInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _merchant_id: merchant_id.to_string(), _dry_run: Default::default(), _delegate: Default::default(), @@ -3688,10 +3690,10 @@ impl<'a, C, A> AccountshippingMethods<'a, C, A> { /// * `request` - No description provided. /// * `merchantId` - The ID of the managing account. /// * `accountId` - The ID of the account for which to get/update account shipping settings. - pub fn patch(&self, request: &AccountShipping, merchant_id: &str, account_id: &str) -> AccountshippingPatchCall<'a, C, A> { + pub fn patch(&self, request: AccountShipping, merchant_id: &str, account_id: &str) -> AccountshippingPatchCall<'a, C, A> { AccountshippingPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _merchant_id: merchant_id.to_string(), _account_id: account_id.to_string(), _dry_run: Default::default(), @@ -3710,10 +3712,10 @@ impl<'a, C, A> AccountshippingMethods<'a, C, A> { /// * `request` - No description provided. /// * `merchantId` - The ID of the managing account. /// * `accountId` - The ID of the account for which to get/update account shipping settings. - pub fn update(&self, request: &AccountShipping, merchant_id: &str, account_id: &str) -> AccountshippingUpdateCall<'a, C, A> { + pub fn update(&self, request: AccountShipping, merchant_id: &str, account_id: &str) -> AccountshippingUpdateCall<'a, C, A> { AccountshippingUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _merchant_id: merchant_id.to_string(), _account_id: account_id.to_string(), _dry_run: Default::default(), @@ -3730,10 +3732,10 @@ impl<'a, C, A> AccountshippingMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn custombatch(&self, request: &AccountshippingCustomBatchRequest) -> AccountshippingCustombatchCall<'a, C, A> { + pub fn custombatch(&self, request: AccountshippingCustomBatchRequest) -> AccountshippingCustombatchCall<'a, C, A> { AccountshippingCustombatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _dry_run: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -3801,7 +3803,7 @@ impl<'a, C, A> AccountshippingMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounttax().custombatch(&req) +/// let result = hub.accounttax().custombatch(req) /// .dry_run(false) /// .doit(); /// # } @@ -3908,12 +3910,17 @@ impl<'a, C, A> AccounttaxCustombatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3922,7 +3929,7 @@ impl<'a, C, A> AccounttaxCustombatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3940,8 +3947,8 @@ impl<'a, C, A> AccounttaxCustombatchCall<'a, C, A> where C: BorrowMut AccounttaxCustombatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AccounttaxCustomBatchRequest) -> AccounttaxCustombatchCall<'a, C, A> { + self._request = new_value; self } /// Flag to run the request in dry-run mode. @@ -4035,7 +4042,7 @@ impl<'a, C, A> AccounttaxCustombatchCall<'a, C, A> where C: BorrowMut AccounttaxPatchCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4184,7 +4196,7 @@ impl<'a, C, A> AccounttaxPatchCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4202,8 +4214,8 @@ impl<'a, C, A> AccounttaxPatchCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AccountTax) -> AccounttaxPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AccountTax) -> AccounttaxPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the managing account. @@ -4440,12 +4452,17 @@ impl<'a, C, A> AccounttaxListCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4454,7 +4471,7 @@ impl<'a, C, A> AccounttaxListCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4575,7 +4592,7 @@ impl<'a, C, A> AccounttaxListCall<'a, C, A> where C: BorrowMut, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounttax().update(&req, "merchantId", "accountId") +/// let result = hub.accounttax().update(req, "merchantId", "accountId") /// .dry_run(true) /// .doit(); /// # } @@ -4710,12 +4727,17 @@ impl<'a, C, A> AccounttaxUpdateCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4724,7 +4746,7 @@ impl<'a, C, A> AccounttaxUpdateCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4742,8 +4764,8 @@ impl<'a, C, A> AccounttaxUpdateCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AccountTax) -> AccounttaxUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AccountTax) -> AccounttaxUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the managing account. @@ -4972,12 +4994,17 @@ impl<'a, C, A> AccounttaxGetCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4986,7 +5013,7 @@ impl<'a, C, A> AccounttaxGetCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5218,12 +5245,17 @@ impl<'a, C, A> DatafeedstatuseGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5232,7 +5264,7 @@ impl<'a, C, A> DatafeedstatuseGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5470,12 +5502,17 @@ impl<'a, C, A> DatafeedstatuseListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5484,7 +5521,7 @@ impl<'a, C, A> DatafeedstatuseListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5603,7 +5640,7 @@ impl<'a, C, A> DatafeedstatuseListCall<'a, C, A> where C: BorrowMut DatafeedstatuseCustombatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5719,7 +5761,7 @@ impl<'a, C, A> DatafeedstatuseCustombatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5737,8 +5779,8 @@ impl<'a, C, A> DatafeedstatuseCustombatchCall<'a, C, A> where C: BorrowMut DatafeedstatuseCustombatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: DatafeedstatusesCustomBatchRequest) -> DatafeedstatuseCustombatchCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -5823,7 +5865,7 @@ impl<'a, C, A> DatafeedstatuseCustombatchCall<'a, C, A> where C: BorrowMut DatafeedCustombatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5939,7 +5986,7 @@ impl<'a, C, A> DatafeedCustombatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5957,8 +6004,8 @@ impl<'a, C, A> DatafeedCustombatchCall<'a, C, A> where C: BorrowMut DatafeedCustombatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: DatafeedsCustomBatchRequest) -> DatafeedCustombatchCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -6160,12 +6207,17 @@ impl<'a, C, A> DatafeedGetCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6174,7 +6226,7 @@ impl<'a, C, A> DatafeedGetCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6289,7 +6341,7 @@ impl<'a, C, A> DatafeedGetCall<'a, C, A> where C: BorrowMut, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.datafeeds().patch(&req, "merchantId", "datafeedId") +/// let result = hub.datafeeds().patch(req, "merchantId", "datafeedId") /// .doit(); /// # } /// ``` @@ -6419,12 +6471,17 @@ impl<'a, C, A> DatafeedPatchCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6433,7 +6490,7 @@ impl<'a, C, A> DatafeedPatchCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6451,8 +6508,8 @@ impl<'a, C, A> DatafeedPatchCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Datafeed) -> DatafeedPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Datafeed) -> DatafeedPatchCall<'a, C, A> { + self._request = new_value; self } /// @@ -6671,12 +6728,17 @@ impl<'a, C, A> DatafeedDeleteCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -6790,7 +6852,7 @@ impl<'a, C, A> DatafeedDeleteCall<'a, C, A> where C: BorrowMut, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.datafeeds().insert(&req, "merchantId") +/// let result = hub.datafeeds().insert(req, "merchantId") /// .doit(); /// # } /// ``` @@ -6918,12 +6980,17 @@ impl<'a, C, A> DatafeedInsertCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6932,7 +6999,7 @@ impl<'a, C, A> DatafeedInsertCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6950,8 +7017,8 @@ impl<'a, C, A> DatafeedInsertCall<'a, C, A> where C: BorrowMut, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Datafeed) -> DatafeedInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Datafeed) -> DatafeedInsertCall<'a, C, A> { + self._request = new_value; self } /// @@ -7170,12 +7237,17 @@ impl<'a, C, A> DatafeedListCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7184,7 +7256,7 @@ impl<'a, C, A> DatafeedListCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7305,7 +7377,7 @@ impl<'a, C, A> DatafeedListCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.datafeeds().update(&req, "merchantId", "datafeedId") +/// let result = hub.datafeeds().update(req, "merchantId", "datafeedId") /// .doit(); /// # } /// ``` @@ -7435,12 +7507,17 @@ impl<'a, C, A> DatafeedUpdateCall<'a, C, A> where C: BorrowMut, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7449,7 +7526,7 @@ impl<'a, C, A> DatafeedUpdateCall<'a, C, A> where C: BorrowMut, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7467,8 +7544,8 @@ impl<'a, C, A> DatafeedUpdateCall<'a, C, A> where C: BorrowMut, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Datafeed) -> DatafeedUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Datafeed) -> DatafeedUpdateCall<'a, C, A> { + self._request = new_value; self } /// @@ -7688,12 +7765,17 @@ impl<'a, C, A> ProductstatuseGetCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7702,7 +7784,7 @@ impl<'a, C, A> ProductstatuseGetCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7942,12 +8024,17 @@ impl<'a, C, A> ProductstatuseListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7956,7 +8043,7 @@ impl<'a, C, A> ProductstatuseListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8077,7 +8164,7 @@ impl<'a, C, A> ProductstatuseListCall<'a, C, A> where C: BorrowMut ProductstatuseCustombatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8193,7 +8285,7 @@ impl<'a, C, A> ProductstatuseCustombatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8211,8 +8303,8 @@ impl<'a, C, A> ProductstatuseCustombatchCall<'a, C, A> where C: BorrowMut ProductstatuseCustombatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ProductstatusesCustomBatchRequest) -> ProductstatuseCustombatchCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -8386,12 +8478,17 @@ impl<'a, C, A> AccountAuthinfoCall<'a, C, A> where C: BorrowMut, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8400,7 +8497,7 @@ impl<'a, C, A> AccountAuthinfoCall<'a, C, A> where C: BorrowMut, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8497,7 +8594,7 @@ impl<'a, C, A> AccountAuthinfoCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().patch(&req, "merchantId", "accountId") +/// let result = hub.accounts().patch(req, "merchantId", "accountId") /// .doit(); /// # } /// ``` @@ -8627,12 +8724,17 @@ impl<'a, C, A> AccountPatchCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8641,7 +8743,7 @@ impl<'a, C, A> AccountPatchCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8659,8 +8761,8 @@ impl<'a, C, A> AccountPatchCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Account) -> AccountPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Account) -> AccountPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the managing account. @@ -8882,12 +8984,17 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8896,7 +9003,7 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9013,7 +9120,7 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().update(&req, "merchantId", "accountId") +/// let result = hub.accounts().update(req, "merchantId", "accountId") /// .doit(); /// # } /// ``` @@ -9143,12 +9250,17 @@ impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9157,7 +9269,7 @@ impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9175,8 +9287,8 @@ impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Account) -> AccountUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Account) -> AccountUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the managing account. @@ -9406,12 +9518,17 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9420,7 +9537,7 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9655,12 +9772,17 @@ impl<'a, C, A> AccountDeleteCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -9776,7 +9898,7 @@ impl<'a, C, A> AccountDeleteCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().custombatch(&req) +/// let result = hub.accounts().custombatch(req) /// .doit(); /// # } /// ``` @@ -9878,12 +10000,17 @@ impl<'a, C, A> AccountCustombatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9892,7 +10019,7 @@ impl<'a, C, A> AccountCustombatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9910,8 +10037,8 @@ impl<'a, C, A> AccountCustombatchCall<'a, C, A> where C: BorrowMut AccountCustombatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AccountsCustomBatchRequest) -> AccountCustombatchCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -9998,7 +10125,7 @@ impl<'a, C, A> AccountCustombatchCall<'a, C, A> where C: BorrowMut AccountInsertCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10140,7 +10272,7 @@ impl<'a, C, A> AccountInsertCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10158,8 +10290,8 @@ impl<'a, C, A> AccountInsertCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Account) -> AccountInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Account) -> AccountInsertCall<'a, C, A> { + self._request = new_value; self } /// The ID of the managing account. @@ -10256,7 +10388,7 @@ impl<'a, C, A> AccountInsertCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.inventory().set(&req, "merchantId", "storeCode", "productId") +/// let result = hub.inventory().set(req, "merchantId", "storeCode", "productId") /// .doit(); /// # } /// ``` @@ -10388,12 +10520,17 @@ impl<'a, C, A> InventorySetCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10402,7 +10539,7 @@ impl<'a, C, A> InventorySetCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10420,8 +10557,8 @@ impl<'a, C, A> InventorySetCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &InventorySetRequest) -> InventorySetCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: InventorySetRequest) -> InventorySetCall<'a, C, A> { + self._request = new_value; self } /// The ID of the managing account. @@ -10538,7 +10675,7 @@ impl<'a, C, A> InventorySetCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.inventory().custombatch(&req) +/// let result = hub.inventory().custombatch(req) /// .doit(); /// # } /// ``` @@ -10640,12 +10777,17 @@ impl<'a, C, A> InventoryCustombatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10654,7 +10796,7 @@ impl<'a, C, A> InventoryCustombatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10672,8 +10814,8 @@ impl<'a, C, A> InventoryCustombatchCall<'a, C, A> where C: BorrowMut InventoryCustombatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: InventoryCustomBatchRequest) -> InventoryCustombatchCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -10875,12 +11017,17 @@ impl<'a, C, A> AccountstatuseGetCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10889,7 +11036,7 @@ impl<'a, C, A> AccountstatuseGetCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11129,12 +11276,17 @@ impl<'a, C, A> AccountstatuseListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11143,7 +11295,7 @@ impl<'a, C, A> AccountstatuseListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11262,7 +11414,7 @@ impl<'a, C, A> AccountstatuseListCall<'a, C, A> where C: BorrowMut AccountstatuseCustombatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11378,7 +11535,7 @@ impl<'a, C, A> AccountstatuseCustombatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11396,8 +11553,8 @@ impl<'a, C, A> AccountstatuseCustombatchCall<'a, C, A> where C: BorrowMut AccountstatuseCustombatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AccountstatusesCustomBatchRequest) -> AccountstatuseCustombatchCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -11607,12 +11764,17 @@ impl<'a, C, A> ProductListCall<'a, C, A> where C: BorrowMut, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11621,7 +11783,7 @@ impl<'a, C, A> ProductListCall<'a, C, A> where C: BorrowMut, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11857,12 +12019,17 @@ impl<'a, C, A> ProductGetCall<'a, C, A> where C: BorrowMut, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11871,7 +12038,7 @@ impl<'a, C, A> ProductGetCall<'a, C, A> where C: BorrowMut, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12107,12 +12274,17 @@ impl<'a, C, A> ProductDeleteCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -12235,7 +12407,7 @@ impl<'a, C, A> ProductDeleteCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.products().custombatch(&req) +/// let result = hub.products().custombatch(req) /// .dry_run(false) /// .doit(); /// # } @@ -12342,12 +12514,17 @@ impl<'a, C, A> ProductCustombatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12356,7 +12533,7 @@ impl<'a, C, A> ProductCustombatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12374,8 +12551,8 @@ impl<'a, C, A> ProductCustombatchCall<'a, C, A> where C: BorrowMut ProductCustombatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ProductsCustomBatchRequest) -> ProductCustombatchCall<'a, C, A> { + self._request = new_value; self } /// Flag to run the request in dry-run mode. @@ -12469,7 +12646,7 @@ impl<'a, C, A> ProductCustombatchCall<'a, C, A> where C: BorrowMut ProductInsertCall<'a, C, A> where C: BorrowMut, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12616,7 +12798,7 @@ impl<'a, C, A> ProductInsertCall<'a, C, A> where C: BorrowMut, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12634,8 +12816,8 @@ impl<'a, C, A> ProductInsertCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Product) -> ProductInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Product) -> ProductInsertCall<'a, C, A> { + self._request = new_value; self } /// The ID of the managing account. @@ -12862,12 +13044,17 @@ impl<'a, C, A> AccountshippingListCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12876,7 +13063,7 @@ impl<'a, C, A> AccountshippingListCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12997,7 +13184,7 @@ impl<'a, C, A> AccountshippingListCall<'a, C, A> where C: BorrowMut AccountshippingPatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13146,7 +13338,7 @@ impl<'a, C, A> AccountshippingPatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13164,8 +13356,8 @@ impl<'a, C, A> AccountshippingPatchCall<'a, C, A> where C: BorrowMut AccountshippingPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AccountShipping) -> AccountshippingPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the managing account. @@ -13279,7 +13471,7 @@ impl<'a, C, A> AccountshippingPatchCall<'a, C, A> where C: BorrowMut AccountshippingUpdateCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13428,7 +13625,7 @@ impl<'a, C, A> AccountshippingUpdateCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13446,8 +13643,8 @@ impl<'a, C, A> AccountshippingUpdateCall<'a, C, A> where C: BorrowMut AccountshippingUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AccountShipping) -> AccountshippingUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the managing account. @@ -13561,7 +13758,7 @@ impl<'a, C, A> AccountshippingUpdateCall<'a, C, A> where C: BorrowMut AccountshippingCustombatchCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13682,7 +13884,7 @@ impl<'a, C, A> AccountshippingCustombatchCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13700,8 +13902,8 @@ impl<'a, C, A> AccountshippingCustombatchCall<'a, C, A> where C: BorrowMut AccountshippingCustombatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AccountshippingCustomBatchRequest) -> AccountshippingCustombatchCall<'a, C, A> { + self._request = new_value; self } /// Flag to run the request in dry-run mode. @@ -13910,12 +14112,17 @@ impl<'a, C, A> AccountshippingGetCall<'a, C, A> where C: BorrowMut(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13924,7 +14131,7 @@ impl<'a, C, A> AccountshippingGetCall<'a, C, A> where C: BorrowMut (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/coordinate1-cli/Cargo.toml b/gen/coordinate1-cli/Cargo.toml index 0c83cc000b..dea09fd47a 100644 --- a/gen/coordinate1-cli/Cargo.toml +++ b/gen/coordinate1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-coordinate1-cli" -version = "0.0.1+20141215" +version = "0.1.0+20141215" authors = ["Sebastian Thiel "] description = "A complete library to interact with coordinate (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/coordinate1-cli" diff --git a/gen/coordinate1-cli/README.md b/gen/coordinate1-cli/README.md index 79383e596c..041092d59d 100644 --- a/gen/coordinate1-cli/README.md +++ b/gen/coordinate1-cli/README.md @@ -1,4 +1,113 @@ -# HELLO COORDINATE:V1 + +The `coordinate1` command-line interface *(CLI)* allows to use most features of the *Google coordinate* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *coordinate* API at revision *20141215*. The CLI is at version *0.1.0*. + +```bash + coordinate1 [options] custom-field-def list [-p ...] [-o ] + coordinate1 [options] jobs get [-p ...] [-o ] + coordinate1 [options] jobs insert
-r <kv>... [-p <v>...] [-o <out>] + coordinate1 [options] jobs list <team-id> [-p <v>...] [-o <out>] + coordinate1 [options] jobs patch <team-id> <job-id> -r <kv>... [-p <v>...] [-o <out>] + coordinate1 [options] jobs update <team-id> <job-id> -r <kv>... [-p <v>...] [-o <out>] + coordinate1 [options] location list <team-id> <worker-email> <start-timestamp-ms> [-p <v>...] [-o <out>] + coordinate1 [options] schedule get <team-id> <job-id> [-p <v>...] [-o <out>] + coordinate1 [options] schedule patch <team-id> <job-id> -r <kv>... [-p <v>...] [-o <out>] + coordinate1 [options] schedule update <team-id> <job-id> -r <kv>... [-p <v>...] [-o <out>] + coordinate1 [options] team list [-p <v>...] [-o <out>] + coordinate1 [options] worker list <team-id> [-p <v>...] [-o <out>] + coordinate1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_coordinate1_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `coordinate1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/coordinate1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/coordinate1-secret.json`, assuming that the required *coordinate* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `coordinate1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/coordinate1-cli/mkdocs.yml b/gen/coordinate1-cli/mkdocs.yml index 56fb9f231b..c2c6aadba6 100644 --- a/gen/coordinate1-cli/mkdocs.yml +++ b/gen/coordinate1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: coordinate v0.0.1+20141215 +site_name: coordinate v0.1.0+20141215 site_url: http://byron.github.io/google-apis-rs/google-coordinate1-cli site_description: Write integrating applications with bcore diff --git a/gen/coordinate1-cli/src/cmn.rs b/gen/coordinate1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/coordinate1-cli/src/cmn.rs +++ b/gen/coordinate1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/coordinate1-cli/src/main.rs b/gen/coordinate1-cli/src/main.rs index 325a52a532..d6f14e881c 100644 --- a/gen/coordinate1-cli/src/main.rs +++ b/gen/coordinate1-cli/src/main.rs @@ -19,37 +19,38 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - coordinate1 [options] custom-field-def list <team-id> [-p <v>]... [-o <out>] - coordinate1 [options] jobs get <team-id> <job-id> [-p <v>]... [-o <out>] - coordinate1 [options] jobs insert <team-id> <address> <lat> <lng> <title> -r <kv>... [-p <v>]... [-o <out>] - coordinate1 [options] jobs list <team-id> [-p <v>]... [-o <out>] - coordinate1 [options] jobs patch <team-id> <job-id> -r <kv>... [-p <v>]... [-o <out>] - coordinate1 [options] jobs update <team-id> <job-id> -r <kv>... [-p <v>]... [-o <out>] - coordinate1 [options] location list <team-id> <worker-email> <start-timestamp-ms> [-p <v>]... [-o <out>] - coordinate1 [options] schedule get <team-id> <job-id> [-p <v>]... [-o <out>] - coordinate1 [options] schedule patch <team-id> <job-id> -r <kv>... [-p <v>]... [-o <out>] - coordinate1 [options] schedule update <team-id> <job-id> -r <kv>... [-p <v>]... [-o <out>] - coordinate1 [options] team list [-p <v>]... [-o <out>] - coordinate1 [options] worker list <team-id> [-p <v>]... [-o <out>] + coordinate1 [options] custom-field-def list <team-id> [-p <v>...] [-o <out>] + coordinate1 [options] jobs get <team-id> <job-id> [-p <v>...] [-o <out>] + coordinate1 [options] jobs insert <team-id> <address> <lat> <lng> <title> -r <kv>... [-p <v>...] [-o <out>] + coordinate1 [options] jobs list <team-id> [-p <v>...] [-o <out>] + coordinate1 [options] jobs patch <team-id> <job-id> -r <kv>... [-p <v>...] [-o <out>] + coordinate1 [options] jobs update <team-id> <job-id> -r <kv>... [-p <v>...] [-o <out>] + coordinate1 [options] location list <team-id> <worker-email> <start-timestamp-ms> [-p <v>...] [-o <out>] + coordinate1 [options] schedule get <team-id> <job-id> [-p <v>...] [-o <out>] + coordinate1 [options] schedule patch <team-id> <job-id> -r <kv>... [-p <v>...] [-o <out>] + coordinate1 [options] schedule update <team-id> <job-id> -r <kv>... [-p <v>...] [-o <out>] + coordinate1 [options] team list [-p <v>...] [-o <out>] + coordinate1 [options] worker list <team-id> [-p <v>...] [-o <out>] coordinate1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_coordinate1_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -98,6 +99,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -141,6 +145,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -157,53 +164,23 @@ impl Engine { fn _jobs_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Job::default(); - let lat: f64 = arg_from_str(&self.opt.arg_lat, err, "<lat>", "number"); - let lng: f64 = arg_from_str(&self.opt.arg_lng, err, "<lng>", "number"); - let mut call = self.hub.jobs().insert(&request, &self.opt.arg_team_id, &self.opt.arg_address, lat, lng, &self.opt.arg_title); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "note" => { - call = call.note(value.unwrap_or("")); - }, - "customer-phone-number" => { - call = call.customer_phone_number(value.unwrap_or("")); - }, - "customer-name" => { - call = call.customer_name(value.unwrap_or("")); - }, - "custom-field" => { - call = call.add_custom_field(value.unwrap_or("")); - }, - "assignee" => { - call = call.assignee(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Job::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_state_custom_fields_init(request: &mut api::Job) { request_state_init(request); if request.state.as_mut().unwrap().custom_fields.is_none() { @@ -224,7 +201,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -286,15 +263,57 @@ impl Engine { request.state.as_mut().unwrap().custom_fields.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let lat: f64 = arg_from_str(&self.opt.arg_lat, err, "<lat>", "number"); + let lng: f64 = arg_from_str(&self.opt.arg_lng, err, "<lng>", "number"); + let mut call = self.hub.jobs().insert(request, &self.opt.arg_team_id, &self.opt.arg_address, lat, lng, &self.opt.arg_title); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "note" => { + call = call.note(value.unwrap_or("")); + }, + "customer-phone-number" => { + call = call.customer_phone_number(value.unwrap_or("")); + }, + "customer-name" => { + call = call.customer_name(value.unwrap_or("")); + }, + "custom-field" => { + call = call.add_custom_field(value.unwrap_or("")); + }, + "assignee" => { + call = call.assignee(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -347,6 +366,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -363,66 +385,23 @@ impl Engine { fn _jobs_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Job::default(); - let mut call = self.hub.jobs().patch(&request, &self.opt.arg_team_id, &self.opt.arg_job_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "title" => { - call = call.title(value.unwrap_or("")); - }, - "progress" => { - call = call.progress(value.unwrap_or("")); - }, - "note" => { - call = call.note(value.unwrap_or("")); - }, - "lng" => { - call = call.lng(arg_from_str(value.unwrap_or("0.0"), err, "lng", "number")); - }, - "lat" => { - call = call.lat(arg_from_str(value.unwrap_or("0.0"), err, "lat", "number")); - }, - "customer-phone-number" => { - call = call.customer_phone_number(value.unwrap_or("")); - }, - "customer-name" => { - call = call.customer_name(value.unwrap_or("")); - }, - "custom-field" => { - call = call.add_custom_field(value.unwrap_or("")); - }, - "assignee" => { - call = call.assignee(value.unwrap_or("")); - }, - "address" => { - call = call.address(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Job::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_state_custom_fields_init(request: &mut api::Job) { request_state_init(request); if request.state.as_mut().unwrap().custom_fields.is_none() { @@ -443,7 +422,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -505,15 +484,70 @@ impl Engine { request.state.as_mut().unwrap().custom_fields.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.jobs().patch(request, &self.opt.arg_team_id, &self.opt.arg_job_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "title" => { + call = call.title(value.unwrap_or("")); + }, + "progress" => { + call = call.progress(value.unwrap_or("")); + }, + "note" => { + call = call.note(value.unwrap_or("")); + }, + "lng" => { + call = call.lng(arg_from_str(value.unwrap_or("0.0"), err, "lng", "number")); + }, + "lat" => { + call = call.lat(arg_from_str(value.unwrap_or("0.0"), err, "lat", "number")); + }, + "customer-phone-number" => { + call = call.customer_phone_number(value.unwrap_or("")); + }, + "customer-name" => { + call = call.customer_name(value.unwrap_or("")); + }, + "custom-field" => { + call = call.add_custom_field(value.unwrap_or("")); + }, + "assignee" => { + call = call.assignee(value.unwrap_or("")); + }, + "address" => { + call = call.address(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -530,66 +564,23 @@ impl Engine { fn _jobs_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Job::default(); - let mut call = self.hub.jobs().update(&request, &self.opt.arg_team_id, &self.opt.arg_job_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "title" => { - call = call.title(value.unwrap_or("")); - }, - "progress" => { - call = call.progress(value.unwrap_or("")); - }, - "note" => { - call = call.note(value.unwrap_or("")); - }, - "lng" => { - call = call.lng(arg_from_str(value.unwrap_or("0.0"), err, "lng", "number")); - }, - "lat" => { - call = call.lat(arg_from_str(value.unwrap_or("0.0"), err, "lat", "number")); - }, - "customer-phone-number" => { - call = call.customer_phone_number(value.unwrap_or("")); - }, - "customer-name" => { - call = call.customer_name(value.unwrap_or("")); - }, - "custom-field" => { - call = call.add_custom_field(value.unwrap_or("")); - }, - "assignee" => { - call = call.assignee(value.unwrap_or("")); - }, - "address" => { - call = call.address(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Job::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_state_custom_fields_init(request: &mut api::Job) { request_state_init(request); if request.state.as_mut().unwrap().custom_fields.is_none() { @@ -610,7 +601,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -672,15 +663,70 @@ impl Engine { request.state.as_mut().unwrap().custom_fields.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.jobs().update(request, &self.opt.arg_team_id, &self.opt.arg_job_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "title" => { + call = call.title(value.unwrap_or("")); + }, + "progress" => { + call = call.progress(value.unwrap_or("")); + }, + "note" => { + call = call.note(value.unwrap_or("")); + }, + "lng" => { + call = call.lng(arg_from_str(value.unwrap_or("0.0"), err, "lng", "number")); + }, + "lat" => { + call = call.lat(arg_from_str(value.unwrap_or("0.0"), err, "lat", "number")); + }, + "customer-phone-number" => { + call = call.customer_phone_number(value.unwrap_or("")); + }, + "customer-name" => { + call = call.customer_name(value.unwrap_or("")); + }, + "custom-field" => { + call = call.add_custom_field(value.unwrap_or("")); + }, + "assignee" => { + call = call.assignee(value.unwrap_or("")); + }, + "address" => { + call = call.address(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -730,6 +776,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -773,6 +822,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -789,8 +841,45 @@ impl Engine { fn _schedule_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Schedule::default(); - let mut call = self.hub.schedule().patch(&request, &self.opt.arg_team_id, &self.opt.arg_job_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "duration" => { + request.duration = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "all-day" => { + request.all_day = Some(arg_from_str(value.unwrap_or("false"), err, "all-day", "boolean")); + }, + "start-time" => { + request.start_time = Some(value.unwrap_or("").to_string()); + }, + "end-time" => { + request.end_time = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.schedule().patch(request, &self.opt.arg_team_id, &self.opt.arg_job_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -824,39 +913,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "duration" => { - request.duration = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "all-day" => { - request.all_day = Some(arg_from_str(value.unwrap_or("false"), err, "all-day", "boolean")); - }, - "start-time" => { - request.start_time = Some(value.unwrap_or("").to_string()); - }, - "end-time" => { - request.end_time = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -873,8 +937,45 @@ impl Engine { fn _schedule_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Schedule::default(); - let mut call = self.hub.schedule().update(&request, &self.opt.arg_team_id, &self.opt.arg_job_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "duration" => { + request.duration = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "all-day" => { + request.all_day = Some(arg_from_str(value.unwrap_or("false"), err, "all-day", "boolean")); + }, + "start-time" => { + request.start_time = Some(value.unwrap_or("").to_string()); + }, + "end-time" => { + request.end_time = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.schedule().update(request, &self.opt.arg_team_id, &self.opt.arg_job_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -908,39 +1009,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "duration" => { - request.duration = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "all-day" => { - request.all_day = Some(arg_from_str(value.unwrap_or("false"), err, "all-day", "boolean")); - }, - "start-time" => { - request.start_time = Some(value.unwrap_or("").to_string()); - }, - "end-time" => { - request.end_time = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -993,6 +1069,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1036,6 +1115,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1176,6 +1258,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -1183,8 +1266,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/coordinate1/Cargo.toml b/gen/coordinate1/Cargo.toml index c73092cc31..73062e9b0f 100644 --- a/gen/coordinate1/Cargo.toml +++ b/gen/coordinate1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-coordinate1" -version = "0.1.5+20141215" +version = "0.1.6+20141215" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with coordinate (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/coordinate1" diff --git a/gen/coordinate1/README.md b/gen/coordinate1/README.md index 89ebb17c60..39e6a599cf 100644 --- a/gen/coordinate1/README.md +++ b/gen/coordinate1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-coordinate1` library allows access to all features of the *Google coordinate* service. -This documentation was generated from *coordinate* crate version *0.1.5+20141215*, where *20141215* is the exact revision of the *coordinate:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *coordinate* crate version *0.1.6+20141215*, where *20141215* is the exact revision of the *coordinate:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *coordinate* *v1* API can be found at the [official documentation site](https://developers.google.com/coordinate/). @@ -112,7 +112,7 @@ let mut req = Job::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.jobs().update(&req, "teamId", "jobId") +let result = hub.jobs().update(req, "teamId", "jobId") .title("Stet") .progress("sed") .note("et") @@ -129,14 +129,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/coordinate1/src/cmn.rs b/gen/coordinate1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/coordinate1/src/cmn.rs +++ b/gen/coordinate1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/coordinate1/src/lib.rs b/gen/coordinate1/src/lib.rs index 6246d22a76..659b062142 100644 --- a/gen/coordinate1/src/lib.rs +++ b/gen/coordinate1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *coordinate* crate version *0.1.5+20141215*, where *20141215* is the exact revision of the *coordinate:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *coordinate* crate version *0.1.6+20141215*, where *20141215* is the exact revision of the *coordinate:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *coordinate* *v1* API can be found at the //! [official documentation site](https://developers.google.com/coordinate/). @@ -113,7 +113,7 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.jobs().update(&req, "teamId", "jobId") +//! let result = hub.jobs().update(req, "teamId", "jobId") //! .title("nonumy") //! .progress("dolores") //! .note("gubergren") @@ -130,14 +130,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -225,7 +226,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -302,7 +303,7 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.jobs().update(&req, "teamId", "jobId") +/// let result = hub.jobs().update(req, "teamId", "jobId") /// .title("ipsum") /// .progress("Lorem") /// .note("et") @@ -319,14 +320,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -347,7 +349,7 @@ impl<'a, C, A> Coordinate<C, A> Coordinate { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -371,7 +373,7 @@ impl<'a, C, A> Coordinate<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -849,10 +851,10 @@ impl<'a, C, A> JobMethods<'a, C, A> { /// * `request` - No description provided. /// * `teamId` - Team ID /// * `jobId` - Job number - pub fn update(&self, request: &Job, team_id: &str, job_id: &str) -> JobUpdateCall<'a, C, A> { + pub fn update(&self, request: Job, team_id: &str, job_id: &str) -> JobUpdateCall<'a, C, A> { JobUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _team_id: team_id.to_string(), _job_id: job_id.to_string(), _title: Default::default(), @@ -880,10 +882,10 @@ impl<'a, C, A> JobMethods<'a, C, A> { /// * `request` - No description provided. /// * `teamId` - Team ID /// * `jobId` - Job number - pub fn patch(&self, request: &Job, team_id: &str, job_id: &str) -> JobPatchCall<'a, C, A> { + pub fn patch(&self, request: Job, team_id: &str, job_id: &str) -> JobPatchCall<'a, C, A> { JobPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _team_id: team_id.to_string(), _job_id: job_id.to_string(), _title: Default::default(), @@ -934,10 +936,10 @@ impl<'a, C, A> JobMethods<'a, C, A> { /// * `lat` - The latitude coordinate of this job's location. /// * `lng` - The longitude coordinate of this job's location. /// * `title` - Job title - pub fn insert(&self, request: &Job, team_id: &str, address: &str, lat: f64, lng: f64, title: &str) -> JobInsertCall<'a, C, A> { + pub fn insert(&self, request: Job, team_id: &str, address: &str, lat: f64, lng: f64, title: &str) -> JobInsertCall<'a, C, A> { JobInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _team_id: team_id.to_string(), _address: address.to_string(), _lat: lat, @@ -1004,10 +1006,10 @@ impl<'a, C, A> ScheduleMethods<'a, C, A> { /// * `request` - No description provided. /// * `teamId` - Team ID /// * `jobId` - Job number - pub fn update(&self, request: &Schedule, team_id: &str, job_id: &str) -> ScheduleUpdateCall<'a, C, A> { + pub fn update(&self, request: Schedule, team_id: &str, job_id: &str) -> ScheduleUpdateCall<'a, C, A> { ScheduleUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _team_id: team_id.to_string(), _job_id: job_id.to_string(), _start_time: Default::default(), @@ -1029,10 +1031,10 @@ impl<'a, C, A> ScheduleMethods<'a, C, A> { /// * `request` - No description provided. /// * `teamId` - Team ID /// * `jobId` - Job number - pub fn patch(&self, request: &Schedule, team_id: &str, job_id: &str) -> SchedulePatchCall<'a, C, A> { + pub fn patch(&self, request: Schedule, team_id: &str, job_id: &str) -> SchedulePatchCall<'a, C, A> { SchedulePatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _team_id: team_id.to_string(), _job_id: job_id.to_string(), _start_time: Default::default(), @@ -1456,12 +1458,17 @@ impl<'a, C, A> JobGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1470,7 +1477,7 @@ impl<'a, C, A> JobGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1587,7 +1594,7 @@ impl<'a, C, A> JobGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.jobs().update(&req, "teamId", "jobId") +/// let result = hub.jobs().update(req, "teamId", "jobId") /// .title("no") /// .progress("labore") /// .note("eirmod") @@ -1771,12 +1778,17 @@ impl<'a, C, A> JobUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1785,7 +1797,7 @@ impl<'a, C, A> JobUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1803,8 +1815,8 @@ impl<'a, C, A> JobUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Job) -> JobUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Job) -> JobUpdateCall<'a, C, A> { + self._request = new_value; self } /// Team ID @@ -1982,7 +1994,7 @@ impl<'a, C, A> JobUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.jobs().patch(&req, "teamId", "jobId") +/// let result = hub.jobs().patch(req, "teamId", "jobId") /// .title("eirmod") /// .progress("sanctus") /// .note("et") @@ -2166,12 +2178,17 @@ impl<'a, C, A> JobPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2180,7 +2197,7 @@ impl<'a, C, A> JobPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2198,8 +2215,8 @@ impl<'a, C, A> JobPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Job) -> JobPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Job) -> JobPatchCall<'a, C, A> { + self._request = new_value; self } /// Team ID @@ -2505,12 +2522,17 @@ impl<'a, C, A> JobListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2519,7 +2541,7 @@ impl<'a, C, A> JobListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2647,7 +2669,7 @@ impl<'a, C, A> JobListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.jobs().insert(&req, "teamId", "address", 0.455185502569, 0.898789428358, "title") +/// let result = hub.jobs().insert(req, "teamId", "address", 0.455185502569, 0.898789428358, "title") /// .note("sit") /// .customer_phone_number("vero") /// .customer_name("diam") @@ -2812,12 +2834,17 @@ impl<'a, C, A> JobInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2826,7 +2853,7 @@ impl<'a, C, A> JobInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2844,8 +2871,8 @@ impl<'a, C, A> JobInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Job) -> JobInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Job) -> JobInsertCall<'a, C, A> { + self._request = new_value; self } /// Team ID @@ -3018,7 +3045,7 @@ impl<'a, C, A> JobInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.schedule().update(&req, "teamId", "jobId") +/// let result = hub.schedule().update(req, "teamId", "jobId") /// .start_time("sadipscing") /// .end_time("invidunt") /// .duration("consetetur") @@ -3168,12 +3195,17 @@ impl<'a, C, A> ScheduleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3182,7 +3214,7 @@ impl<'a, C, A> ScheduleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3200,8 +3232,8 @@ impl<'a, C, A> ScheduleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Schedule) -> ScheduleUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Schedule) -> ScheduleUpdateCall<'a, C, A> { + self._request = new_value; self } /// Team ID @@ -3336,7 +3368,7 @@ impl<'a, C, A> ScheduleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.schedule().patch(&req, "teamId", "jobId") +/// let result = hub.schedule().patch(req, "teamId", "jobId") /// .start_time("Lorem") /// .end_time("et") /// .duration("clita") @@ -3486,12 +3518,17 @@ impl<'a, C, A> SchedulePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3500,7 +3537,7 @@ impl<'a, C, A> SchedulePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3518,8 +3555,8 @@ impl<'a, C, A> SchedulePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Schedule) -> SchedulePatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Schedule) -> SchedulePatchCall<'a, C, A> { + self._request = new_value; self } /// Team ID @@ -3769,12 +3806,17 @@ impl<'a, C, A> ScheduleGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3783,7 +3825,7 @@ impl<'a, C, A> ScheduleGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4013,12 +4055,17 @@ impl<'a, C, A> WorkerListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4027,7 +4074,7 @@ impl<'a, C, A> WorkerListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4261,12 +4308,17 @@ impl<'a, C, A> LocationListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4275,7 +4327,7 @@ impl<'a, C, A> LocationListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4518,12 +4570,17 @@ impl<'a, C, A> TeamListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4532,7 +4589,7 @@ impl<'a, C, A> TeamListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4763,12 +4820,17 @@ impl<'a, C, A> CustomFieldDefListCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4777,7 +4839,7 @@ impl<'a, C, A> CustomFieldDefListCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/customsearch1-cli/Cargo.toml b/gen/customsearch1-cli/Cargo.toml index d5c20f93c2..e162d068c6 100644 --- a/gen/customsearch1-cli/Cargo.toml +++ b/gen/customsearch1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-customsearch1-cli" -version = "0.0.1+20131205" +version = "0.1.0+20131205" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with customsearch (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/customsearch1-cli" diff --git a/gen/customsearch1-cli/README.md b/gen/customsearch1-cli/README.md index 260a95e544..3a05c8cd45 100644 --- a/gen/customsearch1-cli/README.md +++ b/gen/customsearch1-cli/README.md @@ -1,4 +1,98 @@ -# HELLO CUSTOMSEARCH:V1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `customsearch1` command-line interface *(CLI)* allows to use most features of the *Google customsearch* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *customsearch* API at revision *20131205*. The CLI is at version *0.1.0*. + +```bash + customsearch1 [options] cse list <q> [-p <v>...] [-o <out>] + customsearch1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_customsearch1_cli/index.html + +Configuration: + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `customsearch1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/customsearch1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/customsearch1-secret.json`, assuming that the required *customsearch* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `customsearch1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/customsearch1-cli/mkdocs.yml b/gen/customsearch1-cli/mkdocs.yml index 4f2a14ddf7..4dd1951f1f 100644 --- a/gen/customsearch1-cli/mkdocs.yml +++ b/gen/customsearch1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: customsearch v0.0.1+20131205 +site_name: customsearch v0.1.0+20131205 site_url: http://byron.github.io/google-apis-rs/google-customsearch1-cli site_description: Write integrating applications with bcore diff --git a/gen/customsearch1-cli/src/cmn.rs b/gen/customsearch1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/customsearch1-cli/src/cmn.rs +++ b/gen/customsearch1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/customsearch1-cli/src/main.rs b/gen/customsearch1-cli/src/main.rs index 1bf36ce1fb..a7b76d0f5a 100644 --- a/gen/customsearch1-cli/src/main.rs +++ b/gen/customsearch1-cli/src/main.rs @@ -19,22 +19,23 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - customsearch1 [options] cse list <q> [-p <v>]... [-o <out>] + customsearch1 [options] cse list <q> [-p <v>...] [-o <out>] customsearch1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_customsearch1_cli/index.html Configuration: --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -269,6 +270,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -276,8 +278,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/customsearch1/Cargo.toml b/gen/customsearch1/Cargo.toml index 9f30355854..94c8a26f97 100644 --- a/gen/customsearch1/Cargo.toml +++ b/gen/customsearch1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-customsearch1" -version = "0.1.5+20131205" +version = "0.1.6+20131205" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with customsearch (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/customsearch1" diff --git a/gen/customsearch1/README.md b/gen/customsearch1/README.md index 054c44dbea..b89971b1e6 100644 --- a/gen/customsearch1/README.md +++ b/gen/customsearch1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-customsearch1` library allows access to all features of the *Google customsearch* service. -This documentation was generated from *customsearch* crate version *0.1.5+20131205*, where *20131205* is the exact revision of the *customsearch:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *customsearch* crate version *0.1.6+20131205*, where *20131205* is the exact revision of the *customsearch:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *customsearch* *v1* API can be found at the [official documentation site](https://developers.google.com/custom-search/v1/using_rest). @@ -130,14 +130,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/customsearch1/src/cmn.rs b/gen/customsearch1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/customsearch1/src/cmn.rs +++ b/gen/customsearch1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/customsearch1/src/lib.rs b/gen/customsearch1/src/lib.rs index 0cdbc7448d..e2bc4a8c6d 100644 --- a/gen/customsearch1/src/lib.rs +++ b/gen/customsearch1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *customsearch* crate version *0.1.5+20131205*, where *20131205* is the exact revision of the *customsearch:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *customsearch* crate version *0.1.6+20131205*, where *20131205* is the exact revision of the *customsearch:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *customsearch* *v1* API can be found at the //! [official documentation site](https://developers.google.com/custom-search/v1/using_rest). @@ -131,14 +131,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -226,7 +227,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -309,14 +310,15 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -337,7 +339,7 @@ impl<'a, C, A> Customsearch<C, A> Customsearch { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -346,7 +348,7 @@ impl<'a, C, A> Customsearch<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -1125,12 +1127,17 @@ impl<'a, C, A> CseListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1139,7 +1146,7 @@ impl<'a, C, A> CseListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/datastore1_beta2-cli/Cargo.toml b/gen/datastore1_beta2-cli/Cargo.toml index 21f69fab5c..d14f641f54 100644 --- a/gen/datastore1_beta2-cli/Cargo.toml +++ b/gen/datastore1_beta2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-datastore1_beta2-cli" -version = "0.0.1+20150402" +version = "0.1.0+20150402" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with datastore (protocol v1beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/datastore1_beta2-cli" diff --git a/gen/datastore1_beta2-cli/README.md b/gen/datastore1_beta2-cli/README.md index 4b58337290..b0df2b114a 100644 --- a/gen/datastore1_beta2-cli/README.md +++ b/gen/datastore1_beta2-cli/README.md @@ -1,4 +1,107 @@ -# HELLO DATASTORE:V1BETA2 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `datastore1-beta2` command-line interface *(CLI)* allows to use most features of the *Google datastore* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *datastore* API at revision *20150402*. The CLI is at version *0.1.0*. + +```bash + datastore1-beta2 [options] datasets allocate-ids <dataset-id> -r <kv>... [-p <v>...] [-o <out>] + datastore1-beta2 [options] datasets begin-transaction <dataset-id> -r <kv>... [-p <v>...] [-o <out>] + datastore1-beta2 [options] datasets commit <dataset-id> -r <kv>... [-p <v>...] [-o <out>] + datastore1-beta2 [options] datasets lookup <dataset-id> -r <kv>... [-p <v>...] [-o <out>] + datastore1-beta2 [options] datasets rollback <dataset-id> -r <kv>... [-p <v>...] [-o <out>] + datastore1-beta2 [options] datasets run-query <dataset-id> -r <kv>... [-p <v>...] [-o <out>] + datastore1-beta2 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_datastore1_beta2_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `datastore1-beta2-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/datastore1-beta2-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/datastore1-beta2-secret.json`, assuming that the required *datastore* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `datastore1-beta2 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/datastore1_beta2-cli/mkdocs.yml b/gen/datastore1_beta2-cli/mkdocs.yml index f41a6c43dd..9a14b571fb 100644 --- a/gen/datastore1_beta2-cli/mkdocs.yml +++ b/gen/datastore1_beta2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: datastore v0.0.1+20150402 +site_name: datastore v0.1.0+20150402 site_url: http://byron.github.io/google-apis-rs/google-datastore1_beta2-cli site_description: Write integrating applications with bcore diff --git a/gen/datastore1_beta2-cli/src/cmn.rs b/gen/datastore1_beta2-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/datastore1_beta2-cli/src/cmn.rs +++ b/gen/datastore1_beta2-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/datastore1_beta2-cli/src/main.rs b/gen/datastore1_beta2-cli/src/main.rs index 68e59747b5..aca75dd409 100644 --- a/gen/datastore1_beta2-cli/src/main.rs +++ b/gen/datastore1_beta2-cli/src/main.rs @@ -19,31 +19,32 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - datastore1-beta2 [options] datasets allocate-ids <dataset-id> -r <kv>... [-p <v>]... [-o <out>] - datastore1-beta2 [options] datasets begin-transaction <dataset-id> -r <kv>... [-p <v>]... [-o <out>] - datastore1-beta2 [options] datasets commit <dataset-id> -r <kv>... [-p <v>]... [-o <out>] - datastore1-beta2 [options] datasets lookup <dataset-id> -r <kv>... [-p <v>]... [-o <out>] - datastore1-beta2 [options] datasets rollback <dataset-id> -r <kv>... [-p <v>]... [-o <out>] - datastore1-beta2 [options] datasets run-query <dataset-id> -r <kv>... [-p <v>]... [-o <out>] + datastore1-beta2 [options] datasets allocate-ids <dataset-id> -r <kv>... [-p <v>...] [-o <out>] + datastore1-beta2 [options] datasets begin-transaction <dataset-id> -r <kv>... [-p <v>...] [-o <out>] + datastore1-beta2 [options] datasets commit <dataset-id> -r <kv>... [-p <v>...] [-o <out>] + datastore1-beta2 [options] datasets lookup <dataset-id> -r <kv>... [-p <v>...] [-o <out>] + datastore1-beta2 [options] datasets rollback <dataset-id> -r <kv>... [-p <v>...] [-o <out>] + datastore1-beta2 [options] datasets run-query <dataset-id> -r <kv>... [-p <v>...] [-o <out>] datastore1-beta2 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_datastore1_beta2_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -65,8 +66,30 @@ struct Engine { impl Engine { fn _datasets_allocate_ids(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::AllocateIdsRequest::default(); - let mut call = self.hub.datasets().allocate_ids(&request, &self.opt.arg_dataset_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.datasets().allocate_ids(request, &self.opt.arg_dataset_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -88,24 +111,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -122,8 +135,33 @@ impl Engine { fn _datasets_begin_transaction(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::BeginTransactionRequest::default(); - let mut call = self.hub.datasets().begin_transaction(&request, &self.opt.arg_dataset_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "isolation-level" => { + request.isolation_level = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.datasets().begin_transaction(request, &self.opt.arg_dataset_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -145,27 +183,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "isolation-level" => { - request.isolation_level = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -182,8 +207,49 @@ impl Engine { fn _datasets_commit(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::CommitRequest::default(); - let mut call = self.hub.datasets().commit(&request, &self.opt.arg_dataset_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + fn request_mutation_init(request: &mut api::CommitRequest) { + if request.mutation.is_none() { + request.mutation = Some(Default::default()); + } + } + + match &temp_cursor.to_string()[..] { + "ignore-read-only" => { + request.ignore_read_only = Some(arg_from_str(value.unwrap_or("false"), err, "ignore-read-only", "boolean")); + }, + "transaction" => { + request.transaction = Some(value.unwrap_or("").to_string()); + }, + "mode" => { + request.mode = Some(value.unwrap_or("").to_string()); + }, + "mutation.force" => { + request_mutation_init(&mut request); + request.mutation.as_mut().unwrap().force = Some(arg_from_str(value.unwrap_or("false"), err, "mutation.force", "boolean")); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.datasets().commit(request, &self.opt.arg_dataset_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -205,43 +271,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_mutation_init(request: &mut api::CommitRequest) { - if request.mutation.is_none() { - request.mutation = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "ignore-read-only" => { - request.ignore_read_only = Some(arg_from_str(value.unwrap_or("false"), err, "ignore-read-only", "boolean")); - }, - "transaction" => { - request.transaction = Some(value.unwrap_or("").to_string()); - }, - "mode" => { - request.mode = Some(value.unwrap_or("").to_string()); - }, - "mutation.force" => { - request_mutation_init(&mut request); - request.mutation.as_mut().unwrap().force = Some(arg_from_str(value.unwrap_or("false"), err, "mutation.force", "boolean")); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -258,8 +295,44 @@ impl Engine { fn _datasets_lookup(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::LookupRequest::default(); - let mut call = self.hub.datasets().lookup(&request, &self.opt.arg_dataset_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + fn request_read_options_init(request: &mut api::LookupRequest) { + if request.read_options.is_none() { + request.read_options = Some(Default::default()); + } + } + + match &temp_cursor.to_string()[..] { + "read-options.transaction" => { + request_read_options_init(&mut request); + request.read_options.as_mut().unwrap().transaction = Some(value.unwrap_or("").to_string()); + }, + "read-options.read-consistency" => { + request_read_options_init(&mut request); + request.read_options.as_mut().unwrap().read_consistency = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.datasets().lookup(request, &self.opt.arg_dataset_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -281,38 +354,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_read_options_init(request: &mut api::LookupRequest) { - if request.read_options.is_none() { - request.read_options = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "read-options.transaction" => { - request_read_options_init(&mut request); - request.read_options.as_mut().unwrap().transaction = Some(value.unwrap_or("").to_string()); - }, - "read-options.read-consistency" => { - request_read_options_init(&mut request); - request.read_options.as_mut().unwrap().read_consistency = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -329,8 +378,33 @@ impl Engine { fn _datasets_rollback(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::RollbackRequest::default(); - let mut call = self.hub.datasets().rollback(&request, &self.opt.arg_dataset_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "transaction" => { + request.transaction = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.datasets().rollback(request, &self.opt.arg_dataset_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -352,27 +426,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "transaction" => { - request.transaction = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -389,36 +450,23 @@ impl Engine { fn _datasets_run_query(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::RunQueryRequest::default(); - let mut call = self.hub.datasets().run_query(&request, &self.opt.arg_dataset_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::RunQueryRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_gql_query_init(request: &mut api::RunQueryRequest) { if request.gql_query.is_none() { request.gql_query = Some(Default::default()); @@ -513,7 +561,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "query.filter.composite-filter.operator" => { request_query_filter_composite_filter_init(&mut request); request.query.as_mut().unwrap().filter.as_mut().unwrap().composite_filter.as_mut().unwrap().operator = Some(value.unwrap_or("").to_string()); @@ -619,15 +667,40 @@ impl Engine { request.read_options.as_mut().unwrap().read_consistency = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.datasets().run_query(request, &self.opt.arg_dataset_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -731,6 +804,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -738,8 +812,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/datastore1_beta2/Cargo.toml b/gen/datastore1_beta2/Cargo.toml index 4d504658d9..9664329771 100644 --- a/gen/datastore1_beta2/Cargo.toml +++ b/gen/datastore1_beta2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-datastore1_beta2" -version = "0.1.5+20150402" +version = "0.1.6+20150402" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with datastore (protocol v1beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/datastore1_beta2" diff --git a/gen/datastore1_beta2/README.md b/gen/datastore1_beta2/README.md index f74806748d..ad39db9017 100644 --- a/gen/datastore1_beta2/README.md +++ b/gen/datastore1_beta2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-datastore1_beta2` library allows access to all features of the *Google datastore* service. -This documentation was generated from *datastore* crate version *0.1.5+20150402*, where *20150402* is the exact revision of the *datastore:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *datastore* crate version *0.1.6+20150402*, where *20150402* is the exact revision of the *datastore:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *datastore* *v1_beta2* API can be found at the [official documentation site](https://developers.google.com/datastore/). @@ -98,21 +98,22 @@ let mut req = LookupRequest::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.datasets().lookup(&req, "datasetId") +let result = hub.datasets().lookup(req, "datasetId") .doit(); match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/datastore1_beta2/src/cmn.rs b/gen/datastore1_beta2/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/datastore1_beta2/src/cmn.rs +++ b/gen/datastore1_beta2/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/datastore1_beta2/src/lib.rs b/gen/datastore1_beta2/src/lib.rs index 16fb04970c..b7064055b3 100644 --- a/gen/datastore1_beta2/src/lib.rs +++ b/gen/datastore1_beta2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *datastore* crate version *0.1.5+20150402*, where *20150402* is the exact revision of the *datastore:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *datastore* crate version *0.1.6+20150402*, where *20150402* is the exact revision of the *datastore:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *datastore* *v1_beta2* API can be found at the //! [official documentation site](https://developers.google.com/datastore/). @@ -99,21 +99,22 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.datasets().lookup(&req, "datasetId") +//! let result = hub.datasets().lookup(req, "datasetId") //! .doit(); //! //! match result { //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -201,7 +202,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -282,21 +283,22 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.datasets().lookup(&req, "datasetId") +/// let result = hub.datasets().lookup(req, "datasetId") /// .doit(); /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -317,7 +319,7 @@ impl<'a, C, A> Datastore<C, A> Datastore { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -326,7 +328,7 @@ impl<'a, C, A> Datastore<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -1093,10 +1095,10 @@ impl<'a, C, A> DatasetMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `datasetId` - Identifies the dataset. - pub fn commit(&self, request: &CommitRequest, dataset_id: &str) -> DatasetCommitCall<'a, C, A> { + pub fn commit(&self, request: CommitRequest, dataset_id: &str) -> DatasetCommitCall<'a, C, A> { DatasetCommitCall { hub: self.hub, - _request: request.clone(), + _request: request, _dataset_id: dataset_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1112,10 +1114,10 @@ impl<'a, C, A> DatasetMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `datasetId` - Identifies the dataset. - pub fn allocate_ids(&self, request: &AllocateIdsRequest, dataset_id: &str) -> DatasetAllocateIdCall<'a, C, A> { + pub fn allocate_ids(&self, request: AllocateIdsRequest, dataset_id: &str) -> DatasetAllocateIdCall<'a, C, A> { DatasetAllocateIdCall { hub: self.hub, - _request: request.clone(), + _request: request, _dataset_id: dataset_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1131,10 +1133,10 @@ impl<'a, C, A> DatasetMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `datasetId` - Identifies the dataset. - pub fn rollback(&self, request: &RollbackRequest, dataset_id: &str) -> DatasetRollbackCall<'a, C, A> { + pub fn rollback(&self, request: RollbackRequest, dataset_id: &str) -> DatasetRollbackCall<'a, C, A> { DatasetRollbackCall { hub: self.hub, - _request: request.clone(), + _request: request, _dataset_id: dataset_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1150,10 +1152,10 @@ impl<'a, C, A> DatasetMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `datasetId` - Identifies the dataset. - pub fn lookup(&self, request: &LookupRequest, dataset_id: &str) -> DatasetLookupCall<'a, C, A> { + pub fn lookup(&self, request: LookupRequest, dataset_id: &str) -> DatasetLookupCall<'a, C, A> { DatasetLookupCall { hub: self.hub, - _request: request.clone(), + _request: request, _dataset_id: dataset_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1169,10 +1171,10 @@ impl<'a, C, A> DatasetMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `datasetId` - Identifies the dataset. - pub fn run_query(&self, request: &RunQueryRequest, dataset_id: &str) -> DatasetRunQueryCall<'a, C, A> { + pub fn run_query(&self, request: RunQueryRequest, dataset_id: &str) -> DatasetRunQueryCall<'a, C, A> { DatasetRunQueryCall { hub: self.hub, - _request: request.clone(), + _request: request, _dataset_id: dataset_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1188,10 +1190,10 @@ impl<'a, C, A> DatasetMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `datasetId` - Identifies the dataset. - pub fn begin_transaction(&self, request: &BeginTransactionRequest, dataset_id: &str) -> DatasetBeginTransactionCall<'a, C, A> { + pub fn begin_transaction(&self, request: BeginTransactionRequest, dataset_id: &str) -> DatasetBeginTransactionCall<'a, C, A> { DatasetBeginTransactionCall { hub: self.hub, - _request: request.clone(), + _request: request, _dataset_id: dataset_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1240,7 +1242,7 @@ impl<'a, C, A> DatasetMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.datasets().commit(&req, "datasetId") +/// let result = hub.datasets().commit(req, "datasetId") /// .doit(); /// # } /// ``` @@ -1368,12 +1370,17 @@ impl<'a, C, A> DatasetCommitCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1382,7 +1389,7 @@ impl<'a, C, A> DatasetCommitCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1400,8 +1407,8 @@ impl<'a, C, A> DatasetCommitCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &CommitRequest) -> DatasetCommitCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CommitRequest) -> DatasetCommitCall<'a, C, A> { + self._request = new_value; self } /// Identifies the dataset. @@ -1498,7 +1505,7 @@ impl<'a, C, A> DatasetCommitCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.datasets().allocate_ids(&req, "datasetId") +/// let result = hub.datasets().allocate_ids(req, "datasetId") /// .doit(); /// # } /// ``` @@ -1626,12 +1633,17 @@ impl<'a, C, A> DatasetAllocateIdCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1640,7 +1652,7 @@ impl<'a, C, A> DatasetAllocateIdCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1658,8 +1670,8 @@ impl<'a, C, A> DatasetAllocateIdCall<'a, C, A> where C: BorrowMut<hyper::Client> /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AllocateIdsRequest) -> DatasetAllocateIdCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AllocateIdsRequest) -> DatasetAllocateIdCall<'a, C, A> { + self._request = new_value; self } /// Identifies the dataset. @@ -1756,7 +1768,7 @@ impl<'a, C, A> DatasetAllocateIdCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.datasets().rollback(&req, "datasetId") +/// let result = hub.datasets().rollback(req, "datasetId") /// .doit(); /// # } /// ``` @@ -1884,12 +1896,17 @@ impl<'a, C, A> DatasetRollbackCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1898,7 +1915,7 @@ impl<'a, C, A> DatasetRollbackCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1916,8 +1933,8 @@ impl<'a, C, A> DatasetRollbackCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &RollbackRequest) -> DatasetRollbackCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: RollbackRequest) -> DatasetRollbackCall<'a, C, A> { + self._request = new_value; self } /// Identifies the dataset. @@ -2014,7 +2031,7 @@ impl<'a, C, A> DatasetRollbackCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.datasets().lookup(&req, "datasetId") +/// let result = hub.datasets().lookup(req, "datasetId") /// .doit(); /// # } /// ``` @@ -2142,12 +2159,17 @@ impl<'a, C, A> DatasetLookupCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2156,7 +2178,7 @@ impl<'a, C, A> DatasetLookupCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2174,8 +2196,8 @@ impl<'a, C, A> DatasetLookupCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &LookupRequest) -> DatasetLookupCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: LookupRequest) -> DatasetLookupCall<'a, C, A> { + self._request = new_value; self } /// Identifies the dataset. @@ -2272,7 +2294,7 @@ impl<'a, C, A> DatasetLookupCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.datasets().run_query(&req, "datasetId") +/// let result = hub.datasets().run_query(req, "datasetId") /// .doit(); /// # } /// ``` @@ -2400,12 +2422,17 @@ impl<'a, C, A> DatasetRunQueryCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2414,7 +2441,7 @@ impl<'a, C, A> DatasetRunQueryCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2432,8 +2459,8 @@ impl<'a, C, A> DatasetRunQueryCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &RunQueryRequest) -> DatasetRunQueryCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: RunQueryRequest) -> DatasetRunQueryCall<'a, C, A> { + self._request = new_value; self } /// Identifies the dataset. @@ -2530,7 +2557,7 @@ impl<'a, C, A> DatasetRunQueryCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.datasets().begin_transaction(&req, "datasetId") +/// let result = hub.datasets().begin_transaction(req, "datasetId") /// .doit(); /// # } /// ``` @@ -2658,12 +2685,17 @@ impl<'a, C, A> DatasetBeginTransactionCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2672,7 +2704,7 @@ impl<'a, C, A> DatasetBeginTransactionCall<'a, C, A> where C: BorrowMut<hyper::C Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2690,8 +2722,8 @@ impl<'a, C, A> DatasetBeginTransactionCall<'a, C, A> where C: BorrowMut<hyper::C /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &BeginTransactionRequest) -> DatasetBeginTransactionCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: BeginTransactionRequest) -> DatasetBeginTransactionCall<'a, C, A> { + self._request = new_value; self } /// Identifies the dataset. diff --git a/gen/deploymentmanager2_beta1-cli/Cargo.toml b/gen/deploymentmanager2_beta1-cli/Cargo.toml index 38188b30ec..79d0e6761f 100644 --- a/gen/deploymentmanager2_beta1-cli/Cargo.toml +++ b/gen/deploymentmanager2_beta1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-deploymentmanager2_beta1-cli" -version = "0.0.1+20150415" +version = "0.1.0+20150415" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with deploymentmanager (protocol v2beta1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/deploymentmanager2_beta1-cli" diff --git a/gen/deploymentmanager2_beta1-cli/README.md b/gen/deploymentmanager2_beta1-cli/README.md index 747aa3731d..097adadf4e 100644 --- a/gen/deploymentmanager2_beta1-cli/README.md +++ b/gen/deploymentmanager2_beta1-cli/README.md @@ -1,4 +1,112 @@ -# HELLO DEPLOYMENTMANAGER:V2BETA1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `deploymentmanager2-beta1` command-line interface *(CLI)* allows to use most features of the *Google deploymentmanager* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *deploymentmanager* API at revision *20150415*. The CLI is at version *0.1.0*. + +```bash + deploymentmanager2-beta1 [options] deployments delete <project> <deployment> [-p <v>...] [-o <out>] + deploymentmanager2-beta1 [options] deployments get <project> <deployment> [-p <v>...] [-o <out>] + deploymentmanager2-beta1 [options] deployments insert <project> -r <kv>... [-p <v>...] [-o <out>] + deploymentmanager2-beta1 [options] deployments list <project> [-p <v>...] [-o <out>] + deploymentmanager2-beta1 [options] manifests get <project> <deployment> <manifest> [-p <v>...] [-o <out>] + deploymentmanager2-beta1 [options] manifests list <project> <deployment> [-p <v>...] [-o <out>] + deploymentmanager2-beta1 [options] operations get <project> <operation> [-p <v>...] [-o <out>] + deploymentmanager2-beta1 [options] operations list <project> [-p <v>...] [-o <out>] + deploymentmanager2-beta1 [options] resources get <project> <deployment> <resource> [-p <v>...] [-o <out>] + deploymentmanager2-beta1 [options] resources list <project> <deployment> [-p <v>...] [-o <out>] + deploymentmanager2-beta1 [options] types list <project> [-p <v>...] [-o <out>] + deploymentmanager2-beta1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_deploymentmanager2_beta1_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `deploymentmanager2-beta1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/deploymentmanager2-beta1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/deploymentmanager2-beta1-secret.json`, assuming that the required *deploymentmanager* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `deploymentmanager2-beta1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/deploymentmanager2_beta1-cli/mkdocs.yml b/gen/deploymentmanager2_beta1-cli/mkdocs.yml index fcba2e0cf5..39d82d71c6 100644 --- a/gen/deploymentmanager2_beta1-cli/mkdocs.yml +++ b/gen/deploymentmanager2_beta1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: deploymentmanager v0.0.1+20150415 +site_name: deploymentmanager v0.1.0+20150415 site_url: http://byron.github.io/google-apis-rs/google-deploymentmanager2_beta1-cli site_description: Write integrating applications with bcore diff --git a/gen/deploymentmanager2_beta1-cli/src/cmn.rs b/gen/deploymentmanager2_beta1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/deploymentmanager2_beta1-cli/src/cmn.rs +++ b/gen/deploymentmanager2_beta1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/deploymentmanager2_beta1-cli/src/main.rs b/gen/deploymentmanager2_beta1-cli/src/main.rs index ac2cce7dd5..cb1ba34835 100644 --- a/gen/deploymentmanager2_beta1-cli/src/main.rs +++ b/gen/deploymentmanager2_beta1-cli/src/main.rs @@ -19,36 +19,37 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - deploymentmanager2-beta1 [options] deployments delete <project> <deployment> [-p <v>]... [-o <out>] - deploymentmanager2-beta1 [options] deployments get <project> <deployment> [-p <v>]... [-o <out>] - deploymentmanager2-beta1 [options] deployments insert <project> -r <kv>... [-p <v>]... [-o <out>] - deploymentmanager2-beta1 [options] deployments list <project> [-p <v>]... [-o <out>] - deploymentmanager2-beta1 [options] manifests get <project> <deployment> <manifest> [-p <v>]... [-o <out>] - deploymentmanager2-beta1 [options] manifests list <project> <deployment> [-p <v>]... [-o <out>] - deploymentmanager2-beta1 [options] operations get <project> <operation> [-p <v>]... [-o <out>] - deploymentmanager2-beta1 [options] operations list <project> [-p <v>]... [-o <out>] - deploymentmanager2-beta1 [options] resources get <project> <deployment> <resource> [-p <v>]... [-o <out>] - deploymentmanager2-beta1 [options] resources list <project> <deployment> [-p <v>]... [-o <out>] - deploymentmanager2-beta1 [options] types list <project> [-p <v>]... [-o <out>] + deploymentmanager2-beta1 [options] deployments delete <project> <deployment> [-p <v>...] [-o <out>] + deploymentmanager2-beta1 [options] deployments get <project> <deployment> [-p <v>...] [-o <out>] + deploymentmanager2-beta1 [options] deployments insert <project> -r <kv>... [-p <v>...] [-o <out>] + deploymentmanager2-beta1 [options] deployments list <project> [-p <v>...] [-o <out>] + deploymentmanager2-beta1 [options] manifests get <project> <deployment> <manifest> [-p <v>...] [-o <out>] + deploymentmanager2-beta1 [options] manifests list <project> <deployment> [-p <v>...] [-o <out>] + deploymentmanager2-beta1 [options] operations get <project> <operation> [-p <v>...] [-o <out>] + deploymentmanager2-beta1 [options] operations list <project> [-p <v>...] [-o <out>] + deploymentmanager2-beta1 [options] resources get <project> <deployment> <resource> [-p <v>...] [-o <out>] + deploymentmanager2-beta1 [options] resources list <project> <deployment> [-p <v>...] [-o <out>] + deploymentmanager2-beta1 [options] types list <project> [-p <v>...] [-o <out>] deploymentmanager2-beta1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_deploymentmanager2_beta1_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -97,6 +98,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -140,6 +144,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -156,8 +163,45 @@ impl Engine { fn _deployments_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Deployment::default(); - let mut call = self.hub.deployments().insert(&request, &self.opt.arg_project); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "target-config" => { + request.target_config = Some(value.unwrap_or("").to_string()); + }, + "manifest" => { + request.manifest = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + "description" => { + request.description = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.deployments().insert(request, &self.opt.arg_project); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -179,39 +223,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "target-config" => { - request.target_config = Some(value.unwrap_or("").to_string()); - }, - "manifest" => { - request.manifest = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "description" => { - request.description = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -261,6 +280,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -304,6 +326,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -353,6 +378,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -396,6 +424,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -445,6 +476,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -488,6 +522,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -537,6 +574,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -586,6 +626,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -719,6 +762,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -726,8 +770,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/deploymentmanager2_beta1/Cargo.toml b/gen/deploymentmanager2_beta1/Cargo.toml index 3c996be156..c264541101 100644 --- a/gen/deploymentmanager2_beta1/Cargo.toml +++ b/gen/deploymentmanager2_beta1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-deploymentmanager2_beta1" -version = "0.1.5+20150415" +version = "0.1.6+20150415" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with deploymentmanager (protocol v2beta1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/deploymentmanager2_beta1" diff --git a/gen/deploymentmanager2_beta1/README.md b/gen/deploymentmanager2_beta1/README.md index f3b602c934..7d0932d8ca 100644 --- a/gen/deploymentmanager2_beta1/README.md +++ b/gen/deploymentmanager2_beta1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-deploymentmanager2_beta1` library allows access to all features of the *Google deploymentmanager* service. -This documentation was generated from *deploymentmanager* crate version *0.1.5+20150415*, where *20150415* is the exact revision of the *deploymentmanager:v2beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *deploymentmanager* crate version *0.1.6+20150415*, where *20150415* is the exact revision of the *deploymentmanager:v2beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *deploymentmanager* *v2_beta1* API can be found at the [official documentation site](https://developers.google.com/deployment-manager/). @@ -112,14 +112,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/deploymentmanager2_beta1/src/cmn.rs b/gen/deploymentmanager2_beta1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/deploymentmanager2_beta1/src/cmn.rs +++ b/gen/deploymentmanager2_beta1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/deploymentmanager2_beta1/src/lib.rs b/gen/deploymentmanager2_beta1/src/lib.rs index c7f1924f2e..d9cbd39772 100644 --- a/gen/deploymentmanager2_beta1/src/lib.rs +++ b/gen/deploymentmanager2_beta1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *deploymentmanager* crate version *0.1.5+20150415*, where *20150415* is the exact revision of the *deploymentmanager:v2beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *deploymentmanager* crate version *0.1.6+20150415*, where *20150415* is the exact revision of the *deploymentmanager:v2beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *deploymentmanager* *v2_beta1* API can be found at the //! [official documentation site](https://developers.google.com/deployment-manager/). @@ -113,14 +113,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -208,7 +209,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -292,14 +293,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -320,7 +322,7 @@ impl<'a, C, A> Deploymentmanager<C, A> Deploymentmanager { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -341,7 +343,7 @@ impl<'a, C, A> Deploymentmanager<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -835,10 +837,10 @@ impl<'a, C, A> DeploymentMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `project` - ! The project ID for this request. - pub fn insert(&self, request: &Deployment, project: &str) -> DeploymentInsertCall<'a, C, A> { + pub fn insert(&self, request: Deployment, project: &str) -> DeploymentInsertCall<'a, C, A> { DeploymentInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1285,12 +1287,17 @@ impl<'a, C, A> OperationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1299,7 +1306,7 @@ impl<'a, C, A> OperationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1539,12 +1546,17 @@ impl<'a, C, A> OperationListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1553,7 +1565,7 @@ impl<'a, C, A> OperationListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1674,7 +1686,7 @@ impl<'a, C, A> OperationListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.deployments().insert(&req, "project") +/// let result = hub.deployments().insert(req, "project") /// .doit(); /// # } /// ``` @@ -1802,12 +1814,17 @@ impl<'a, C, A> DeploymentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1816,7 +1833,7 @@ impl<'a, C, A> DeploymentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1834,8 +1851,8 @@ impl<'a, C, A> DeploymentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Deployment) -> DeploymentInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Deployment) -> DeploymentInsertCall<'a, C, A> { + self._request = new_value; self } /// ! The project ID for this request. @@ -2047,12 +2064,17 @@ impl<'a, C, A> DeploymentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2061,7 +2083,7 @@ impl<'a, C, A> DeploymentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2301,12 +2323,17 @@ impl<'a, C, A> DeploymentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2315,7 +2342,7 @@ impl<'a, C, A> DeploymentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2551,12 +2578,17 @@ impl<'a, C, A> DeploymentDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2565,7 +2597,7 @@ impl<'a, C, A> DeploymentDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2805,12 +2837,17 @@ impl<'a, C, A> TypeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2819,7 +2856,7 @@ impl<'a, C, A> TypeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3057,12 +3094,17 @@ impl<'a, C, A> ResourceGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3071,7 +3113,7 @@ impl<'a, C, A> ResourceGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3323,12 +3365,17 @@ impl<'a, C, A> ResourceListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3337,7 +3384,7 @@ impl<'a, C, A> ResourceListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3593,12 +3640,17 @@ impl<'a, C, A> ManifestListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3607,7 +3659,7 @@ impl<'a, C, A> ManifestListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3855,12 +3907,17 @@ impl<'a, C, A> ManifestGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3869,7 +3926,7 @@ impl<'a, C, A> ManifestGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/dfareporting2d1-cli/Cargo.toml b/gen/dfareporting2d1-cli/Cargo.toml index 420131fe9b..cefe278d07 100644 --- a/gen/dfareporting2d1-cli/Cargo.toml +++ b/gen/dfareporting2d1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-dfareporting2d1-cli" -version = "0.0.1+20150326" +version = "0.1.0+20150326" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with dfareporting (protocol v2.1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/dfareporting2d1-cli" diff --git a/gen/dfareporting2d1-cli/README.md b/gen/dfareporting2d1-cli/README.md index 85b7056f4c..b3cc81d788 100644 --- a/gen/dfareporting2d1-cli/README.md +++ b/gen/dfareporting2d1-cli/README.md @@ -1,4 +1,294 @@ -# HELLO DFAREPORTING:V2.1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `dfareporting2d1` command-line interface *(CLI)* allows to use most features of the *Google dfareporting* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *dfareporting* API at revision *20150326*. The CLI is at version *0.1.0*. + +```bash + dfareporting2d1 [options] account-active-ad-summaries get <profile-id> <summary-account-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] account-permission-groups get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] account-permission-groups list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] account-permissions get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] account-permissions list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] account-user-profiles get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] account-user-profiles insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] account-user-profiles list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] account-user-profiles patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] account-user-profiles update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] accounts get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] accounts list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] accounts patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] accounts update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] ads get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] ads insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] ads list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] ads patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] ads update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] advertiser-groups delete <profile-id> <id> [-p <v>...] + dfareporting2d1 [options] advertiser-groups get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] advertiser-groups insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] advertiser-groups list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] advertiser-groups patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] advertiser-groups update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] advertisers get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] advertisers insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] advertisers list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] advertisers patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] advertisers update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] browsers list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] campaign-creative-associations insert <profile-id> <campaign-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] campaign-creative-associations list <profile-id> <campaign-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] campaigns get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] campaigns insert <profile-id> <default-landing-page-name> <default-landing-page-url> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] campaigns list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] campaigns patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] campaigns update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] change-logs get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] change-logs list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] cities list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] connection-types get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] connection-types list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] content-categories delete <profile-id> <id> [-p <v>...] + dfareporting2d1 [options] content-categories get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] content-categories insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] content-categories list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] content-categories patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] content-categories update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] countries get <profile-id> <dart-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] countries list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-assets insert <profile-id> <advertiser-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-field-values delete <profile-id> <creative-field-id> <id> [-p <v>...] + dfareporting2d1 [options] creative-field-values get <profile-id> <creative-field-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-field-values insert <profile-id> <creative-field-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-field-values list <profile-id> <creative-field-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-field-values patch <profile-id> <creative-field-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-field-values update <profile-id> <creative-field-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-fields delete <profile-id> <id> [-p <v>...] + dfareporting2d1 [options] creative-fields get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-fields insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-fields list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-fields patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-fields update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-groups get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-groups insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-groups list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-groups patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-groups update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] creatives get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] creatives insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] creatives list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] creatives patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] creatives update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] dimension-values query <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] directory-site-contacts get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] directory-site-contacts list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] directory-sites get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] directory-sites insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] directory-sites list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] event-tags delete <profile-id> <id> [-p <v>...] + dfareporting2d1 [options] event-tags get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] event-tags insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] event-tags list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] event-tags patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] event-tags update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] files get <report-id> <file-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] files list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-activities delete <profile-id> <id> [-p <v>...] + dfareporting2d1 [options] floodlight-activities generatetag <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-activities get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-activities insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-activities list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-activities patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-activities update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-activity-groups delete <profile-id> <id> [-p <v>...] + dfareporting2d1 [options] floodlight-activity-groups get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-activity-groups insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-activity-groups list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-activity-groups patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-activity-groups update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-configurations get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-configurations list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-configurations patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-configurations update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] inventory-items get <profile-id> <project-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] inventory-items list <profile-id> <project-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] landing-pages delete <profile-id> <campaign-id> <id> [-p <v>...] + dfareporting2d1 [options] landing-pages get <profile-id> <campaign-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] landing-pages insert <profile-id> <campaign-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] landing-pages list <profile-id> <campaign-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] landing-pages patch <profile-id> <campaign-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] landing-pages update <profile-id> <campaign-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] metros list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] mobile-carriers get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] mobile-carriers list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] operating-system-versions get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] operating-system-versions list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] operating-systems get <profile-id> <dart-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] operating-systems list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] order-documents get <profile-id> <project-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] order-documents list <profile-id> <project-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] orders get <profile-id> <project-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] orders list <profile-id> <project-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] placement-groups get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] placement-groups insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] placement-groups list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] placement-groups patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] placement-groups update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] placement-strategies delete <profile-id> <id> [-p <v>...] + dfareporting2d1 [options] placement-strategies get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] placement-strategies insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] placement-strategies list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] placement-strategies patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] placement-strategies update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] placements generatetags <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] placements get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] placements insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] placements list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] placements patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] placements update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] platform-types get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] platform-types list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] postal-codes get <profile-id> <code> [-p <v>...] [-o <out>] + dfareporting2d1 [options] postal-codes list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] projects get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] projects list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] regions list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] remarketing-list-shares get <profile-id> <remarketing-list-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] remarketing-list-shares patch <profile-id> <remarketing-list-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] remarketing-list-shares update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] remarketing-lists get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] remarketing-lists insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] remarketing-lists list <profile-id> <advertiser-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] remarketing-lists patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] remarketing-lists update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] reports compatible-fields-query <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] reports delete <profile-id> <report-id> [-p <v>...] + dfareporting2d1 [options] reports files-get <profile-id> <report-id> <file-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] reports files-list <profile-id> <report-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] reports get <profile-id> <report-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] reports insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] reports list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] reports patch <profile-id> <report-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] reports run <profile-id> <report-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] reports update <profile-id> <report-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] sites get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] sites insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] sites list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] sites patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] sites update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] sizes get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] sizes insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] sizes list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] subaccounts get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] subaccounts insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] subaccounts list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] subaccounts patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] subaccounts update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] targetable-remarketing-lists get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] targetable-remarketing-lists list <profile-id> <advertiser-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] user-profiles get <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] user-profiles list [-p <v>...] [-o <out>] + dfareporting2d1 [options] user-role-permission-groups get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] user-role-permission-groups list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] user-role-permissions get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] user-role-permissions list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] user-roles delete <profile-id> <id> [-p <v>...] + dfareporting2d1 [options] user-roles get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] user-roles insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] user-roles list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] user-roles patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] user-roles update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_dfareporting2d1_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `dfareporting2d1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/dfareporting2d1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/dfareporting2d1-secret.json`, assuming that the required *dfareporting* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `dfareporting2d1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/dfareporting2d1-cli/mkdocs.yml b/gen/dfareporting2d1-cli/mkdocs.yml index db9b47504d..fa56c8a814 100644 --- a/gen/dfareporting2d1-cli/mkdocs.yml +++ b/gen/dfareporting2d1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: dfareporting v0.0.1+20150326 +site_name: dfareporting v0.1.0+20150326 site_url: http://byron.github.io/google-apis-rs/google-dfareporting2d1-cli site_description: Write integrating applications with bcore diff --git a/gen/dfareporting2d1-cli/src/cmn.rs b/gen/dfareporting2d1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/dfareporting2d1-cli/src/cmn.rs +++ b/gen/dfareporting2d1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/dfareporting2d1-cli/src/main.rs b/gen/dfareporting2d1-cli/src/main.rs index 00fdcb7e54..41ca80faf8 100644 --- a/gen/dfareporting2d1-cli/src/main.rs +++ b/gen/dfareporting2d1-cli/src/main.rs @@ -19,218 +19,219 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - dfareporting2d1 [options] account-active-ad-summaries get <profile-id> <summary-account-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] account-permission-groups get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] account-permission-groups list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] account-permissions get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] account-permissions list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] account-user-profiles get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] account-user-profiles insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] account-user-profiles list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] account-user-profiles patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] account-user-profiles update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] accounts get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] accounts list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] accounts patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] accounts update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] ads get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] ads insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] ads list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] ads patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] ads update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] advertiser-groups delete <profile-id> <id> [-p <v>]... - dfareporting2d1 [options] advertiser-groups get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] advertiser-groups insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] advertiser-groups list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] advertiser-groups patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] advertiser-groups update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] advertisers get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] advertisers insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] advertisers list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] advertisers patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] advertisers update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] browsers list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] campaign-creative-associations insert <profile-id> <campaign-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] campaign-creative-associations list <profile-id> <campaign-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] campaigns get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] campaigns insert <profile-id> <default-landing-page-name> <default-landing-page-url> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] campaigns list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] campaigns patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] campaigns update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] change-logs get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] change-logs list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] cities list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] connection-types get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] connection-types list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] content-categories delete <profile-id> <id> [-p <v>]... - dfareporting2d1 [options] content-categories get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] content-categories insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] content-categories list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] content-categories patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] content-categories update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] countries get <profile-id> <dart-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] countries list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] creative-assets insert <profile-id> <advertiser-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] - dfareporting2d1 [options] creative-field-values delete <profile-id> <creative-field-id> <id> [-p <v>]... - dfareporting2d1 [options] creative-field-values get <profile-id> <creative-field-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] creative-field-values insert <profile-id> <creative-field-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] creative-field-values list <profile-id> <creative-field-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] creative-field-values patch <profile-id> <creative-field-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] creative-field-values update <profile-id> <creative-field-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] creative-fields delete <profile-id> <id> [-p <v>]... - dfareporting2d1 [options] creative-fields get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] creative-fields insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] creative-fields list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] creative-fields patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] creative-fields update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] creative-groups get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] creative-groups insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] creative-groups list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] creative-groups patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] creative-groups update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] creatives get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] creatives insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] creatives list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] creatives patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] creatives update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] dimension-values query <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] directory-site-contacts get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] directory-site-contacts list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] directory-sites get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] directory-sites insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] directory-sites list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] event-tags delete <profile-id> <id> [-p <v>]... - dfareporting2d1 [options] event-tags get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] event-tags insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] event-tags list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] event-tags patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] event-tags update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] files get <report-id> <file-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] files list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] floodlight-activities delete <profile-id> <id> [-p <v>]... - dfareporting2d1 [options] floodlight-activities generatetag <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] floodlight-activities get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] floodlight-activities insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] floodlight-activities list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] floodlight-activities patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] floodlight-activities update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] floodlight-activity-groups delete <profile-id> <id> [-p <v>]... - dfareporting2d1 [options] floodlight-activity-groups get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] floodlight-activity-groups insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] floodlight-activity-groups list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] floodlight-activity-groups patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] floodlight-activity-groups update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] floodlight-configurations get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] floodlight-configurations list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] floodlight-configurations patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] floodlight-configurations update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] inventory-items get <profile-id> <project-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] inventory-items list <profile-id> <project-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] landing-pages delete <profile-id> <campaign-id> <id> [-p <v>]... - dfareporting2d1 [options] landing-pages get <profile-id> <campaign-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] landing-pages insert <profile-id> <campaign-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] landing-pages list <profile-id> <campaign-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] landing-pages patch <profile-id> <campaign-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] landing-pages update <profile-id> <campaign-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] metros list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] mobile-carriers get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] mobile-carriers list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] operating-system-versions get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] operating-system-versions list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] operating-systems get <profile-id> <dart-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] operating-systems list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] order-documents get <profile-id> <project-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] order-documents list <profile-id> <project-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] orders get <profile-id> <project-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] orders list <profile-id> <project-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] placement-groups get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] placement-groups insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] placement-groups list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] placement-groups patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] placement-groups update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] placement-strategies delete <profile-id> <id> [-p <v>]... - dfareporting2d1 [options] placement-strategies get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] placement-strategies insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] placement-strategies list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] placement-strategies patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] placement-strategies update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] placements generatetags <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] placements get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] placements insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] placements list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] placements patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] placements update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] platform-types get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] platform-types list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] postal-codes get <profile-id> <code> [-p <v>]... [-o <out>] - dfareporting2d1 [options] postal-codes list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] projects get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] projects list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] regions list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] remarketing-list-shares get <profile-id> <remarketing-list-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] remarketing-list-shares patch <profile-id> <remarketing-list-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] remarketing-list-shares update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] remarketing-lists get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] remarketing-lists insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] remarketing-lists list <profile-id> <advertiser-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] remarketing-lists patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] remarketing-lists update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] reports compatible-fields-query <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] reports delete <profile-id> <report-id> [-p <v>]... - dfareporting2d1 [options] reports files-get <profile-id> <report-id> <file-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] reports files-list <profile-id> <report-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] reports get <profile-id> <report-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] reports insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] reports list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] reports patch <profile-id> <report-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] reports run <profile-id> <report-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] reports update <profile-id> <report-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] sites get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] sites insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] sites list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] sites patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] sites update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] sizes get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] sizes insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] sizes list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] subaccounts get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] subaccounts insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] subaccounts list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] subaccounts patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] subaccounts update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] targetable-remarketing-lists get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] targetable-remarketing-lists list <profile-id> <advertiser-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] user-profiles get <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] user-profiles list [-p <v>]... [-o <out>] - dfareporting2d1 [options] user-role-permission-groups get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] user-role-permission-groups list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] user-role-permissions get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] user-role-permissions list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] user-roles delete <profile-id> <id> [-p <v>]... - dfareporting2d1 [options] user-roles get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] user-roles insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] user-roles list <profile-id> [-p <v>]... [-o <out>] - dfareporting2d1 [options] user-roles patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2d1 [options] user-roles update <profile-id> -r <kv>... [-p <v>]... [-o <out>] + dfareporting2d1 [options] account-active-ad-summaries get <profile-id> <summary-account-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] account-permission-groups get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] account-permission-groups list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] account-permissions get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] account-permissions list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] account-user-profiles get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] account-user-profiles insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] account-user-profiles list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] account-user-profiles patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] account-user-profiles update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] accounts get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] accounts list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] accounts patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] accounts update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] ads get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] ads insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] ads list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] ads patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] ads update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] advertiser-groups delete <profile-id> <id> [-p <v>...] + dfareporting2d1 [options] advertiser-groups get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] advertiser-groups insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] advertiser-groups list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] advertiser-groups patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] advertiser-groups update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] advertisers get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] advertisers insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] advertisers list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] advertisers patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] advertisers update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] browsers list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] campaign-creative-associations insert <profile-id> <campaign-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] campaign-creative-associations list <profile-id> <campaign-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] campaigns get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] campaigns insert <profile-id> <default-landing-page-name> <default-landing-page-url> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] campaigns list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] campaigns patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] campaigns update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] change-logs get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] change-logs list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] cities list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] connection-types get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] connection-types list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] content-categories delete <profile-id> <id> [-p <v>...] + dfareporting2d1 [options] content-categories get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] content-categories insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] content-categories list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] content-categories patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] content-categories update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] countries get <profile-id> <dart-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] countries list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-assets insert <profile-id> <advertiser-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-field-values delete <profile-id> <creative-field-id> <id> [-p <v>...] + dfareporting2d1 [options] creative-field-values get <profile-id> <creative-field-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-field-values insert <profile-id> <creative-field-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-field-values list <profile-id> <creative-field-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-field-values patch <profile-id> <creative-field-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-field-values update <profile-id> <creative-field-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-fields delete <profile-id> <id> [-p <v>...] + dfareporting2d1 [options] creative-fields get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-fields insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-fields list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-fields patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-fields update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-groups get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-groups insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-groups list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-groups patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] creative-groups update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] creatives get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] creatives insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] creatives list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] creatives patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] creatives update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] dimension-values query <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] directory-site-contacts get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] directory-site-contacts list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] directory-sites get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] directory-sites insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] directory-sites list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] event-tags delete <profile-id> <id> [-p <v>...] + dfareporting2d1 [options] event-tags get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] event-tags insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] event-tags list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] event-tags patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] event-tags update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] files get <report-id> <file-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] files list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-activities delete <profile-id> <id> [-p <v>...] + dfareporting2d1 [options] floodlight-activities generatetag <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-activities get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-activities insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-activities list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-activities patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-activities update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-activity-groups delete <profile-id> <id> [-p <v>...] + dfareporting2d1 [options] floodlight-activity-groups get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-activity-groups insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-activity-groups list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-activity-groups patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-activity-groups update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-configurations get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-configurations list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-configurations patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] floodlight-configurations update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] inventory-items get <profile-id> <project-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] inventory-items list <profile-id> <project-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] landing-pages delete <profile-id> <campaign-id> <id> [-p <v>...] + dfareporting2d1 [options] landing-pages get <profile-id> <campaign-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] landing-pages insert <profile-id> <campaign-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] landing-pages list <profile-id> <campaign-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] landing-pages patch <profile-id> <campaign-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] landing-pages update <profile-id> <campaign-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] metros list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] mobile-carriers get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] mobile-carriers list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] operating-system-versions get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] operating-system-versions list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] operating-systems get <profile-id> <dart-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] operating-systems list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] order-documents get <profile-id> <project-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] order-documents list <profile-id> <project-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] orders get <profile-id> <project-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] orders list <profile-id> <project-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] placement-groups get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] placement-groups insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] placement-groups list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] placement-groups patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] placement-groups update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] placement-strategies delete <profile-id> <id> [-p <v>...] + dfareporting2d1 [options] placement-strategies get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] placement-strategies insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] placement-strategies list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] placement-strategies patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] placement-strategies update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] placements generatetags <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] placements get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] placements insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] placements list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] placements patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] placements update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] platform-types get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] platform-types list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] postal-codes get <profile-id> <code> [-p <v>...] [-o <out>] + dfareporting2d1 [options] postal-codes list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] projects get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] projects list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] regions list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] remarketing-list-shares get <profile-id> <remarketing-list-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] remarketing-list-shares patch <profile-id> <remarketing-list-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] remarketing-list-shares update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] remarketing-lists get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] remarketing-lists insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] remarketing-lists list <profile-id> <advertiser-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] remarketing-lists patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] remarketing-lists update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] reports compatible-fields-query <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] reports delete <profile-id> <report-id> [-p <v>...] + dfareporting2d1 [options] reports files-get <profile-id> <report-id> <file-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] reports files-list <profile-id> <report-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] reports get <profile-id> <report-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] reports insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] reports list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] reports patch <profile-id> <report-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] reports run <profile-id> <report-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] reports update <profile-id> <report-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] sites get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] sites insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] sites list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] sites patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] sites update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] sizes get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] sizes insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] sizes list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] subaccounts get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] subaccounts insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] subaccounts list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] subaccounts patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] subaccounts update <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] targetable-remarketing-lists get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] targetable-remarketing-lists list <profile-id> <advertiser-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] user-profiles get <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] user-profiles list [-p <v>...] [-o <out>] + dfareporting2d1 [options] user-role-permission-groups get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] user-role-permission-groups list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] user-role-permissions get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] user-role-permissions list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] user-roles delete <profile-id> <id> [-p <v>...] + dfareporting2d1 [options] user-roles get <profile-id> <id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] user-roles insert <profile-id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] user-roles list <profile-id> [-p <v>...] [-o <out>] + dfareporting2d1 [options] user-roles patch <profile-id> <id> -r <kv>... [-p <v>...] [-o <out>] + dfareporting2d1 [options] user-roles update <profile-id> -r <kv>... [-p <v>...] [-o <out>] dfareporting2d1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_dfareporting2d1_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -279,6 +280,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -322,6 +326,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -365,6 +372,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -408,6 +418,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -451,6 +464,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -494,6 +510,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -510,36 +529,23 @@ impl Engine { fn _account_user_profiles_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::AccountUserProfile::default(); - let mut call = self.hub.account_user_profiles().insert(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::AccountUserProfile::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_filter_init(request: &mut api::AccountUserProfile) { if request.advertiser_filter.is_none() { request.advertiser_filter = Some(Default::default()); @@ -564,7 +570,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -672,15 +678,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.account_user_profiles().insert(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -751,6 +782,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -767,36 +801,23 @@ impl Engine { fn _account_user_profiles_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::AccountUserProfile::default(); - let mut call = self.hub.account_user_profiles().patch(&request, &self.opt.arg_profile_id, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::AccountUserProfile::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_filter_init(request: &mut api::AccountUserProfile) { if request.advertiser_filter.is_none() { request.advertiser_filter = Some(Default::default()); @@ -821,7 +842,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -929,15 +950,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.account_user_profiles().patch(request, &self.opt.arg_profile_id, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -954,36 +1000,23 @@ impl Engine { fn _account_user_profiles_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::AccountUserProfile::default(); - let mut call = self.hub.account_user_profiles().update(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::AccountUserProfile::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_filter_init(request: &mut api::AccountUserProfile) { if request.advertiser_filter.is_none() { request.advertiser_filter = Some(Default::default()); @@ -1008,7 +1041,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1116,15 +1149,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.account_user_profiles().update(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1168,6 +1226,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1232,6 +1293,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1248,36 +1312,23 @@ impl Engine { fn _accounts_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Account::default(); - let mut call = self.hub.accounts().patch(&request, &self.opt.arg_profile_id, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Account::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_reports_configuration_init(request: &mut api::Account) { if request.reports_configuration.is_none() { request.reports_configuration = Some(Default::default()); @@ -1291,7 +1342,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1376,15 +1427,40 @@ impl Engine { request.available_permission_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.accounts().patch(request, &self.opt.arg_profile_id, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1401,36 +1477,23 @@ impl Engine { fn _accounts_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Account::default(); - let mut call = self.hub.accounts().update(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Account::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_reports_configuration_init(request: &mut api::Account) { if request.reports_configuration.is_none() { request.reports_configuration = Some(Default::default()); @@ -1444,7 +1507,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1529,15 +1592,40 @@ impl Engine { request.available_permission_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.accounts().update(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1581,6 +1669,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1597,36 +1688,23 @@ impl Engine { fn _ads_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Ad::default(); - let mut call = self.hub.ads().insert(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Ad::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::Ad) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -1724,7 +1802,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "click-through-url-suffix-properties.click-through-url-suffix" => { request_click_through_url_suffix_properties_init(&mut request); request.click_through_url_suffix_properties.as_mut().unwrap().click_through_url_suffix = Some(value.unwrap_or("").to_string()); @@ -1988,15 +2066,40 @@ impl Engine { request.dynamic_click_tracker = Some(arg_from_str(value.unwrap_or("false"), err, "dynamic-click-tracker", "boolean")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.ads().insert(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2112,6 +2215,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2128,36 +2234,23 @@ impl Engine { fn _ads_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Ad::default(); - let mut call = self.hub.ads().patch(&request, &self.opt.arg_profile_id, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Ad::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::Ad) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -2255,7 +2348,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "click-through-url-suffix-properties.click-through-url-suffix" => { request_click_through_url_suffix_properties_init(&mut request); request.click_through_url_suffix_properties.as_mut().unwrap().click_through_url_suffix = Some(value.unwrap_or("").to_string()); @@ -2519,15 +2612,40 @@ impl Engine { request.dynamic_click_tracker = Some(arg_from_str(value.unwrap_or("false"), err, "dynamic-click-tracker", "boolean")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.ads().patch(request, &self.opt.arg_profile_id, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2544,36 +2662,23 @@ impl Engine { fn _ads_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Ad::default(); - let mut call = self.hub.ads().update(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Ad::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::Ad) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -2671,7 +2776,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "click-through-url-suffix-properties.click-through-url-suffix" => { request_click_through_url_suffix_properties_init(&mut request); request.click_through_url_suffix_properties.as_mut().unwrap().click_through_url_suffix = Some(value.unwrap_or("").to_string()); @@ -2935,15 +3040,40 @@ impl Engine { request.dynamic_click_tracker = Some(arg_from_str(value.unwrap_or("false"), err, "dynamic-click-tracker", "boolean")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.ads().update(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2987,6 +3117,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -3028,6 +3161,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3044,8 +3180,42 @@ impl Engine { fn _advertiser_groups_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::AdvertiserGroup::default(); - let mut call = self.hub.advertiser_groups().insert(&request, &self.opt.arg_profile_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request.account_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.advertiser_groups().insert(request, &self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -3067,36 +3237,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request.account_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3158,6 +3306,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3174,8 +3325,42 @@ impl Engine { fn _advertiser_groups_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::AdvertiserGroup::default(); - let mut call = self.hub.advertiser_groups().patch(&request, &self.opt.arg_profile_id, &self.opt.arg_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request.account_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.advertiser_groups().patch(request, &self.opt.arg_profile_id, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -3197,36 +3382,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request.account_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3243,8 +3406,42 @@ impl Engine { fn _advertiser_groups_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::AdvertiserGroup::default(); - let mut call = self.hub.advertiser_groups().update(&request, &self.opt.arg_profile_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request.account_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.advertiser_groups().update(request, &self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -3266,36 +3463,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request.account_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3339,6 +3514,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3355,36 +3533,23 @@ impl Engine { fn _advertisers_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Advertiser::default(); - let mut call = self.hub.advertisers().insert(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Advertiser::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_floodlight_configuration_id_dimension_value_init(request: &mut api::Advertiser) { if request.floodlight_configuration_id_dimension_value.is_none() { request.floodlight_configuration_id_dimension_value = Some(Default::default()); @@ -3397,7 +3562,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -3487,15 +3652,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.advertisers().insert(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3575,6 +3765,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3591,36 +3784,23 @@ impl Engine { fn _advertisers_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Advertiser::default(); - let mut call = self.hub.advertisers().patch(&request, &self.opt.arg_profile_id, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Advertiser::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_floodlight_configuration_id_dimension_value_init(request: &mut api::Advertiser) { if request.floodlight_configuration_id_dimension_value.is_none() { request.floodlight_configuration_id_dimension_value = Some(Default::default()); @@ -3633,7 +3813,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -3723,15 +3903,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.advertisers().patch(request, &self.opt.arg_profile_id, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3748,36 +3953,23 @@ impl Engine { fn _advertisers_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Advertiser::default(); - let mut call = self.hub.advertisers().update(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Advertiser::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_floodlight_configuration_id_dimension_value_init(request: &mut api::Advertiser) { if request.floodlight_configuration_id_dimension_value.is_none() { request.floodlight_configuration_id_dimension_value = Some(Default::default()); @@ -3790,7 +3982,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -3880,15 +4072,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.advertisers().update(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3932,6 +4149,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3948,8 +4168,36 @@ impl Engine { fn _campaign_creative_associations_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::CampaignCreativeAssociation::default(); - let mut call = self.hub.campaign_creative_associations().insert(&request, &self.opt.arg_profile_id, &self.opt.arg_campaign_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "creative-id" => { + request.creative_id = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.campaign_creative_associations().insert(request, &self.opt.arg_profile_id, &self.opt.arg_campaign_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -3971,30 +4219,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "creative-id" => { - request.creative_id = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4047,6 +4279,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4090,6 +4325,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4106,36 +4344,23 @@ impl Engine { fn _campaigns_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Campaign::default(); - let mut call = self.hub.campaigns().insert(&request, &self.opt.arg_profile_id, &self.opt.arg_default_landing_page_name, &self.opt.arg_default_landing_page_url); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Campaign::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::Campaign) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -4184,7 +4409,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "comment" => { request.comment = Some(value.unwrap_or("").to_string()); }, @@ -4349,15 +4574,40 @@ impl Engine { request.last_modified_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.campaigns().insert(request, &self.opt.arg_profile_id, &self.opt.arg_default_landing_page_name, &self.opt.arg_default_landing_page_url); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4440,6 +4690,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4456,36 +4709,23 @@ impl Engine { fn _campaigns_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Campaign::default(); - let mut call = self.hub.campaigns().patch(&request, &self.opt.arg_profile_id, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Campaign::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::Campaign) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -4534,7 +4774,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "comment" => { request.comment = Some(value.unwrap_or("").to_string()); }, @@ -4699,15 +4939,40 @@ impl Engine { request.last_modified_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.campaigns().patch(request, &self.opt.arg_profile_id, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4724,36 +4989,23 @@ impl Engine { fn _campaigns_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Campaign::default(); - let mut call = self.hub.campaigns().update(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Campaign::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::Campaign) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -4802,7 +5054,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "comment" => { request.comment = Some(value.unwrap_or("").to_string()); }, @@ -4967,15 +5219,40 @@ impl Engine { request.last_modified_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.campaigns().update(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5019,6 +5296,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5092,6 +5372,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5147,6 +5430,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5190,6 +5476,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5233,6 +5522,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5276,6 +5568,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -5317,6 +5612,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5333,8 +5631,42 @@ impl Engine { fn _content_categories_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::ContentCategory::default(); - let mut call = self.hub.content_categories().insert(&request, &self.opt.arg_profile_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request.account_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.content_categories().insert(request, &self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -5356,36 +5688,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request.account_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5447,6 +5757,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5463,8 +5776,42 @@ impl Engine { fn _content_categories_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::ContentCategory::default(); - let mut call = self.hub.content_categories().patch(&request, &self.opt.arg_profile_id, &self.opt.arg_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request.account_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.content_categories().patch(request, &self.opt.arg_profile_id, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -5486,36 +5833,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request.account_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5532,8 +5857,42 @@ impl Engine { fn _content_categories_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::ContentCategory::default(); - let mut call = self.hub.content_categories().update(&request, &self.opt.arg_profile_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request.account_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.content_categories().update(request, &self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -5555,36 +5914,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request.account_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5628,6 +5965,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5671,6 +6011,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5687,43 +6030,30 @@ impl Engine { fn _creative_assets_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::CreativeAssetMetadata::default(); - let mut call = self.hub.creative_assets().insert(&request, &self.opt.arg_profile_id, &self.opt.arg_advertiser_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::CreativeAssetMetadata::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_asset_identifier_init(request: &mut api::CreativeAssetMetadata) { if request.asset_identifier.is_none() { request.asset_identifier = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "warned-validation-rules" => { if request.warned_validation_rules.is_none() { request.warned_validation_rules = Some(Default::default()); @@ -5748,10 +6078,32 @@ impl Engine { request.asset_identifier.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.creative_assets().insert(request, &self.opt.arg_profile_id, &self.opt.arg_advertiser_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = if self.opt.cmd_simple { "simple" @@ -5766,6 +6118,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -5810,6 +6165,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -5851,6 +6209,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5867,8 +6228,39 @@ impl Engine { fn _creative_field_values_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::CreativeFieldValue::default(); - let mut call = self.hub.creative_field_values().insert(&request, &self.opt.arg_profile_id, &self.opt.arg_creative_field_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "value" => { + request.value = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.creative_field_values().insert(request, &self.opt.arg_profile_id, &self.opt.arg_creative_field_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -5890,33 +6282,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "value" => { - request.value = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5978,6 +6351,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5994,8 +6370,39 @@ impl Engine { fn _creative_field_values_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::CreativeFieldValue::default(); - let mut call = self.hub.creative_field_values().patch(&request, &self.opt.arg_profile_id, &self.opt.arg_creative_field_id, &self.opt.arg_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "value" => { + request.value = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.creative_field_values().patch(request, &self.opt.arg_profile_id, &self.opt.arg_creative_field_id, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -6017,33 +6424,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "value" => { - request.value = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6060,8 +6448,39 @@ impl Engine { fn _creative_field_values_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::CreativeFieldValue::default(); - let mut call = self.hub.creative_field_values().update(&request, &self.opt.arg_profile_id, &self.opt.arg_creative_field_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "value" => { + request.value = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.creative_field_values().update(request, &self.opt.arg_profile_id, &self.opt.arg_creative_field_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -6083,33 +6502,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "value" => { - request.value = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6153,6 +6553,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -6194,6 +6597,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6210,43 +6616,30 @@ impl Engine { fn _creative_fields_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::CreativeField::default(); - let mut call = self.hub.creative_fields().insert(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::CreativeField::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::CreativeField) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -6292,15 +6685,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.creative_fields().insert(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6365,6 +6783,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6381,43 +6802,30 @@ impl Engine { fn _creative_fields_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::CreativeField::default(); - let mut call = self.hub.creative_fields().patch(&request, &self.opt.arg_profile_id, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::CreativeField::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::CreativeField) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -6463,15 +6871,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.creative_fields().patch(request, &self.opt.arg_profile_id, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6488,43 +6921,30 @@ impl Engine { fn _creative_fields_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::CreativeField::default(); - let mut call = self.hub.creative_fields().update(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::CreativeField::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::CreativeField) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -6570,15 +6990,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.creative_fields().update(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6622,6 +7067,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6638,43 +7086,30 @@ impl Engine { fn _creative_groups_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::CreativeGroup::default(); - let mut call = self.hub.creative_groups().insert(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::CreativeGroup::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::CreativeGroup) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -6723,15 +7158,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.creative_groups().insert(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6799,6 +7259,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6815,43 +7278,30 @@ impl Engine { fn _creative_groups_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::CreativeGroup::default(); - let mut call = self.hub.creative_groups().patch(&request, &self.opt.arg_profile_id, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::CreativeGroup::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::CreativeGroup) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -6900,15 +7350,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.creative_groups().patch(request, &self.opt.arg_profile_id, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6925,43 +7400,30 @@ impl Engine { fn _creative_groups_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::CreativeGroup::default(); - let mut call = self.hub.creative_groups().update(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::CreativeGroup::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::CreativeGroup) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -7010,15 +7472,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.creative_groups().update(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7062,6 +7549,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7078,36 +7568,23 @@ impl Engine { fn _creatives_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Creative::default(); - let mut call = self.hub.creatives().insert(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Creative::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_backup_image_target_window_init(request: &mut api::Creative) { if request.backup_image_target_window.is_none() { request.backup_image_target_window = Some(Default::default()); @@ -7144,7 +7621,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "artwork-type" => { request.artwork_type = Some(value.unwrap_or("").to_string()); }, @@ -7429,15 +7906,40 @@ impl Engine { request.skippable = Some(arg_from_str(value.unwrap_or("false"), err, "skippable", "boolean")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.creatives().insert(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7529,6 +8031,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7545,36 +8050,23 @@ impl Engine { fn _creatives_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Creative::default(); - let mut call = self.hub.creatives().patch(&request, &self.opt.arg_profile_id, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Creative::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_backup_image_target_window_init(request: &mut api::Creative) { if request.backup_image_target_window.is_none() { request.backup_image_target_window = Some(Default::default()); @@ -7611,7 +8103,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "artwork-type" => { request.artwork_type = Some(value.unwrap_or("").to_string()); }, @@ -7896,15 +8388,40 @@ impl Engine { request.skippable = Some(arg_from_str(value.unwrap_or("false"), err, "skippable", "boolean")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.creatives().patch(request, &self.opt.arg_profile_id, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7921,36 +8438,23 @@ impl Engine { fn _creatives_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Creative::default(); - let mut call = self.hub.creatives().update(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Creative::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_backup_image_target_window_init(request: &mut api::Creative) { if request.backup_image_target_window.is_none() { request.backup_image_target_window = Some(Default::default()); @@ -7987,7 +8491,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "artwork-type" => { request.artwork_type = Some(value.unwrap_or("").to_string()); }, @@ -8272,15 +8776,40 @@ impl Engine { request.skippable = Some(arg_from_str(value.unwrap_or("false"), err, "skippable", "boolean")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.creatives().update(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -8297,8 +8826,42 @@ impl Engine { fn _dimension_values_query(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::DimensionValueRequest::default(); - let mut call = self.hub.dimension_values().query(&request, &self.opt.arg_profile_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "dimension-name" => { + request.dimension_name = Some(value.unwrap_or("").to_string()); + }, + "start-date" => { + request.start_date = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "end-date" => { + request.end_date = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.dimension_values().query(request, &self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -8326,36 +8889,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "dimension-name" => { - request.dimension_name = Some(value.unwrap_or("").to_string()); - }, - "start-date" => { - request.start_date = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "end-date" => { - request.end_date = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -8399,6 +8940,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -8463,6 +9007,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -8506,6 +9053,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -8522,36 +9072,23 @@ impl Engine { fn _directory_sites_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::DirectorySite::default(); - let mut call = self.hub.directory_sites().insert(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::DirectorySite::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_id_dimension_value_init(request: &mut api::DirectorySite) { if request.id_dimension_value.is_none() { request.id_dimension_value = Some(Default::default()); @@ -8571,7 +9108,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -8688,15 +9225,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.directory_sites().insert(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -8779,6 +9341,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -8822,6 +9387,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -8863,6 +9431,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -8879,36 +9450,23 @@ impl Engine { fn _event_tags_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::EventTag::default(); - let mut call = self.hub.event_tags().insert(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::EventTag::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::EventTag) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -8921,7 +9479,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -9026,15 +9584,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.event_tags().insert(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -9108,6 +9691,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -9124,36 +9710,23 @@ impl Engine { fn _event_tags_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::EventTag::default(); - let mut call = self.hub.event_tags().patch(&request, &self.opt.arg_profile_id, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::EventTag::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::EventTag) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -9166,7 +9739,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -9271,15 +9844,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.event_tags().patch(request, &self.opt.arg_profile_id, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -9296,36 +9894,23 @@ impl Engine { fn _event_tags_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::EventTag::default(); - let mut call = self.hub.event_tags().update(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::EventTag::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::EventTag) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -9338,7 +9923,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -9443,15 +10028,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.event_tags().update(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -9499,6 +10109,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -9561,6 +10174,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -9604,6 +10220,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -9648,6 +10267,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -9691,6 +10313,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -9707,36 +10332,23 @@ impl Engine { fn _floodlight_activities_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::FloodlightActivity::default(); - let mut call = self.hub.floodlight_activities().insert(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::FloodlightActivity::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::FloodlightActivity) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -9755,7 +10367,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "tag-string" => { request.tag_string = Some(value.unwrap_or("").to_string()); }, @@ -9919,15 +10531,40 @@ impl Engine { request.floodlight_activity_group_type = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.floodlight_activities().insert(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -10010,6 +10647,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -10026,36 +10666,23 @@ impl Engine { fn _floodlight_activities_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::FloodlightActivity::default(); - let mut call = self.hub.floodlight_activities().patch(&request, &self.opt.arg_profile_id, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::FloodlightActivity::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::FloodlightActivity) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -10074,7 +10701,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "tag-string" => { request.tag_string = Some(value.unwrap_or("").to_string()); }, @@ -10238,15 +10865,40 @@ impl Engine { request.floodlight_activity_group_type = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.floodlight_activities().patch(request, &self.opt.arg_profile_id, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -10263,36 +10915,23 @@ impl Engine { fn _floodlight_activities_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::FloodlightActivity::default(); - let mut call = self.hub.floodlight_activities().update(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::FloodlightActivity::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::FloodlightActivity) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -10311,7 +10950,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "tag-string" => { request.tag_string = Some(value.unwrap_or("").to_string()); }, @@ -10475,15 +11114,40 @@ impl Engine { request.floodlight_activity_group_type = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.floodlight_activities().update(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -10527,6 +11191,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -10568,6 +11235,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -10584,36 +11254,23 @@ impl Engine { fn _floodlight_activity_groups_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::FloodlightActivityGroup::default(); - let mut call = self.hub.floodlight_activity_groups().insert(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::FloodlightActivityGroup::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::FloodlightActivityGroup) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -10632,7 +11289,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -10737,15 +11394,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.floodlight_activity_groups().insert(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -10816,6 +11498,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -10832,36 +11517,23 @@ impl Engine { fn _floodlight_activity_groups_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::FloodlightActivityGroup::default(); - let mut call = self.hub.floodlight_activity_groups().patch(&request, &self.opt.arg_profile_id, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::FloodlightActivityGroup::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::FloodlightActivityGroup) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -10880,7 +11552,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -10985,15 +11657,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.floodlight_activity_groups().patch(request, &self.opt.arg_profile_id, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -11010,36 +11707,23 @@ impl Engine { fn _floodlight_activity_groups_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::FloodlightActivityGroup::default(); - let mut call = self.hub.floodlight_activity_groups().update(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::FloodlightActivityGroup::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::FloodlightActivityGroup) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -11058,7 +11742,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -11163,15 +11847,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.floodlight_activity_groups().update(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -11215,6 +11924,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -11261,6 +11973,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -11277,36 +11992,23 @@ impl Engine { fn _floodlight_configurations_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::FloodlightConfiguration::default(); - let mut call = self.hub.floodlight_configurations().patch(&request, &self.opt.arg_profile_id, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::FloodlightConfiguration::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::FloodlightConfiguration) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -11337,7 +12039,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "natural-search-conversion-attribution-option" => { request.natural_search_conversion_attribution_option = Some(value.unwrap_or("").to_string()); }, @@ -11454,15 +12156,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.floodlight_configurations().patch(request, &self.opt.arg_profile_id, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -11479,36 +12206,23 @@ impl Engine { fn _floodlight_configurations_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::FloodlightConfiguration::default(); - let mut call = self.hub.floodlight_configurations().update(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::FloodlightConfiguration::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::FloodlightConfiguration) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -11539,7 +12253,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "natural-search-conversion-attribution-option" => { request.natural_search_conversion_attribution_option = Some(value.unwrap_or("").to_string()); }, @@ -11656,15 +12370,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.floodlight_configurations().update(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -11708,6 +12447,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -11775,6 +12517,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -11818,6 +12563,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -11859,6 +12607,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -11875,8 +12626,45 @@ impl Engine { fn _landing_pages_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::LandingPage::default(); - let mut call = self.hub.landing_pages().insert(&request, &self.opt.arg_profile_id, &self.opt.arg_campaign_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "default" => { + request.default = Some(arg_from_str(value.unwrap_or("false"), err, "default", "boolean")); + }, + "url" => { + request.url = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.landing_pages().insert(request, &self.opt.arg_profile_id, &self.opt.arg_campaign_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -11898,39 +12686,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "default" => { - request.default = Some(arg_from_str(value.unwrap_or("false"), err, "default", "boolean")); - }, - "url" => { - request.url = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -11974,6 +12737,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -11990,8 +12756,45 @@ impl Engine { fn _landing_pages_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::LandingPage::default(); - let mut call = self.hub.landing_pages().patch(&request, &self.opt.arg_profile_id, &self.opt.arg_campaign_id, &self.opt.arg_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "default" => { + request.default = Some(arg_from_str(value.unwrap_or("false"), err, "default", "boolean")); + }, + "url" => { + request.url = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.landing_pages().patch(request, &self.opt.arg_profile_id, &self.opt.arg_campaign_id, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -12013,39 +12816,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "default" => { - request.default = Some(arg_from_str(value.unwrap_or("false"), err, "default", "boolean")); - }, - "url" => { - request.url = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -12062,8 +12840,45 @@ impl Engine { fn _landing_pages_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::LandingPage::default(); - let mut call = self.hub.landing_pages().update(&request, &self.opt.arg_profile_id, &self.opt.arg_campaign_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "default" => { + request.default = Some(arg_from_str(value.unwrap_or("false"), err, "default", "boolean")); + }, + "url" => { + request.url = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.landing_pages().update(request, &self.opt.arg_profile_id, &self.opt.arg_campaign_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -12085,39 +12900,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "default" => { - request.default = Some(arg_from_str(value.unwrap_or("false"), err, "default", "boolean")); - }, - "url" => { - request.url = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -12161,6 +12951,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -12204,6 +12997,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -12247,6 +13043,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -12290,6 +13089,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -12333,6 +13135,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -12376,6 +13181,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -12419,6 +13227,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -12462,6 +13273,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -12532,6 +13346,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -12575,6 +13392,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -12639,6 +13459,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -12682,6 +13505,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -12698,36 +13524,23 @@ impl Engine { fn _placement_groups_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::PlacementGroup::default(); - let mut call = self.hub.placement_groups().insert(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::PlacementGroup::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::PlacementGroup) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -12788,7 +13601,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "comment" => { request.comment = Some(value.unwrap_or("").to_string()); }, @@ -13072,15 +13885,40 @@ impl Engine { request.pricing_schedule.as_mut().unwrap().floodlight_activity_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.placement_groups().insert(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -13169,6 +14007,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -13185,36 +14026,23 @@ impl Engine { fn _placement_groups_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::PlacementGroup::default(); - let mut call = self.hub.placement_groups().patch(&request, &self.opt.arg_profile_id, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::PlacementGroup::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::PlacementGroup) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -13275,7 +14103,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "comment" => { request.comment = Some(value.unwrap_or("").to_string()); }, @@ -13559,15 +14387,40 @@ impl Engine { request.pricing_schedule.as_mut().unwrap().floodlight_activity_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.placement_groups().patch(request, &self.opt.arg_profile_id, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -13584,36 +14437,23 @@ impl Engine { fn _placement_groups_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::PlacementGroup::default(); - let mut call = self.hub.placement_groups().update(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::PlacementGroup::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::PlacementGroup) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -13674,7 +14514,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "comment" => { request.comment = Some(value.unwrap_or("").to_string()); }, @@ -13958,15 +14798,40 @@ impl Engine { request.pricing_schedule.as_mut().unwrap().floodlight_activity_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.placement_groups().update(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -14010,6 +14875,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -14051,6 +14919,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -14067,8 +14938,42 @@ impl Engine { fn _placement_strategies_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::PlacementStrategy::default(); - let mut call = self.hub.placement_strategies().insert(&request, &self.opt.arg_profile_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request.account_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.placement_strategies().insert(request, &self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -14090,36 +14995,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request.account_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -14181,6 +15064,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -14197,8 +15083,42 @@ impl Engine { fn _placement_strategies_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::PlacementStrategy::default(); - let mut call = self.hub.placement_strategies().patch(&request, &self.opt.arg_profile_id, &self.opt.arg_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request.account_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.placement_strategies().patch(request, &self.opt.arg_profile_id, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -14220,36 +15140,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request.account_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -14266,8 +15164,42 @@ impl Engine { fn _placement_strategies_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::PlacementStrategy::default(); - let mut call = self.hub.placement_strategies().update(&request, &self.opt.arg_profile_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request.account_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.placement_strategies().update(request, &self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -14289,36 +15221,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request.account_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -14371,6 +15281,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -14414,6 +15327,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -14430,36 +15346,23 @@ impl Engine { fn _placements_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Placement::default(); - let mut call = self.hub.placements().insert(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Placement::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::Placement) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -14538,7 +15441,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "comment" => { request.comment = Some(value.unwrap_or("").to_string()); }, @@ -14864,15 +15767,40 @@ impl Engine { request.pricing_schedule.as_mut().unwrap().floodlight_activity_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.placements().insert(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -14970,6 +15898,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -14986,36 +15917,23 @@ impl Engine { fn _placements_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Placement::default(); - let mut call = self.hub.placements().patch(&request, &self.opt.arg_profile_id, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Placement::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::Placement) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -15094,7 +16012,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "comment" => { request.comment = Some(value.unwrap_or("").to_string()); }, @@ -15420,15 +16338,40 @@ impl Engine { request.pricing_schedule.as_mut().unwrap().floodlight_activity_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.placements().patch(request, &self.opt.arg_profile_id, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -15445,36 +16388,23 @@ impl Engine { fn _placements_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Placement::default(); - let mut call = self.hub.placements().update(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Placement::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::Placement) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -15553,7 +16483,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "comment" => { request.comment = Some(value.unwrap_or("").to_string()); }, @@ -15879,15 +16809,40 @@ impl Engine { request.pricing_schedule.as_mut().unwrap().floodlight_activity_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.placements().update(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -15931,6 +16886,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -15974,6 +16932,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -16017,6 +16978,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -16060,6 +17024,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -16103,6 +17070,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -16167,6 +17137,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -16210,6 +17183,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -16253,6 +17229,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -16269,8 +17248,48 @@ impl Engine { fn _remarketing_list_shares_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::RemarketingListShare::default(); - let mut call = self.hub.remarketing_list_shares().patch(&request, &self.opt.arg_profile_id, &self.opt.arg_remarketing_list_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "shared-advertiser-ids" => { + if request.shared_advertiser_ids.is_none() { + request.shared_advertiser_ids = Some(Default::default()); + } + request.shared_advertiser_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "remarketing-list-id" => { + request.remarketing_list_id = Some(value.unwrap_or("").to_string()); + }, + "shared-account-ids" => { + if request.shared_account_ids.is_none() { + request.shared_account_ids = Some(Default::default()); + } + request.shared_account_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.remarketing_list_shares().patch(request, &self.opt.arg_profile_id, &self.opt.arg_remarketing_list_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -16292,42 +17311,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "shared-advertiser-ids" => { - if request.shared_advertiser_ids.is_none() { - request.shared_advertiser_ids = Some(Default::default()); - } - request.shared_advertiser_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "remarketing-list-id" => { - request.remarketing_list_id = Some(value.unwrap_or("").to_string()); - }, - "shared-account-ids" => { - if request.shared_account_ids.is_none() { - request.shared_account_ids = Some(Default::default()); - } - request.shared_account_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -16344,8 +17335,48 @@ impl Engine { fn _remarketing_list_shares_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::RemarketingListShare::default(); - let mut call = self.hub.remarketing_list_shares().update(&request, &self.opt.arg_profile_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "shared-advertiser-ids" => { + if request.shared_advertiser_ids.is_none() { + request.shared_advertiser_ids = Some(Default::default()); + } + request.shared_advertiser_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "remarketing-list-id" => { + request.remarketing_list_id = Some(value.unwrap_or("").to_string()); + }, + "shared-account-ids" => { + if request.shared_account_ids.is_none() { + request.shared_account_ids = Some(Default::default()); + } + request.shared_account_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.remarketing_list_shares().update(request, &self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -16367,42 +17398,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "shared-advertiser-ids" => { - if request.shared_advertiser_ids.is_none() { - request.shared_advertiser_ids = Some(Default::default()); - } - request.shared_advertiser_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "remarketing-list-id" => { - request.remarketing_list_id = Some(value.unwrap_or("").to_string()); - }, - "shared-account-ids" => { - if request.shared_account_ids.is_none() { - request.shared_account_ids = Some(Default::default()); - } - request.shared_account_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -16446,6 +17449,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -16462,36 +17468,23 @@ impl Engine { fn _remarketing_lists_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::RemarketingList::default(); - let mut call = self.hub.remarketing_lists().insert(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::RemarketingList::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::RemarketingList) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -16504,7 +17497,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "list-population-rule.floodlight-activity-name" => { request_list_population_rule_init(&mut request); request.list_population_rule.as_mut().unwrap().floodlight_activity_name = Some(value.unwrap_or("").to_string()); @@ -16582,15 +17575,40 @@ impl Engine { request.list_source = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.remarketing_lists().insert(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -16655,6 +17673,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -16671,36 +17692,23 @@ impl Engine { fn _remarketing_lists_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::RemarketingList::default(); - let mut call = self.hub.remarketing_lists().patch(&request, &self.opt.arg_profile_id, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::RemarketingList::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::RemarketingList) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -16713,7 +17721,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "list-population-rule.floodlight-activity-name" => { request_list_population_rule_init(&mut request); request.list_population_rule.as_mut().unwrap().floodlight_activity_name = Some(value.unwrap_or("").to_string()); @@ -16791,15 +17799,40 @@ impl Engine { request.list_source = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.remarketing_lists().patch(request, &self.opt.arg_profile_id, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -16816,36 +17849,23 @@ impl Engine { fn _remarketing_lists_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::RemarketingList::default(); - let mut call = self.hub.remarketing_lists().update(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::RemarketingList::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_advertiser_id_dimension_value_init(request: &mut api::RemarketingList) { if request.advertiser_id_dimension_value.is_none() { request.advertiser_id_dimension_value = Some(Default::default()); @@ -16858,7 +17878,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "list-population-rule.floodlight-activity-name" => { request_list_population_rule_init(&mut request); request.list_population_rule.as_mut().unwrap().floodlight_activity_name = Some(value.unwrap_or("").to_string()); @@ -16936,33 +17956,11 @@ impl Engine { request.list_source = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _reports_compatible_fields_query(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::Report::default(); - let mut call = self.hub.reports().compatible_fields_query(&request, &self.opt.arg_profile_id); + let mut call = self.hub.remarketing_lists().update(request, &self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -16984,13 +17982,47 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _reports_compatible_fields_query(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::Report::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_criteria_activities_init(request: &mut api::Report) { request_criteria_init(request); if request.criteria.as_mut().unwrap().activities.is_none() { @@ -17124,7 +18156,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "criteria.activities.kind" => { request_criteria_activities_init(&mut request); request.criteria.as_mut().unwrap().activities.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); @@ -17480,15 +18512,40 @@ impl Engine { request.cross_dimension_reach_criteria.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.reports().compatible_fields_query(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -17532,6 +18589,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -17577,6 +18637,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -17636,6 +18699,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -17679,6 +18745,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -17695,36 +18764,23 @@ impl Engine { fn _reports_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Report::default(); - let mut call = self.hub.reports().insert(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Report::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_criteria_activities_init(request: &mut api::Report) { request_criteria_init(request); if request.criteria.as_mut().unwrap().activities.is_none() { @@ -17858,7 +18914,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "criteria.activities.kind" => { request_criteria_activities_init(&mut request); request.criteria.as_mut().unwrap().activities.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); @@ -18214,15 +19270,40 @@ impl Engine { request.cross_dimension_reach_criteria.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.reports().insert(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -18281,6 +19362,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -18297,36 +19381,23 @@ impl Engine { fn _reports_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Report::default(); - let mut call = self.hub.reports().patch(&request, &self.opt.arg_profile_id, &self.opt.arg_report_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Report::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_criteria_activities_init(request: &mut api::Report) { request_criteria_init(request); if request.criteria.as_mut().unwrap().activities.is_none() { @@ -18460,7 +19531,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "criteria.activities.kind" => { request_criteria_activities_init(&mut request); request.criteria.as_mut().unwrap().activities.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); @@ -18816,15 +19887,40 @@ impl Engine { request.cross_dimension_reach_criteria.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.reports().patch(request, &self.opt.arg_profile_id, &self.opt.arg_report_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -18871,6 +19967,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -18887,36 +19986,23 @@ impl Engine { fn _reports_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Report::default(); - let mut call = self.hub.reports().update(&request, &self.opt.arg_profile_id, &self.opt.arg_report_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Report::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_criteria_activities_init(request: &mut api::Report) { request_criteria_init(request); if request.criteria.as_mut().unwrap().activities.is_none() { @@ -19050,7 +20136,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "criteria.activities.kind" => { request_criteria_activities_init(&mut request); request.criteria.as_mut().unwrap().activities.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); @@ -19406,15 +20492,40 @@ impl Engine { request.cross_dimension_reach_criteria.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.reports().update(request, &self.opt.arg_profile_id, &self.opt.arg_report_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -19458,6 +20569,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -19474,36 +20588,23 @@ impl Engine { fn _sites_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Site::default(); - let mut call = self.hub.sites().insert(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Site::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_directory_site_id_dimension_value_init(request: &mut api::Site) { if request.directory_site_id_dimension_value.is_none() { request.directory_site_id_dimension_value = Some(Default::default()); @@ -19543,7 +20644,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -19666,15 +20767,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.sites().insert(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -19763,6 +20889,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -19779,36 +20908,23 @@ impl Engine { fn _sites_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Site::default(); - let mut call = self.hub.sites().patch(&request, &self.opt.arg_profile_id, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Site::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_directory_site_id_dimension_value_init(request: &mut api::Site) { if request.directory_site_id_dimension_value.is_none() { request.directory_site_id_dimension_value = Some(Default::default()); @@ -19848,7 +20964,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -19971,15 +21087,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.sites().patch(request, &self.opt.arg_profile_id, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -19996,36 +21137,23 @@ impl Engine { fn _sites_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Site::default(); - let mut call = self.hub.sites().update(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Site::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_directory_site_id_dimension_value_init(request: &mut api::Site) { if request.directory_site_id_dimension_value.is_none() { request.directory_site_id_dimension_value = Some(Default::default()); @@ -20065,7 +21193,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -20188,15 +21316,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.sites().update(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -20240,6 +21393,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -20256,8 +21412,45 @@ impl Engine { fn _sizes_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Size::default(); - let mut call = self.hub.sizes().insert(&request, &self.opt.arg_profile_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "width" => { + request.width = Some(arg_from_str(value.unwrap_or("-0"), err, "width", "integer")); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "iab" => { + request.iab = Some(arg_from_str(value.unwrap_or("false"), err, "iab", "boolean")); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "height" => { + request.height = Some(arg_from_str(value.unwrap_or("-0"), err, "height", "integer")); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.sizes().insert(request, &self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -20279,39 +21472,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "width" => { - request.width = Some(arg_from_str(value.unwrap_or("-0"), err, "width", "integer")); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "iab" => { - request.iab = Some(arg_from_str(value.unwrap_or("false"), err, "iab", "boolean")); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "height" => { - request.height = Some(arg_from_str(value.unwrap_or("-0"), err, "height", "integer")); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -20367,6 +21535,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -20410,6 +21581,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -20426,8 +21600,48 @@ impl Engine { fn _subaccounts_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Subaccount::default(); - let mut call = self.hub.subaccounts().insert(&request, &self.opt.arg_profile_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "available-permission-ids" => { + if request.available_permission_ids.is_none() { + request.available_permission_ids = Some(Default::default()); + } + request.available_permission_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request.account_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.subaccounts().insert(request, &self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -20449,42 +21663,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "available-permission-ids" => { - if request.available_permission_ids.is_none() { - request.available_permission_ids = Some(Default::default()); - } - request.available_permission_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request.account_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -20546,6 +21732,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -20562,8 +21751,48 @@ impl Engine { fn _subaccounts_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Subaccount::default(); - let mut call = self.hub.subaccounts().patch(&request, &self.opt.arg_profile_id, &self.opt.arg_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "available-permission-ids" => { + if request.available_permission_ids.is_none() { + request.available_permission_ids = Some(Default::default()); + } + request.available_permission_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request.account_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.subaccounts().patch(request, &self.opt.arg_profile_id, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -20585,42 +21814,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "available-permission-ids" => { - if request.available_permission_ids.is_none() { - request.available_permission_ids = Some(Default::default()); - } - request.available_permission_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request.account_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -20637,8 +21838,48 @@ impl Engine { fn _subaccounts_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Subaccount::default(); - let mut call = self.hub.subaccounts().update(&request, &self.opt.arg_profile_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "available-permission-ids" => { + if request.available_permission_ids.is_none() { + request.available_permission_ids = Some(Default::default()); + } + request.available_permission_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request.account_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.subaccounts().update(request, &self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -20660,42 +21901,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "available-permission-ids" => { - if request.available_permission_ids.is_none() { - request.available_permission_ids = Some(Default::default()); - } - request.available_permission_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request.account_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -20739,6 +21952,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -20800,6 +22016,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -20843,6 +22062,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -20886,6 +22108,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -20929,6 +22154,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -20972,6 +22200,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -21015,6 +22246,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -21061,6 +22295,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -21104,6 +22341,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -21145,6 +22385,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -21161,37 +22404,24 @@ impl Engine { fn _user_roles_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::UserRole::default(); - let mut call = self.hub.user_roles().insert(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::UserRole::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "default-user-role" => { request.default_user_role = Some(arg_from_str(value.unwrap_or("false"), err, "default-user-role", "boolean")); }, @@ -21214,15 +22444,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.user_roles().insert(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -21290,6 +22545,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -21306,37 +22564,24 @@ impl Engine { fn _user_roles_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::UserRole::default(); - let mut call = self.hub.user_roles().patch(&request, &self.opt.arg_profile_id, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::UserRole::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "default-user-role" => { request.default_user_role = Some(arg_from_str(value.unwrap_or("false"), err, "default-user-role", "boolean")); }, @@ -21359,15 +22604,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.user_roles().patch(request, &self.opt.arg_profile_id, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -21384,37 +22654,24 @@ impl Engine { fn _user_roles_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::UserRole::default(); - let mut call = self.hub.user_roles().update(&request, &self.opt.arg_profile_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::UserRole::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "default-user-role" => { request.default_user_role = Some(arg_from_str(value.unwrap_or("false"), err, "default-user-role", "boolean")); }, @@ -21437,15 +22694,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.user_roles().update(request, &self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -22193,6 +23475,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -22200,8 +23483,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/dfareporting2d1/Cargo.toml b/gen/dfareporting2d1/Cargo.toml index 0d9c68c716..8dfebc568d 100644 --- a/gen/dfareporting2d1/Cargo.toml +++ b/gen/dfareporting2d1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-dfareporting2d1" -version = "0.1.5+20150326" +version = "0.1.6+20150326" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with dfareporting (protocol v2.1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/dfareporting2d1" diff --git a/gen/dfareporting2d1/README.md b/gen/dfareporting2d1/README.md index 3ea0866d1b..5601ca3e94 100644 --- a/gen/dfareporting2d1/README.md +++ b/gen/dfareporting2d1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-dfareporting2d1` library allows access to all features of the *Google dfareporting* service. -This documentation was generated from *dfareporting* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *dfareporting:v2.1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *dfareporting* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *dfareporting:v2.1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *dfareporting* *v2d1* API can be found at the [official documentation site](https://developers.google.com/doubleclick-advertisers/reporting/). @@ -230,14 +230,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/dfareporting2d1/src/cmn.rs b/gen/dfareporting2d1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/dfareporting2d1/src/cmn.rs +++ b/gen/dfareporting2d1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/dfareporting2d1/src/lib.rs b/gen/dfareporting2d1/src/lib.rs index baa15f8570..e4cb861b7b 100644 --- a/gen/dfareporting2d1/src/lib.rs +++ b/gen/dfareporting2d1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *dfareporting* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *dfareporting:v2.1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *dfareporting* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *dfareporting:v2.1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *dfareporting* *v2d1* API can be found at the //! [official documentation site](https://developers.google.com/doubleclick-advertisers/reporting/). @@ -231,14 +231,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -326,7 +327,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -409,14 +410,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -437,7 +439,7 @@ impl<'a, C, A> Dfareporting<C, A> Dfareporting { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -608,7 +610,7 @@ impl<'a, C, A> Dfareporting<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -7091,10 +7093,10 @@ impl<'a, C, A> CreativeFieldValueMethods<'a, C, A> { /// * `profileId` - User profile ID associated with this request. /// * `creativeFieldId` - Creative field ID for this creative field value. /// * `id` - Creative Field Value ID - pub fn patch(&self, request: &CreativeFieldValue, profile_id: &str, creative_field_id: &str, id: &str) -> CreativeFieldValuePatchCall<'a, C, A> { + pub fn patch(&self, request: CreativeFieldValue, profile_id: &str, creative_field_id: &str, id: &str) -> CreativeFieldValuePatchCall<'a, C, A> { CreativeFieldValuePatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _creative_field_id: creative_field_id.to_string(), _id: id.to_string(), @@ -7155,10 +7157,10 @@ impl<'a, C, A> CreativeFieldValueMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `creativeFieldId` - Creative field ID for this creative field value. - pub fn insert(&self, request: &CreativeFieldValue, profile_id: &str, creative_field_id: &str) -> CreativeFieldValueInsertCall<'a, C, A> { + pub fn insert(&self, request: CreativeFieldValue, profile_id: &str, creative_field_id: &str) -> CreativeFieldValueInsertCall<'a, C, A> { CreativeFieldValueInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _creative_field_id: creative_field_id.to_string(), _delegate: Default::default(), @@ -7176,10 +7178,10 @@ impl<'a, C, A> CreativeFieldValueMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `creativeFieldId` - Creative field ID for this creative field value. - pub fn update(&self, request: &CreativeFieldValue, profile_id: &str, creative_field_id: &str) -> CreativeFieldValueUpdateCall<'a, C, A> { + pub fn update(&self, request: CreativeFieldValue, profile_id: &str, creative_field_id: &str) -> CreativeFieldValueUpdateCall<'a, C, A> { CreativeFieldValueUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _creative_field_id: creative_field_id.to_string(), _delegate: Default::default(), @@ -7262,10 +7264,10 @@ impl<'a, C, A> CreativeFieldMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn update(&self, request: &CreativeField, profile_id: &str) -> CreativeFieldUpdateCall<'a, C, A> { + pub fn update(&self, request: CreativeField, profile_id: &str) -> CreativeFieldUpdateCall<'a, C, A> { CreativeFieldUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -7343,10 +7345,10 @@ impl<'a, C, A> CreativeFieldMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn insert(&self, request: &CreativeField, profile_id: &str) -> CreativeFieldInsertCall<'a, C, A> { + pub fn insert(&self, request: CreativeField, profile_id: &str) -> CreativeFieldInsertCall<'a, C, A> { CreativeFieldInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -7363,10 +7365,10 @@ impl<'a, C, A> CreativeFieldMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Creative Field ID - pub fn patch(&self, request: &CreativeField, profile_id: &str, id: &str) -> CreativeFieldPatchCall<'a, C, A> { + pub fn patch(&self, request: CreativeField, profile_id: &str, id: &str) -> CreativeFieldPatchCall<'a, C, A> { CreativeFieldPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -7424,10 +7426,10 @@ impl<'a, C, A> UserRoleMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn insert(&self, request: &UserRole, profile_id: &str) -> UserRoleInsertCall<'a, C, A> { + pub fn insert(&self, request: UserRole, profile_id: &str) -> UserRoleInsertCall<'a, C, A> { UserRoleInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -7462,10 +7464,10 @@ impl<'a, C, A> UserRoleMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn update(&self, request: &UserRole, profile_id: &str) -> UserRoleUpdateCall<'a, C, A> { + pub fn update(&self, request: UserRole, profile_id: &str) -> UserRoleUpdateCall<'a, C, A> { UserRoleUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -7501,10 +7503,10 @@ impl<'a, C, A> UserRoleMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - User role ID. - pub fn patch(&self, request: &UserRole, profile_id: &str, id: &str) -> UserRolePatchCall<'a, C, A> { + pub fn patch(&self, request: UserRole, profile_id: &str, id: &str) -> UserRolePatchCall<'a, C, A> { UserRolePatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -7686,10 +7688,10 @@ impl<'a, C, A> LandingPageMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `campaignId` - Landing page campaign ID. - pub fn update(&self, request: &LandingPage, profile_id: &str, campaign_id: &str) -> LandingPageUpdateCall<'a, C, A> { + pub fn update(&self, request: LandingPage, profile_id: &str, campaign_id: &str) -> LandingPageUpdateCall<'a, C, A> { LandingPageUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _campaign_id: campaign_id.to_string(), _delegate: Default::default(), @@ -7726,10 +7728,10 @@ impl<'a, C, A> LandingPageMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `campaignId` - Landing page campaign ID. - pub fn insert(&self, request: &LandingPage, profile_id: &str, campaign_id: &str) -> LandingPageInsertCall<'a, C, A> { + pub fn insert(&self, request: LandingPage, profile_id: &str, campaign_id: &str) -> LandingPageInsertCall<'a, C, A> { LandingPageInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _campaign_id: campaign_id.to_string(), _delegate: Default::default(), @@ -7748,10 +7750,10 @@ impl<'a, C, A> LandingPageMethods<'a, C, A> { /// * `profileId` - User profile ID associated with this request. /// * `campaignId` - Landing page campaign ID. /// * `id` - Landing page ID. - pub fn patch(&self, request: &LandingPage, profile_id: &str, campaign_id: &str, id: &str) -> LandingPagePatchCall<'a, C, A> { + pub fn patch(&self, request: LandingPage, profile_id: &str, campaign_id: &str, id: &str) -> LandingPagePatchCall<'a, C, A> { LandingPagePatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _campaign_id: campaign_id.to_string(), _id: id.to_string(), @@ -7832,10 +7834,10 @@ impl<'a, C, A> CreativeAssetMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `advertiserId` - Advertiser ID of this creative. This is a required field. - pub fn insert(&self, request: &CreativeAssetMetadata, profile_id: &str, advertiser_id: &str) -> CreativeAssetInsertCall<'a, C, A> { + pub fn insert(&self, request: CreativeAssetMetadata, profile_id: &str, advertiser_id: &str) -> CreativeAssetInsertCall<'a, C, A> { CreativeAssetInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _advertiser_id: advertiser_id.to_string(), _delegate: Default::default(), @@ -7894,10 +7896,10 @@ impl<'a, C, A> CampaignCreativeAssociationMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `campaignId` - Campaign ID in this association. - pub fn insert(&self, request: &CampaignCreativeAssociation, profile_id: &str, campaign_id: &str) -> CampaignCreativeAssociationInsertCall<'a, C, A> { + pub fn insert(&self, request: CampaignCreativeAssociation, profile_id: &str, campaign_id: &str) -> CampaignCreativeAssociationInsertCall<'a, C, A> { CampaignCreativeAssociationInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _campaign_id: campaign_id.to_string(), _delegate: Default::default(), @@ -8084,10 +8086,10 @@ impl<'a, C, A> RemarketingListShareMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `remarketingListId` - Remarketing list ID. - pub fn patch(&self, request: &RemarketingListShare, profile_id: &str, remarketing_list_id: &str) -> RemarketingListSharePatchCall<'a, C, A> { + pub fn patch(&self, request: RemarketingListShare, profile_id: &str, remarketing_list_id: &str) -> RemarketingListSharePatchCall<'a, C, A> { RemarketingListSharePatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _remarketing_list_id: remarketing_list_id.to_string(), _delegate: Default::default(), @@ -8104,10 +8106,10 @@ impl<'a, C, A> RemarketingListShareMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn update(&self, request: &RemarketingListShare, profile_id: &str) -> RemarketingListShareUpdateCall<'a, C, A> { + pub fn update(&self, request: RemarketingListShare, profile_id: &str) -> RemarketingListShareUpdateCall<'a, C, A> { RemarketingListShareUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -8185,10 +8187,10 @@ impl<'a, C, A> ReportMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - The DFA user profile ID. /// * `reportId` - The ID of the report. - pub fn patch(&self, request: &Report, profile_id: &str, report_id: &str) -> ReportPatchCall<'a, C, A> { + pub fn patch(&self, request: Report, profile_id: &str, report_id: &str) -> ReportPatchCall<'a, C, A> { ReportPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _report_id: report_id.to_string(), _delegate: Default::default(), @@ -8228,10 +8230,10 @@ impl<'a, C, A> ReportMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - The DFA user profile ID. - pub fn insert(&self, request: &Report, profile_id: &str) -> ReportInsertCall<'a, C, A> { + pub fn insert(&self, request: Report, profile_id: &str) -> ReportInsertCall<'a, C, A> { ReportInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -8248,10 +8250,10 @@ impl<'a, C, A> ReportMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - The DFA user profile ID. /// * `reportId` - The ID of the report. - pub fn update(&self, request: &Report, profile_id: &str, report_id: &str) -> ReportUpdateCall<'a, C, A> { + pub fn update(&self, request: Report, profile_id: &str, report_id: &str) -> ReportUpdateCall<'a, C, A> { ReportUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _report_id: report_id.to_string(), _delegate: Default::default(), @@ -8268,10 +8270,10 @@ impl<'a, C, A> ReportMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - The DFA user profile ID. - pub fn compatible_fields_query(&self, request: &Report, profile_id: &str) -> ReportCompatibleFieldQueryCall<'a, C, A> { + pub fn compatible_fields_query(&self, request: Report, profile_id: &str) -> ReportCompatibleFieldQueryCall<'a, C, A> { ReportCompatibleFieldQueryCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -8409,10 +8411,10 @@ impl<'a, C, A> AdvertiserMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn insert(&self, request: &Advertiser, profile_id: &str) -> AdvertiserInsertCall<'a, C, A> { + pub fn insert(&self, request: Advertiser, profile_id: &str) -> AdvertiserInsertCall<'a, C, A> { AdvertiserInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -8429,10 +8431,10 @@ impl<'a, C, A> AdvertiserMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Advertiser ID. - pub fn patch(&self, request: &Advertiser, profile_id: &str, id: &str) -> AdvertiserPatchCall<'a, C, A> { + pub fn patch(&self, request: Advertiser, profile_id: &str, id: &str) -> AdvertiserPatchCall<'a, C, A> { AdvertiserPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -8478,10 +8480,10 @@ impl<'a, C, A> AdvertiserMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn update(&self, request: &Advertiser, profile_id: &str) -> AdvertiserUpdateCall<'a, C, A> { + pub fn update(&self, request: Advertiser, profile_id: &str) -> AdvertiserUpdateCall<'a, C, A> { AdvertiserUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -8557,10 +8559,10 @@ impl<'a, C, A> DimensionValueMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - The DFA user profile ID. - pub fn query(&self, request: &DimensionValueRequest, profile_id: &str) -> DimensionValueQueryCall<'a, C, A> { + pub fn query(&self, request: DimensionValueRequest, profile_id: &str) -> DimensionValueQueryCall<'a, C, A> { DimensionValueQueryCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _page_token: Default::default(), _max_results: Default::default(), @@ -8658,10 +8660,10 @@ impl<'a, C, A> FloodlightActivityGroupMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Floodlight activity Group ID. - pub fn patch(&self, request: &FloodlightActivityGroup, profile_id: &str, id: &str) -> FloodlightActivityGroupPatchCall<'a, C, A> { + pub fn patch(&self, request: FloodlightActivityGroup, profile_id: &str, id: &str) -> FloodlightActivityGroupPatchCall<'a, C, A> { FloodlightActivityGroupPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -8704,10 +8706,10 @@ impl<'a, C, A> FloodlightActivityGroupMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn insert(&self, request: &FloodlightActivityGroup, profile_id: &str) -> FloodlightActivityGroupInsertCall<'a, C, A> { + pub fn insert(&self, request: FloodlightActivityGroup, profile_id: &str) -> FloodlightActivityGroupInsertCall<'a, C, A> { FloodlightActivityGroupInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -8723,10 +8725,10 @@ impl<'a, C, A> FloodlightActivityGroupMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn update(&self, request: &FloodlightActivityGroup, profile_id: &str) -> FloodlightActivityGroupUpdateCall<'a, C, A> { + pub fn update(&self, request: FloodlightActivityGroup, profile_id: &str) -> FloodlightActivityGroupUpdateCall<'a, C, A> { FloodlightActivityGroupUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -9084,10 +9086,10 @@ impl<'a, C, A> AdMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Ad ID. - pub fn patch(&self, request: &Ad, profile_id: &str, id: &str) -> AdPatchCall<'a, C, A> { + pub fn patch(&self, request: Ad, profile_id: &str, id: &str) -> AdPatchCall<'a, C, A> { AdPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -9104,10 +9106,10 @@ impl<'a, C, A> AdMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn insert(&self, request: &Ad, profile_id: &str) -> AdInsertCall<'a, C, A> { + pub fn insert(&self, request: Ad, profile_id: &str) -> AdInsertCall<'a, C, A> { AdInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -9183,10 +9185,10 @@ impl<'a, C, A> AdMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn update(&self, request: &Ad, profile_id: &str) -> AdUpdateCall<'a, C, A> { + pub fn update(&self, request: Ad, profile_id: &str) -> AdUpdateCall<'a, C, A> { AdUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -9439,10 +9441,10 @@ impl<'a, C, A> AdvertiserGroupMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn insert(&self, request: &AdvertiserGroup, profile_id: &str) -> AdvertiserGroupInsertCall<'a, C, A> { + pub fn insert(&self, request: AdvertiserGroup, profile_id: &str) -> AdvertiserGroupInsertCall<'a, C, A> { AdvertiserGroupInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -9458,10 +9460,10 @@ impl<'a, C, A> AdvertiserGroupMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn update(&self, request: &AdvertiserGroup, profile_id: &str) -> AdvertiserGroupUpdateCall<'a, C, A> { + pub fn update(&self, request: AdvertiserGroup, profile_id: &str) -> AdvertiserGroupUpdateCall<'a, C, A> { AdvertiserGroupUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -9478,10 +9480,10 @@ impl<'a, C, A> AdvertiserGroupMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Advertiser group ID. - pub fn patch(&self, request: &AdvertiserGroup, profile_id: &str, id: &str) -> AdvertiserGroupPatchCall<'a, C, A> { + pub fn patch(&self, request: AdvertiserGroup, profile_id: &str, id: &str) -> AdvertiserGroupPatchCall<'a, C, A> { AdvertiserGroupPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -9558,10 +9560,10 @@ impl<'a, C, A> SiteMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn insert(&self, request: &Site, profile_id: &str) -> SiteInsertCall<'a, C, A> { + pub fn insert(&self, request: Site, profile_id: &str) -> SiteInsertCall<'a, C, A> { SiteInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -9628,10 +9630,10 @@ impl<'a, C, A> SiteMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn update(&self, request: &Site, profile_id: &str) -> SiteUpdateCall<'a, C, A> { + pub fn update(&self, request: Site, profile_id: &str) -> SiteUpdateCall<'a, C, A> { SiteUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -9648,10 +9650,10 @@ impl<'a, C, A> SiteMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Site ID. - pub fn patch(&self, request: &Site, profile_id: &str, id: &str) -> SitePatchCall<'a, C, A> { + pub fn patch(&self, request: Site, profile_id: &str, id: &str) -> SitePatchCall<'a, C, A> { SitePatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -9758,10 +9760,10 @@ impl<'a, C, A> FloodlightActivityMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn insert(&self, request: &FloodlightActivity, profile_id: &str) -> FloodlightActivityInsertCall<'a, C, A> { + pub fn insert(&self, request: FloodlightActivity, profile_id: &str) -> FloodlightActivityInsertCall<'a, C, A> { FloodlightActivityInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -9797,10 +9799,10 @@ impl<'a, C, A> FloodlightActivityMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Floodlight activity ID. - pub fn patch(&self, request: &FloodlightActivity, profile_id: &str, id: &str) -> FloodlightActivityPatchCall<'a, C, A> { + pub fn patch(&self, request: FloodlightActivity, profile_id: &str, id: &str) -> FloodlightActivityPatchCall<'a, C, A> { FloodlightActivityPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -9835,10 +9837,10 @@ impl<'a, C, A> FloodlightActivityMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn update(&self, request: &FloodlightActivity, profile_id: &str) -> FloodlightActivityUpdateCall<'a, C, A> { + pub fn update(&self, request: FloodlightActivity, profile_id: &str) -> FloodlightActivityUpdateCall<'a, C, A> { FloodlightActivityUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -9953,10 +9955,10 @@ impl<'a, C, A> CreativeGroupMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn insert(&self, request: &CreativeGroup, profile_id: &str) -> CreativeGroupInsertCall<'a, C, A> { + pub fn insert(&self, request: CreativeGroup, profile_id: &str) -> CreativeGroupInsertCall<'a, C, A> { CreativeGroupInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -9991,10 +9993,10 @@ impl<'a, C, A> CreativeGroupMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn update(&self, request: &CreativeGroup, profile_id: &str) -> CreativeGroupUpdateCall<'a, C, A> { + pub fn update(&self, request: CreativeGroup, profile_id: &str) -> CreativeGroupUpdateCall<'a, C, A> { CreativeGroupUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -10036,10 +10038,10 @@ impl<'a, C, A> CreativeGroupMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Creative group ID. - pub fn patch(&self, request: &CreativeGroup, profile_id: &str, id: &str) -> CreativeGroupPatchCall<'a, C, A> { + pub fn patch(&self, request: CreativeGroup, profile_id: &str, id: &str) -> CreativeGroupPatchCall<'a, C, A> { CreativeGroupPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -10183,10 +10185,10 @@ impl<'a, C, A> SubaccountMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Subaccount ID. - pub fn patch(&self, request: &Subaccount, profile_id: &str, id: &str) -> SubaccountPatchCall<'a, C, A> { + pub fn patch(&self, request: Subaccount, profile_id: &str, id: &str) -> SubaccountPatchCall<'a, C, A> { SubaccountPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -10203,10 +10205,10 @@ impl<'a, C, A> SubaccountMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn insert(&self, request: &Subaccount, profile_id: &str) -> SubaccountInsertCall<'a, C, A> { + pub fn insert(&self, request: Subaccount, profile_id: &str) -> SubaccountInsertCall<'a, C, A> { SubaccountInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -10245,10 +10247,10 @@ impl<'a, C, A> SubaccountMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn update(&self, request: &Subaccount, profile_id: &str) -> SubaccountUpdateCall<'a, C, A> { + pub fn update(&self, request: Subaccount, profile_id: &str) -> SubaccountUpdateCall<'a, C, A> { SubaccountUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -10420,10 +10422,10 @@ impl<'a, C, A> FloodlightConfigurationMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn update(&self, request: &FloodlightConfiguration, profile_id: &str) -> FloodlightConfigurationUpdateCall<'a, C, A> { + pub fn update(&self, request: FloodlightConfiguration, profile_id: &str) -> FloodlightConfigurationUpdateCall<'a, C, A> { FloodlightConfigurationUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -10440,10 +10442,10 @@ impl<'a, C, A> FloodlightConfigurationMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Floodlight configuration ID. - pub fn patch(&self, request: &FloodlightConfiguration, profile_id: &str, id: &str) -> FloodlightConfigurationPatchCall<'a, C, A> { + pub fn patch(&self, request: FloodlightConfiguration, profile_id: &str, id: &str) -> FloodlightConfigurationPatchCall<'a, C, A> { FloodlightConfigurationPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -10710,10 +10712,10 @@ impl<'a, C, A> PlacementGroupMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn update(&self, request: &PlacementGroup, profile_id: &str) -> PlacementGroupUpdateCall<'a, C, A> { + pub fn update(&self, request: PlacementGroup, profile_id: &str) -> PlacementGroupUpdateCall<'a, C, A> { PlacementGroupUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -10729,10 +10731,10 @@ impl<'a, C, A> PlacementGroupMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn insert(&self, request: &PlacementGroup, profile_id: &str) -> PlacementGroupInsertCall<'a, C, A> { + pub fn insert(&self, request: PlacementGroup, profile_id: &str) -> PlacementGroupInsertCall<'a, C, A> { PlacementGroupInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -10768,10 +10770,10 @@ impl<'a, C, A> PlacementGroupMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Placement group ID. - pub fn patch(&self, request: &PlacementGroup, profile_id: &str, id: &str) -> PlacementGroupPatchCall<'a, C, A> { + pub fn patch(&self, request: PlacementGroup, profile_id: &str, id: &str) -> PlacementGroupPatchCall<'a, C, A> { PlacementGroupPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -11096,10 +11098,10 @@ impl<'a, C, A> ContentCategoryMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn update(&self, request: &ContentCategory, profile_id: &str) -> ContentCategoryUpdateCall<'a, C, A> { + pub fn update(&self, request: ContentCategory, profile_id: &str) -> ContentCategoryUpdateCall<'a, C, A> { ContentCategoryUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -11115,10 +11117,10 @@ impl<'a, C, A> ContentCategoryMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn insert(&self, request: &ContentCategory, profile_id: &str) -> ContentCategoryInsertCall<'a, C, A> { + pub fn insert(&self, request: ContentCategory, profile_id: &str) -> ContentCategoryInsertCall<'a, C, A> { ContentCategoryInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -11173,10 +11175,10 @@ impl<'a, C, A> ContentCategoryMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Content category ID. - pub fn patch(&self, request: &ContentCategory, profile_id: &str, id: &str) -> ContentCategoryPatchCall<'a, C, A> { + pub fn patch(&self, request: ContentCategory, profile_id: &str, id: &str) -> ContentCategoryPatchCall<'a, C, A> { ContentCategoryPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -11234,10 +11236,10 @@ impl<'a, C, A> CreativeMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn update(&self, request: &Creative, profile_id: &str) -> CreativeUpdateCall<'a, C, A> { + pub fn update(&self, request: Creative, profile_id: &str) -> CreativeUpdateCall<'a, C, A> { CreativeUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -11253,10 +11255,10 @@ impl<'a, C, A> CreativeMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn insert(&self, request: &Creative, profile_id: &str) -> CreativeInsertCall<'a, C, A> { + pub fn insert(&self, request: Creative, profile_id: &str) -> CreativeInsertCall<'a, C, A> { CreativeInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -11325,10 +11327,10 @@ impl<'a, C, A> CreativeMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Creative ID. - pub fn patch(&self, request: &Creative, profile_id: &str, id: &str) -> CreativePatchCall<'a, C, A> { + pub fn patch(&self, request: Creative, profile_id: &str, id: &str) -> CreativePatchCall<'a, C, A> { CreativePatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -11407,10 +11409,10 @@ impl<'a, C, A> CampaignMethods<'a, C, A> { /// * `profileId` - User profile ID associated with this request. /// * `defaultLandingPageName` - Default landing page name for this new campaign. Must be less than 256 characters long. /// * `defaultLandingPageUrl` - Default landing page URL for this new campaign. - pub fn insert(&self, request: &Campaign, profile_id: &str, default_landing_page_name: &str, default_landing_page_url: &str) -> CampaignInsertCall<'a, C, A> { + pub fn insert(&self, request: Campaign, profile_id: &str, default_landing_page_name: &str, default_landing_page_url: &str) -> CampaignInsertCall<'a, C, A> { CampaignInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _default_landing_page_name: default_landing_page_name.to_string(), _default_landing_page_url: default_landing_page_url.to_string(), @@ -11429,10 +11431,10 @@ impl<'a, C, A> CampaignMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Campaign ID. - pub fn patch(&self, request: &Campaign, profile_id: &str, id: &str) -> CampaignPatchCall<'a, C, A> { + pub fn patch(&self, request: Campaign, profile_id: &str, id: &str) -> CampaignPatchCall<'a, C, A> { CampaignPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -11449,10 +11451,10 @@ impl<'a, C, A> CampaignMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn update(&self, request: &Campaign, profile_id: &str) -> CampaignUpdateCall<'a, C, A> { + pub fn update(&self, request: Campaign, profile_id: &str) -> CampaignUpdateCall<'a, C, A> { CampaignUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -11585,10 +11587,10 @@ impl<'a, C, A> EventTagMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn insert(&self, request: &EventTag, profile_id: &str) -> EventTagInsertCall<'a, C, A> { + pub fn insert(&self, request: EventTag, profile_id: &str) -> EventTagInsertCall<'a, C, A> { EventTagInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -11605,10 +11607,10 @@ impl<'a, C, A> EventTagMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Event tag ID. - pub fn patch(&self, request: &EventTag, profile_id: &str, id: &str) -> EventTagPatchCall<'a, C, A> { + pub fn patch(&self, request: EventTag, profile_id: &str, id: &str) -> EventTagPatchCall<'a, C, A> { EventTagPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -11625,10 +11627,10 @@ impl<'a, C, A> EventTagMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn update(&self, request: &EventTag, profile_id: &str) -> EventTagUpdateCall<'a, C, A> { + pub fn update(&self, request: EventTag, profile_id: &str) -> EventTagUpdateCall<'a, C, A> { EventTagUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -11723,10 +11725,10 @@ impl<'a, C, A> RemarketingListMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn update(&self, request: &RemarketingList, profile_id: &str) -> RemarketingListUpdateCall<'a, C, A> { + pub fn update(&self, request: RemarketingList, profile_id: &str) -> RemarketingListUpdateCall<'a, C, A> { RemarketingListUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -11769,10 +11771,10 @@ impl<'a, C, A> RemarketingListMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Remarketing list ID. - pub fn patch(&self, request: &RemarketingList, profile_id: &str, id: &str) -> RemarketingListPatchCall<'a, C, A> { + pub fn patch(&self, request: RemarketingList, profile_id: &str, id: &str) -> RemarketingListPatchCall<'a, C, A> { RemarketingListPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -11789,10 +11791,10 @@ impl<'a, C, A> RemarketingListMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn insert(&self, request: &RemarketingList, profile_id: &str) -> RemarketingListInsertCall<'a, C, A> { + pub fn insert(&self, request: RemarketingList, profile_id: &str) -> RemarketingListInsertCall<'a, C, A> { RemarketingListInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -11911,10 +11913,10 @@ impl<'a, C, A> PlacementStrategyMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn update(&self, request: &PlacementStrategy, profile_id: &str) -> PlacementStrategyUpdateCall<'a, C, A> { + pub fn update(&self, request: PlacementStrategy, profile_id: &str) -> PlacementStrategyUpdateCall<'a, C, A> { PlacementStrategyUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -11991,10 +11993,10 @@ impl<'a, C, A> PlacementStrategyMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn insert(&self, request: &PlacementStrategy, profile_id: &str) -> PlacementStrategyInsertCall<'a, C, A> { + pub fn insert(&self, request: PlacementStrategy, profile_id: &str) -> PlacementStrategyInsertCall<'a, C, A> { PlacementStrategyInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -12011,10 +12013,10 @@ impl<'a, C, A> PlacementStrategyMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Placement strategy ID. - pub fn patch(&self, request: &PlacementStrategy, profile_id: &str, id: &str) -> PlacementStrategyPatchCall<'a, C, A> { + pub fn patch(&self, request: PlacementStrategy, profile_id: &str, id: &str) -> PlacementStrategyPatchCall<'a, C, A> { PlacementStrategyPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -12156,10 +12158,10 @@ impl<'a, C, A> DirectorySiteMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn insert(&self, request: &DirectorySite, profile_id: &str) -> DirectorySiteInsertCall<'a, C, A> { + pub fn insert(&self, request: DirectorySite, profile_id: &str) -> DirectorySiteInsertCall<'a, C, A> { DirectorySiteInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -12265,10 +12267,10 @@ impl<'a, C, A> SizeMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn insert(&self, request: &Size, profile_id: &str) -> SizeInsertCall<'a, C, A> { + pub fn insert(&self, request: Size, profile_id: &str) -> SizeInsertCall<'a, C, A> { SizeInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -12425,10 +12427,10 @@ impl<'a, C, A> AccountUserProfileMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn update(&self, request: &AccountUserProfile, profile_id: &str) -> AccountUserProfileUpdateCall<'a, C, A> { + pub fn update(&self, request: AccountUserProfile, profile_id: &str) -> AccountUserProfileUpdateCall<'a, C, A> { AccountUserProfileUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -12470,10 +12472,10 @@ impl<'a, C, A> AccountUserProfileMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn insert(&self, request: &AccountUserProfile, profile_id: &str) -> AccountUserProfileInsertCall<'a, C, A> { + pub fn insert(&self, request: AccountUserProfile, profile_id: &str) -> AccountUserProfileInsertCall<'a, C, A> { AccountUserProfileInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -12490,10 +12492,10 @@ impl<'a, C, A> AccountUserProfileMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - User profile ID. - pub fn patch(&self, request: &AccountUserProfile, profile_id: &str, id: &str) -> AccountUserProfilePatchCall<'a, C, A> { + pub fn patch(&self, request: AccountUserProfile, profile_id: &str, id: &str) -> AccountUserProfilePatchCall<'a, C, A> { AccountUserProfilePatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -12915,10 +12917,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn update(&self, request: &Account, profile_id: &str) -> AccountUpdateCall<'a, C, A> { + pub fn update(&self, request: Account, profile_id: &str) -> AccountUpdateCall<'a, C, A> { AccountUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -12935,10 +12937,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Account ID. - pub fn patch(&self, request: &Account, profile_id: &str, id: &str) -> AccountPatchCall<'a, C, A> { + pub fn patch(&self, request: Account, profile_id: &str, id: &str) -> AccountPatchCall<'a, C, A> { AccountPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -12997,10 +12999,10 @@ impl<'a, C, A> PlacementMethods<'a, C, A> { /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Placement ID. - pub fn patch(&self, request: &Placement, profile_id: &str, id: &str) -> PlacementPatchCall<'a, C, A> { + pub fn patch(&self, request: Placement, profile_id: &str, id: &str) -> PlacementPatchCall<'a, C, A> { PlacementPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -13052,10 +13054,10 @@ impl<'a, C, A> PlacementMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn insert(&self, request: &Placement, profile_id: &str) -> PlacementInsertCall<'a, C, A> { + pub fn insert(&self, request: Placement, profile_id: &str) -> PlacementInsertCall<'a, C, A> { PlacementInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -13071,10 +13073,10 @@ impl<'a, C, A> PlacementMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn update(&self, request: &Placement, profile_id: &str) -> PlacementUpdateCall<'a, C, A> { + pub fn update(&self, request: Placement, profile_id: &str) -> PlacementUpdateCall<'a, C, A> { PlacementUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -13277,12 +13279,17 @@ impl<'a, C, A> UserRolePermissionGroupGetCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13291,7 +13298,7 @@ impl<'a, C, A> UserRolePermissionGroupGetCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13521,12 +13528,17 @@ impl<'a, C, A> UserRolePermissionGroupListCall<'a, C, A> where C: BorrowMut<hype if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13535,7 +13547,7 @@ impl<'a, C, A> UserRolePermissionGroupListCall<'a, C, A> where C: BorrowMut<hype Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13757,12 +13769,17 @@ impl<'a, C, A> PlatformTypeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13771,7 +13788,7 @@ impl<'a, C, A> PlatformTypeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14001,12 +14018,17 @@ impl<'a, C, A> PlatformTypeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14015,7 +14037,7 @@ impl<'a, C, A> PlatformTypeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14122,7 +14144,7 @@ impl<'a, C, A> PlatformTypeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.creative_field_values().patch(&req, "profileId", "creativeFieldId", "id") +/// let result = hub.creative_field_values().patch(req, "profileId", "creativeFieldId", "id") /// .doit(); /// # } /// ``` @@ -14254,12 +14276,17 @@ impl<'a, C, A> CreativeFieldValuePatchCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14268,7 +14295,7 @@ impl<'a, C, A> CreativeFieldValuePatchCall<'a, C, A> where C: BorrowMut<hyper::C Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14286,8 +14313,8 @@ impl<'a, C, A> CreativeFieldValuePatchCall<'a, C, A> where C: BorrowMut<hyper::C /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &CreativeFieldValue) -> CreativeFieldValuePatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CreativeFieldValue) -> CreativeFieldValuePatchCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -14521,12 +14548,17 @@ impl<'a, C, A> CreativeFieldValueGetCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14535,7 +14567,7 @@ impl<'a, C, A> CreativeFieldValueGetCall<'a, C, A> where C: BorrowMut<hyper::Cli Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14778,12 +14810,17 @@ impl<'a, C, A> CreativeFieldValueDeleteCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -14909,7 +14946,7 @@ impl<'a, C, A> CreativeFieldValueDeleteCall<'a, C, A> where C: BorrowMut<hyper:: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.creative_field_values().insert(&req, "profileId", "creativeFieldId") +/// let result = hub.creative_field_values().insert(req, "profileId", "creativeFieldId") /// .doit(); /// # } /// ``` @@ -15039,12 +15076,17 @@ impl<'a, C, A> CreativeFieldValueInsertCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15053,7 +15095,7 @@ impl<'a, C, A> CreativeFieldValueInsertCall<'a, C, A> where C: BorrowMut<hyper:: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15071,8 +15113,8 @@ impl<'a, C, A> CreativeFieldValueInsertCall<'a, C, A> where C: BorrowMut<hyper:: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &CreativeFieldValue) -> CreativeFieldValueInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CreativeFieldValue) -> CreativeFieldValueInsertCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -15179,7 +15221,7 @@ impl<'a, C, A> CreativeFieldValueInsertCall<'a, C, A> where C: BorrowMut<hyper:: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.creative_field_values().update(&req, "profileId", "creativeFieldId") +/// let result = hub.creative_field_values().update(req, "profileId", "creativeFieldId") /// .doit(); /// # } /// ``` @@ -15309,12 +15351,17 @@ impl<'a, C, A> CreativeFieldValueUpdateCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15323,7 +15370,7 @@ impl<'a, C, A> CreativeFieldValueUpdateCall<'a, C, A> where C: BorrowMut<hyper:: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15341,8 +15388,8 @@ impl<'a, C, A> CreativeFieldValueUpdateCall<'a, C, A> where C: BorrowMut<hyper:: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &CreativeFieldValue) -> CreativeFieldValueUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CreativeFieldValue) -> CreativeFieldValueUpdateCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -15598,12 +15645,17 @@ impl<'a, C, A> CreativeFieldValueListCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15612,7 +15664,7 @@ impl<'a, C, A> CreativeFieldValueListCall<'a, C, A> where C: BorrowMut<hyper::Cl Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15772,7 +15824,7 @@ impl<'a, C, A> CreativeFieldValueListCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.creative_fields().update(&req, "profileId") +/// let result = hub.creative_fields().update(req, "profileId") /// .doit(); /// # } /// ``` @@ -15900,12 +15952,17 @@ impl<'a, C, A> CreativeFieldUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15914,7 +15971,7 @@ impl<'a, C, A> CreativeFieldUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15932,8 +15989,8 @@ impl<'a, C, A> CreativeFieldUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &CreativeField) -> CreativeFieldUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CreativeField) -> CreativeFieldUpdateCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -16186,12 +16243,17 @@ impl<'a, C, A> CreativeFieldListCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16200,7 +16262,7 @@ impl<'a, C, A> CreativeFieldListCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16472,12 +16534,17 @@ impl<'a, C, A> CreativeFieldDeleteCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -16708,12 +16775,17 @@ impl<'a, C, A> CreativeFieldGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16722,7 +16794,7 @@ impl<'a, C, A> CreativeFieldGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16839,7 +16911,7 @@ impl<'a, C, A> CreativeFieldGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.creative_fields().insert(&req, "profileId") +/// let result = hub.creative_fields().insert(req, "profileId") /// .doit(); /// # } /// ``` @@ -16967,12 +17039,17 @@ impl<'a, C, A> CreativeFieldInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16981,7 +17058,7 @@ impl<'a, C, A> CreativeFieldInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16999,8 +17076,8 @@ impl<'a, C, A> CreativeFieldInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &CreativeField) -> CreativeFieldInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CreativeField) -> CreativeFieldInsertCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -17097,7 +17174,7 @@ impl<'a, C, A> CreativeFieldInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.creative_fields().patch(&req, "profileId", "id") +/// let result = hub.creative_fields().patch(req, "profileId", "id") /// .doit(); /// # } /// ``` @@ -17227,12 +17304,17 @@ impl<'a, C, A> CreativeFieldPatchCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -17241,7 +17323,7 @@ impl<'a, C, A> CreativeFieldPatchCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -17259,8 +17341,8 @@ impl<'a, C, A> CreativeFieldPatchCall<'a, C, A> where C: BorrowMut<hyper::Client /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &CreativeField) -> CreativeFieldPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CreativeField) -> CreativeFieldPatchCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -17367,7 +17449,7 @@ impl<'a, C, A> CreativeFieldPatchCall<'a, C, A> where C: BorrowMut<hyper::Client /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.user_roles().insert(&req, "profileId") +/// let result = hub.user_roles().insert(req, "profileId") /// .doit(); /// # } /// ``` @@ -17495,12 +17577,17 @@ impl<'a, C, A> UserRoleInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -17509,7 +17596,7 @@ impl<'a, C, A> UserRoleInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -17527,8 +17614,8 @@ impl<'a, C, A> UserRoleInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &UserRole) -> UserRoleInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: UserRole) -> UserRoleInsertCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -17740,12 +17827,17 @@ impl<'a, C, A> UserRoleGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -17754,7 +17846,7 @@ impl<'a, C, A> UserRoleGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -17871,7 +17963,7 @@ impl<'a, C, A> UserRoleGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.user_roles().update(&req, "profileId") +/// let result = hub.user_roles().update(req, "profileId") /// .doit(); /// # } /// ``` @@ -17999,12 +18091,17 @@ impl<'a, C, A> UserRoleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -18013,7 +18110,7 @@ impl<'a, C, A> UserRoleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -18031,8 +18128,8 @@ impl<'a, C, A> UserRoleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &UserRole) -> UserRoleUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: UserRole) -> UserRoleUpdateCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -18243,12 +18340,17 @@ impl<'a, C, A> UserRoleDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -18364,7 +18466,7 @@ impl<'a, C, A> UserRoleDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.user_roles().patch(&req, "profileId", "id") +/// let result = hub.user_roles().patch(req, "profileId", "id") /// .doit(); /// # } /// ``` @@ -18494,12 +18596,17 @@ impl<'a, C, A> UserRolePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -18508,7 +18615,7 @@ impl<'a, C, A> UserRolePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -18526,8 +18633,8 @@ impl<'a, C, A> UserRolePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &UserRole) -> UserRolePatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: UserRole) -> UserRolePatchCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -18791,12 +18898,17 @@ impl<'a, C, A> UserRoleListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -18805,7 +18917,7 @@ impl<'a, C, A> UserRoleListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -19084,12 +19196,17 @@ impl<'a, C, A> OperatingSystemVersionGetCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -19098,7 +19215,7 @@ impl<'a, C, A> OperatingSystemVersionGetCall<'a, C, A> where C: BorrowMut<hyper: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -19328,12 +19445,17 @@ impl<'a, C, A> OperatingSystemVersionListCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -19342,7 +19464,7 @@ impl<'a, C, A> OperatingSystemVersionListCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -19566,12 +19688,17 @@ impl<'a, C, A> LandingPageGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -19580,7 +19707,7 @@ impl<'a, C, A> LandingPageGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -19707,7 +19834,7 @@ impl<'a, C, A> LandingPageGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.landing_pages().update(&req, "profileId", "campaignId") +/// let result = hub.landing_pages().update(req, "profileId", "campaignId") /// .doit(); /// # } /// ``` @@ -19837,12 +19964,17 @@ impl<'a, C, A> LandingPageUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -19851,7 +19983,7 @@ impl<'a, C, A> LandingPageUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -19869,8 +20001,8 @@ impl<'a, C, A> LandingPageUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client> /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &LandingPage) -> LandingPageUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: LandingPage) -> LandingPageUpdateCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -20092,12 +20224,17 @@ impl<'a, C, A> LandingPageListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -20106,7 +20243,7 @@ impl<'a, C, A> LandingPageListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -20223,7 +20360,7 @@ impl<'a, C, A> LandingPageListCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.landing_pages().insert(&req, "profileId", "campaignId") +/// let result = hub.landing_pages().insert(req, "profileId", "campaignId") /// .doit(); /// # } /// ``` @@ -20353,12 +20490,17 @@ impl<'a, C, A> LandingPageInsertCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -20367,7 +20509,7 @@ impl<'a, C, A> LandingPageInsertCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -20385,8 +20527,8 @@ impl<'a, C, A> LandingPageInsertCall<'a, C, A> where C: BorrowMut<hyper::Client> /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &LandingPage) -> LandingPageInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: LandingPage) -> LandingPageInsertCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -20493,7 +20635,7 @@ impl<'a, C, A> LandingPageInsertCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.landing_pages().patch(&req, "profileId", "campaignId", "id") +/// let result = hub.landing_pages().patch(req, "profileId", "campaignId", "id") /// .doit(); /// # } /// ``` @@ -20625,12 +20767,17 @@ impl<'a, C, A> LandingPagePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -20639,7 +20786,7 @@ impl<'a, C, A> LandingPagePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -20657,8 +20804,8 @@ impl<'a, C, A> LandingPagePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &LandingPage) -> LandingPagePatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: LandingPage) -> LandingPagePatchCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -20891,12 +21038,17 @@ impl<'a, C, A> LandingPageDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -21023,7 +21175,7 @@ impl<'a, C, A> LandingPageDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload_resumable(...)`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.creative_assets().insert(&req, "profileId", "advertiserId") +/// let result = hub.creative_assets().insert(req, "profileId", "advertiserId") /// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } /// ``` @@ -21071,14 +21223,15 @@ impl<'a, C, A> CreativeAssetInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/dfareporting/v2.1/userprofiles/{profileId}/creativeAssets/{advertiserId}/creativeAssets".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/dfareporting/v2.1/userprofiles/{profileId}/creativeAssets/{advertiserId}/creativeAssets".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/dfareporting/v2.1/userprofiles/{profileId}/creativeAssets/{advertiserId}/creativeAssets".to_string() + ("https://www.googleapis.com/resumable/upload/dfareporting/v2.1/userprofiles/{profileId}/creativeAssets/{advertiserId}/creativeAssets".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -21197,12 +21350,17 @@ impl<'a, C, A> CreativeAssetInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -21212,9 +21370,9 @@ impl<'a, C, A> CreativeAssetInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -21224,7 +21382,7 @@ impl<'a, C, A> CreativeAssetInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -21255,7 +21413,7 @@ impl<'a, C, A> CreativeAssetInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -21299,8 +21457,8 @@ impl<'a, C, A> CreativeAssetInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &CreativeAssetMetadata) -> CreativeAssetInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CreativeAssetMetadata) -> CreativeAssetInsertCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -21407,7 +21565,7 @@ impl<'a, C, A> CreativeAssetInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.campaign_creative_associations().insert(&req, "profileId", "campaignId") +/// let result = hub.campaign_creative_associations().insert(req, "profileId", "campaignId") /// .doit(); /// # } /// ``` @@ -21537,12 +21695,17 @@ impl<'a, C, A> CampaignCreativeAssociationInsertCall<'a, C, A> where C: BorrowMu if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -21551,7 +21714,7 @@ impl<'a, C, A> CampaignCreativeAssociationInsertCall<'a, C, A> where C: BorrowMu Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -21569,8 +21732,8 @@ impl<'a, C, A> CampaignCreativeAssociationInsertCall<'a, C, A> where C: BorrowMu /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &CampaignCreativeAssociation) -> CampaignCreativeAssociationInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CampaignCreativeAssociation) -> CampaignCreativeAssociationInsertCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -21807,12 +21970,17 @@ impl<'a, C, A> CampaignCreativeAssociationListCall<'a, C, A> where C: BorrowMut< if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -21821,7 +21989,7 @@ impl<'a, C, A> CampaignCreativeAssociationListCall<'a, C, A> where C: BorrowMut< Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -22134,12 +22302,17 @@ impl<'a, C, A> ChangeLogListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -22148,7 +22321,7 @@ impl<'a, C, A> ChangeLogListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -22443,12 +22616,17 @@ impl<'a, C, A> ChangeLogGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -22457,7 +22635,7 @@ impl<'a, C, A> ChangeLogGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -22689,12 +22867,17 @@ impl<'a, C, A> RemarketingListShareGetCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -22703,7 +22886,7 @@ impl<'a, C, A> RemarketingListShareGetCall<'a, C, A> where C: BorrowMut<hyper::C Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -22820,7 +23003,7 @@ impl<'a, C, A> RemarketingListShareGetCall<'a, C, A> where C: BorrowMut<hyper::C /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.remarketing_list_shares().patch(&req, "profileId", "remarketingListId") +/// let result = hub.remarketing_list_shares().patch(req, "profileId", "remarketingListId") /// .doit(); /// # } /// ``` @@ -22950,12 +23133,17 @@ impl<'a, C, A> RemarketingListSharePatchCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -22964,7 +23152,7 @@ impl<'a, C, A> RemarketingListSharePatchCall<'a, C, A> where C: BorrowMut<hyper: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -22982,8 +23170,8 @@ impl<'a, C, A> RemarketingListSharePatchCall<'a, C, A> where C: BorrowMut<hyper: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &RemarketingListShare) -> RemarketingListSharePatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: RemarketingListShare) -> RemarketingListSharePatchCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -23090,7 +23278,7 @@ impl<'a, C, A> RemarketingListSharePatchCall<'a, C, A> where C: BorrowMut<hyper: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.remarketing_list_shares().update(&req, "profileId") +/// let result = hub.remarketing_list_shares().update(req, "profileId") /// .doit(); /// # } /// ``` @@ -23218,12 +23406,17 @@ impl<'a, C, A> RemarketingListShareUpdateCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -23232,7 +23425,7 @@ impl<'a, C, A> RemarketingListShareUpdateCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -23250,8 +23443,8 @@ impl<'a, C, A> RemarketingListShareUpdateCall<'a, C, A> where C: BorrowMut<hyper /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &RemarketingListShare) -> RemarketingListShareUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: RemarketingListShare) -> RemarketingListShareUpdateCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -23468,12 +23661,17 @@ impl<'a, C, A> ReportRunCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -23482,7 +23680,7 @@ impl<'a, C, A> ReportRunCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -23606,7 +23804,7 @@ impl<'a, C, A> ReportRunCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.reports().patch(&req, "profileId", "reportId") +/// let result = hub.reports().patch(req, "profileId", "reportId") /// .doit(); /// # } /// ``` @@ -23736,12 +23934,17 @@ impl<'a, C, A> ReportPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -23750,7 +23953,7 @@ impl<'a, C, A> ReportPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -23768,8 +23971,8 @@ impl<'a, C, A> ReportPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Report) -> ReportPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Report) -> ReportPatchCall<'a, C, A> { + self._request = new_value; self } /// The DFA user profile ID. @@ -24011,12 +24214,17 @@ impl<'a, C, A> ReportFileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -24025,7 +24233,7 @@ impl<'a, C, A> ReportFileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -24170,7 +24378,7 @@ impl<'a, C, A> ReportFileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.reports().insert(&req, "profileId") +/// let result = hub.reports().insert(req, "profileId") /// .doit(); /// # } /// ``` @@ -24298,12 +24506,17 @@ impl<'a, C, A> ReportInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -24312,7 +24525,7 @@ impl<'a, C, A> ReportInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -24330,8 +24543,8 @@ impl<'a, C, A> ReportInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Report) -> ReportInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Report) -> ReportInsertCall<'a, C, A> { + self._request = new_value; self } /// The DFA user profile ID. @@ -24428,7 +24641,7 @@ impl<'a, C, A> ReportInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.reports().update(&req, "profileId", "reportId") +/// let result = hub.reports().update(req, "profileId", "reportId") /// .doit(); /// # } /// ``` @@ -24558,12 +24771,17 @@ impl<'a, C, A> ReportUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -24572,7 +24790,7 @@ impl<'a, C, A> ReportUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -24590,8 +24808,8 @@ impl<'a, C, A> ReportUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Report) -> ReportUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Report) -> ReportUpdateCall<'a, C, A> { + self._request = new_value; self } /// The DFA user profile ID. @@ -24698,7 +24916,7 @@ impl<'a, C, A> ReportUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.reports().compatible_fields_query(&req, "profileId") +/// let result = hub.reports().compatible_fields_query(req, "profileId") /// .doit(); /// # } /// ``` @@ -24826,12 +25044,17 @@ impl<'a, C, A> ReportCompatibleFieldQueryCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -24840,7 +25063,7 @@ impl<'a, C, A> ReportCompatibleFieldQueryCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -24858,8 +25081,8 @@ impl<'a, C, A> ReportCompatibleFieldQueryCall<'a, C, A> where C: BorrowMut<hyper /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Report) -> ReportCompatibleFieldQueryCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Report) -> ReportCompatibleFieldQueryCall<'a, C, A> { + self._request = new_value; self } /// The DFA user profile ID. @@ -25071,12 +25294,17 @@ impl<'a, C, A> ReportGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -25085,7 +25313,7 @@ impl<'a, C, A> ReportGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -25340,12 +25568,17 @@ impl<'a, C, A> ReportFileGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = if enable_resource_parsing { let mut json_response = String::new(); @@ -25354,7 +25587,7 @@ impl<'a, C, A> ReportFileGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } } else { (res, Default::default()) }; @@ -25595,12 +25828,17 @@ impl<'a, C, A> ReportDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -25854,12 +26092,17 @@ impl<'a, C, A> ReportListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -25868,7 +26111,7 @@ impl<'a, C, A> ReportListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -26010,7 +26253,7 @@ impl<'a, C, A> ReportListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.advertisers().insert(&req, "profileId") +/// let result = hub.advertisers().insert(req, "profileId") /// .doit(); /// # } /// ``` @@ -26138,12 +26381,17 @@ impl<'a, C, A> AdvertiserInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -26152,7 +26400,7 @@ impl<'a, C, A> AdvertiserInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -26170,8 +26418,8 @@ impl<'a, C, A> AdvertiserInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Advertiser) -> AdvertiserInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Advertiser) -> AdvertiserInsertCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -26268,7 +26516,7 @@ impl<'a, C, A> AdvertiserInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.advertisers().patch(&req, "profileId", "id") +/// let result = hub.advertisers().patch(req, "profileId", "id") /// .doit(); /// # } /// ``` @@ -26398,12 +26646,17 @@ impl<'a, C, A> AdvertiserPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -26412,7 +26665,7 @@ impl<'a, C, A> AdvertiserPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -26430,8 +26683,8 @@ impl<'a, C, A> AdvertiserPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Advertiser) -> AdvertiserPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Advertiser) -> AdvertiserPatchCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -26723,12 +26976,17 @@ impl<'a, C, A> AdvertiserListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -26737,7 +26995,7 @@ impl<'a, C, A> AdvertiserListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -26931,7 +27189,7 @@ impl<'a, C, A> AdvertiserListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.advertisers().update(&req, "profileId") +/// let result = hub.advertisers().update(req, "profileId") /// .doit(); /// # } /// ``` @@ -27059,12 +27317,17 @@ impl<'a, C, A> AdvertiserUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -27073,7 +27336,7 @@ impl<'a, C, A> AdvertiserUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -27091,8 +27354,8 @@ impl<'a, C, A> AdvertiserUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Advertiser) -> AdvertiserUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Advertiser) -> AdvertiserUpdateCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -27304,12 +27567,17 @@ impl<'a, C, A> AdvertiserGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -27318,7 +27586,7 @@ impl<'a, C, A> AdvertiserGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -27435,7 +27703,7 @@ impl<'a, C, A> AdvertiserGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.dimension_values().query(&req, "profileId") +/// let result = hub.dimension_values().query(req, "profileId") /// .page_token("sanctus") /// .max_results(-27) /// .doit(); @@ -27573,12 +27841,17 @@ impl<'a, C, A> DimensionValueQueryCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -27587,7 +27860,7 @@ impl<'a, C, A> DimensionValueQueryCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -27605,8 +27878,8 @@ impl<'a, C, A> DimensionValueQueryCall<'a, C, A> where C: BorrowMut<hyper::Clien /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &DimensionValueRequest) -> DimensionValueQueryCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: DimensionValueRequest) -> DimensionValueQueryCall<'a, C, A> { + self._request = new_value; self } /// The DFA user profile ID. @@ -27831,12 +28104,17 @@ impl<'a, C, A> FloodlightActivityGroupDeleteCall<'a, C, A> where C: BorrowMut<hy if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -28067,12 +28345,17 @@ impl<'a, C, A> FloodlightActivityGroupGetCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -28081,7 +28364,7 @@ impl<'a, C, A> FloodlightActivityGroupGetCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -28198,7 +28481,7 @@ impl<'a, C, A> FloodlightActivityGroupGetCall<'a, C, A> where C: BorrowMut<hyper /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.floodlight_activity_groups().patch(&req, "profileId", "id") +/// let result = hub.floodlight_activity_groups().patch(req, "profileId", "id") /// .doit(); /// # } /// ``` @@ -28328,12 +28611,17 @@ impl<'a, C, A> FloodlightActivityGroupPatchCall<'a, C, A> where C: BorrowMut<hyp if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -28342,7 +28630,7 @@ impl<'a, C, A> FloodlightActivityGroupPatchCall<'a, C, A> where C: BorrowMut<hyp Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -28360,8 +28648,8 @@ impl<'a, C, A> FloodlightActivityGroupPatchCall<'a, C, A> where C: BorrowMut<hyp /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &FloodlightActivityGroup) -> FloodlightActivityGroupPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: FloodlightActivityGroup) -> FloodlightActivityGroupPatchCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -28630,12 +28918,17 @@ impl<'a, C, A> FloodlightActivityGroupListCall<'a, C, A> where C: BorrowMut<hype if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -28644,7 +28937,7 @@ impl<'a, C, A> FloodlightActivityGroupListCall<'a, C, A> where C: BorrowMut<hype Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -28815,7 +29108,7 @@ impl<'a, C, A> FloodlightActivityGroupListCall<'a, C, A> where C: BorrowMut<hype /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.floodlight_activity_groups().insert(&req, "profileId") +/// let result = hub.floodlight_activity_groups().insert(req, "profileId") /// .doit(); /// # } /// ``` @@ -28943,12 +29236,17 @@ impl<'a, C, A> FloodlightActivityGroupInsertCall<'a, C, A> where C: BorrowMut<hy if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -28957,7 +29255,7 @@ impl<'a, C, A> FloodlightActivityGroupInsertCall<'a, C, A> where C: BorrowMut<hy Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -28975,8 +29273,8 @@ impl<'a, C, A> FloodlightActivityGroupInsertCall<'a, C, A> where C: BorrowMut<hy /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &FloodlightActivityGroup) -> FloodlightActivityGroupInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: FloodlightActivityGroup) -> FloodlightActivityGroupInsertCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -29073,7 +29371,7 @@ impl<'a, C, A> FloodlightActivityGroupInsertCall<'a, C, A> where C: BorrowMut<hy /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.floodlight_activity_groups().update(&req, "profileId") +/// let result = hub.floodlight_activity_groups().update(req, "profileId") /// .doit(); /// # } /// ``` @@ -29201,12 +29499,17 @@ impl<'a, C, A> FloodlightActivityGroupUpdateCall<'a, C, A> where C: BorrowMut<hy if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -29215,7 +29518,7 @@ impl<'a, C, A> FloodlightActivityGroupUpdateCall<'a, C, A> where C: BorrowMut<hy Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -29233,8 +29536,8 @@ impl<'a, C, A> FloodlightActivityGroupUpdateCall<'a, C, A> where C: BorrowMut<hy /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &FloodlightActivityGroup) -> FloodlightActivityGroupUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: FloodlightActivityGroup) -> FloodlightActivityGroupUpdateCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -29444,12 +29747,17 @@ impl<'a, C, A> MetroListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -29458,7 +29766,7 @@ impl<'a, C, A> MetroListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -29723,12 +30031,17 @@ impl<'a, C, A> OrderListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -29737,7 +30050,7 @@ impl<'a, C, A> OrderListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -30022,12 +30335,17 @@ impl<'a, C, A> OrderGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -30036,7 +30354,7 @@ impl<'a, C, A> OrderGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -30278,12 +30596,17 @@ impl<'a, C, A> DirectorySiteContactGetCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -30292,7 +30615,7 @@ impl<'a, C, A> DirectorySiteContactGetCall<'a, C, A> where C: BorrowMut<hyper::C Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -30565,12 +30888,17 @@ impl<'a, C, A> DirectorySiteContactListCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -30579,7 +30907,7 @@ impl<'a, C, A> DirectorySiteContactListCall<'a, C, A> where C: BorrowMut<hyper:: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -30824,12 +31152,17 @@ impl<'a, C, A> UserProfileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -30838,7 +31171,7 @@ impl<'a, C, A> UserProfileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -31048,12 +31381,17 @@ impl<'a, C, A> UserProfileGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -31062,7 +31400,7 @@ impl<'a, C, A> UserProfileGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -31169,7 +31507,7 @@ impl<'a, C, A> UserProfileGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.ads().patch(&req, "profileId", "id") +/// let result = hub.ads().patch(req, "profileId", "id") /// .doit(); /// # } /// ``` @@ -31299,12 +31637,17 @@ impl<'a, C, A> AdPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -31313,7 +31656,7 @@ impl<'a, C, A> AdPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -31331,8 +31674,8 @@ impl<'a, C, A> AdPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Ad) -> AdPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Ad) -> AdPatchCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -31439,7 +31782,7 @@ impl<'a, C, A> AdPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.ads().insert(&req, "profileId") +/// let result = hub.ads().insert(req, "profileId") /// .doit(); /// # } /// ``` @@ -31567,12 +31910,17 @@ impl<'a, C, A> AdInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -31581,7 +31929,7 @@ impl<'a, C, A> AdInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -31599,8 +31947,8 @@ impl<'a, C, A> AdInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Ad) -> AdInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Ad) -> AdInsertCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -31970,12 +32318,17 @@ impl<'a, C, A> AdListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -31984,7 +32337,7 @@ impl<'a, C, A> AdListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -32384,12 +32737,17 @@ impl<'a, C, A> AdGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -32398,7 +32756,7 @@ impl<'a, C, A> AdGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -32515,7 +32873,7 @@ impl<'a, C, A> AdGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.ads().update(&req, "profileId") +/// let result = hub.ads().update(req, "profileId") /// .doit(); /// # } /// ``` @@ -32643,12 +33001,17 @@ impl<'a, C, A> AdUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -32657,7 +33020,7 @@ impl<'a, C, A> AdUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -32675,8 +33038,8 @@ impl<'a, C, A> AdUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Ad) -> AdUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Ad) -> AdUpdateCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -32888,12 +33251,17 @@ impl<'a, C, A> AccountPermissionGetCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -32902,7 +33270,7 @@ impl<'a, C, A> AccountPermissionGetCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -33132,12 +33500,17 @@ impl<'a, C, A> AccountPermissionListCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -33146,7 +33519,7 @@ impl<'a, C, A> AccountPermissionListCall<'a, C, A> where C: BorrowMut<hyper::Cli Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -33366,12 +33739,17 @@ impl<'a, C, A> ConnectionTypeListCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -33380,7 +33758,7 @@ impl<'a, C, A> ConnectionTypeListCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -33602,12 +33980,17 @@ impl<'a, C, A> ConnectionTypeGetCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -33616,7 +33999,7 @@ impl<'a, C, A> ConnectionTypeGetCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -33848,12 +34231,17 @@ impl<'a, C, A> AdvertiserGroupGetCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -33862,7 +34250,7 @@ impl<'a, C, A> AdvertiserGroupGetCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -34126,12 +34514,17 @@ impl<'a, C, A> AdvertiserGroupListCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -34140,7 +34533,7 @@ impl<'a, C, A> AdvertiserGroupListCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -34290,7 +34683,7 @@ impl<'a, C, A> AdvertiserGroupListCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.advertiser_groups().insert(&req, "profileId") +/// let result = hub.advertiser_groups().insert(req, "profileId") /// .doit(); /// # } /// ``` @@ -34418,12 +34811,17 @@ impl<'a, C, A> AdvertiserGroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -34432,7 +34830,7 @@ impl<'a, C, A> AdvertiserGroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Cli Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -34450,8 +34848,8 @@ impl<'a, C, A> AdvertiserGroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Cli /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AdvertiserGroup) -> AdvertiserGroupInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AdvertiserGroup) -> AdvertiserGroupInsertCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -34548,7 +34946,7 @@ impl<'a, C, A> AdvertiserGroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Cli /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.advertiser_groups().update(&req, "profileId") +/// let result = hub.advertiser_groups().update(req, "profileId") /// .doit(); /// # } /// ``` @@ -34676,12 +35074,17 @@ impl<'a, C, A> AdvertiserGroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -34690,7 +35093,7 @@ impl<'a, C, A> AdvertiserGroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Cli Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -34708,8 +35111,8 @@ impl<'a, C, A> AdvertiserGroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Cli /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AdvertiserGroup) -> AdvertiserGroupUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AdvertiserGroup) -> AdvertiserGroupUpdateCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -34806,7 +35209,7 @@ impl<'a, C, A> AdvertiserGroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Cli /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.advertiser_groups().patch(&req, "profileId", "id") +/// let result = hub.advertiser_groups().patch(req, "profileId", "id") /// .doit(); /// # } /// ``` @@ -34936,12 +35339,17 @@ impl<'a, C, A> AdvertiserGroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -34950,7 +35358,7 @@ impl<'a, C, A> AdvertiserGroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -34968,8 +35376,8 @@ impl<'a, C, A> AdvertiserGroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Clie /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AdvertiserGroup) -> AdvertiserGroupPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AdvertiserGroup) -> AdvertiserGroupPatchCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -35190,12 +35598,17 @@ impl<'a, C, A> AdvertiserGroupDeleteCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -35311,7 +35724,7 @@ impl<'a, C, A> AdvertiserGroupDeleteCall<'a, C, A> where C: BorrowMut<hyper::Cli /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.sites().insert(&req, "profileId") +/// let result = hub.sites().insert(req, "profileId") /// .doit(); /// # } /// ``` @@ -35439,12 +35852,17 @@ impl<'a, C, A> SiteInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -35453,7 +35871,7 @@ impl<'a, C, A> SiteInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -35471,8 +35889,8 @@ impl<'a, C, A> SiteInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Site) -> SiteInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Site) -> SiteInsertCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -35684,12 +36102,17 @@ impl<'a, C, A> SiteGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -35698,7 +36121,7 @@ impl<'a, C, A> SiteGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -36015,12 +36438,17 @@ impl<'a, C, A> SiteListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -36029,7 +36457,7 @@ impl<'a, C, A> SiteListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -36244,7 +36672,7 @@ impl<'a, C, A> SiteListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.sites().update(&req, "profileId") +/// let result = hub.sites().update(req, "profileId") /// .doit(); /// # } /// ``` @@ -36372,12 +36800,17 @@ impl<'a, C, A> SiteUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -36386,7 +36819,7 @@ impl<'a, C, A> SiteUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -36404,8 +36837,8 @@ impl<'a, C, A> SiteUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Site) -> SiteUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Site) -> SiteUpdateCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -36502,7 +36935,7 @@ impl<'a, C, A> SiteUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.sites().patch(&req, "profileId", "id") +/// let result = hub.sites().patch(req, "profileId", "id") /// .doit(); /// # } /// ``` @@ -36632,12 +37065,17 @@ impl<'a, C, A> SitePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -36646,7 +37084,7 @@ impl<'a, C, A> SitePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -36664,8 +37102,8 @@ impl<'a, C, A> SitePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Site) -> SitePatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Site) -> SitePatchCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -36887,12 +37325,17 @@ impl<'a, C, A> FloodlightActivityGetCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -36901,7 +37344,7 @@ impl<'a, C, A> FloodlightActivityGetCall<'a, C, A> where C: BorrowMut<hyper::Cli Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -37204,12 +37647,17 @@ impl<'a, C, A> FloodlightActivityListCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -37218,7 +37666,7 @@ impl<'a, C, A> FloodlightActivityListCall<'a, C, A> where C: BorrowMut<hyper::Cl Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -37418,7 +37866,7 @@ impl<'a, C, A> FloodlightActivityListCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.floodlight_activities().insert(&req, "profileId") +/// let result = hub.floodlight_activities().insert(req, "profileId") /// .doit(); /// # } /// ``` @@ -37546,12 +37994,17 @@ impl<'a, C, A> FloodlightActivityInsertCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -37560,7 +38013,7 @@ impl<'a, C, A> FloodlightActivityInsertCall<'a, C, A> where C: BorrowMut<hyper:: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -37578,8 +38031,8 @@ impl<'a, C, A> FloodlightActivityInsertCall<'a, C, A> where C: BorrowMut<hyper:: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &FloodlightActivity) -> FloodlightActivityInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: FloodlightActivity) -> FloodlightActivityInsertCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -37790,12 +38243,17 @@ impl<'a, C, A> FloodlightActivityDeleteCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -37911,7 +38369,7 @@ impl<'a, C, A> FloodlightActivityDeleteCall<'a, C, A> where C: BorrowMut<hyper:: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.floodlight_activities().patch(&req, "profileId", "id") +/// let result = hub.floodlight_activities().patch(req, "profileId", "id") /// .doit(); /// # } /// ``` @@ -38041,12 +38499,17 @@ impl<'a, C, A> FloodlightActivityPatchCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -38055,7 +38518,7 @@ impl<'a, C, A> FloodlightActivityPatchCall<'a, C, A> where C: BorrowMut<hyper::C Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -38073,8 +38536,8 @@ impl<'a, C, A> FloodlightActivityPatchCall<'a, C, A> where C: BorrowMut<hyper::C /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &FloodlightActivity) -> FloodlightActivityPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: FloodlightActivity) -> FloodlightActivityPatchCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -38299,12 +38762,17 @@ impl<'a, C, A> FloodlightActivityGeneratetagCall<'a, C, A> where C: BorrowMut<hy if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -38313,7 +38781,7 @@ impl<'a, C, A> FloodlightActivityGeneratetagCall<'a, C, A> where C: BorrowMut<hy Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -38427,7 +38895,7 @@ impl<'a, C, A> FloodlightActivityGeneratetagCall<'a, C, A> where C: BorrowMut<hy /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.floodlight_activities().update(&req, "profileId") +/// let result = hub.floodlight_activities().update(req, "profileId") /// .doit(); /// # } /// ``` @@ -38555,12 +39023,17 @@ impl<'a, C, A> FloodlightActivityUpdateCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -38569,7 +39042,7 @@ impl<'a, C, A> FloodlightActivityUpdateCall<'a, C, A> where C: BorrowMut<hyper:: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -38587,8 +39060,8 @@ impl<'a, C, A> FloodlightActivityUpdateCall<'a, C, A> where C: BorrowMut<hyper:: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &FloodlightActivity) -> FloodlightActivityUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: FloodlightActivity) -> FloodlightActivityUpdateCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -38798,12 +39271,17 @@ impl<'a, C, A> RegionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -38812,7 +39290,7 @@ impl<'a, C, A> RegionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -38919,7 +39397,7 @@ impl<'a, C, A> RegionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.creative_groups().insert(&req, "profileId") +/// let result = hub.creative_groups().insert(req, "profileId") /// .doit(); /// # } /// ``` @@ -39047,12 +39525,17 @@ impl<'a, C, A> CreativeGroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -39061,7 +39544,7 @@ impl<'a, C, A> CreativeGroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -39079,8 +39562,8 @@ impl<'a, C, A> CreativeGroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &CreativeGroup) -> CreativeGroupInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CreativeGroup) -> CreativeGroupInsertCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -39292,12 +39775,17 @@ impl<'a, C, A> CreativeGroupGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -39306,7 +39794,7 @@ impl<'a, C, A> CreativeGroupGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -39423,7 +39911,7 @@ impl<'a, C, A> CreativeGroupGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.creative_groups().update(&req, "profileId") +/// let result = hub.creative_groups().update(req, "profileId") /// .doit(); /// # } /// ``` @@ -39551,12 +40039,17 @@ impl<'a, C, A> CreativeGroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -39565,7 +40058,7 @@ impl<'a, C, A> CreativeGroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -39583,8 +40076,8 @@ impl<'a, C, A> CreativeGroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &CreativeGroup) -> CreativeGroupUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CreativeGroup) -> CreativeGroupUpdateCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -39842,12 +40335,17 @@ impl<'a, C, A> CreativeGroupListCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -39856,7 +40354,7 @@ impl<'a, C, A> CreativeGroupListCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -40021,7 +40519,7 @@ impl<'a, C, A> CreativeGroupListCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.creative_groups().patch(&req, "profileId", "id") +/// let result = hub.creative_groups().patch(req, "profileId", "id") /// .doit(); /// # } /// ``` @@ -40151,12 +40649,17 @@ impl<'a, C, A> CreativeGroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -40165,7 +40668,7 @@ impl<'a, C, A> CreativeGroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -40183,8 +40686,8 @@ impl<'a, C, A> CreativeGroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Client /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &CreativeGroup) -> CreativeGroupPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CreativeGroup) -> CreativeGroupPatchCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -40436,12 +40939,17 @@ impl<'a, C, A> TargetableRemarketingListListCall<'a, C, A> where C: BorrowMut<hy if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -40450,7 +40958,7 @@ impl<'a, C, A> TargetableRemarketingListListCall<'a, C, A> where C: BorrowMut<hy Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -40724,12 +41232,17 @@ impl<'a, C, A> TargetableRemarketingListGetCall<'a, C, A> where C: BorrowMut<hyp if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -40738,7 +41251,7 @@ impl<'a, C, A> TargetableRemarketingListGetCall<'a, C, A> where C: BorrowMut<hyp Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -40855,7 +41368,7 @@ impl<'a, C, A> TargetableRemarketingListGetCall<'a, C, A> where C: BorrowMut<hyp /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.subaccounts().patch(&req, "profileId", "id") +/// let result = hub.subaccounts().patch(req, "profileId", "id") /// .doit(); /// # } /// ``` @@ -40985,12 +41498,17 @@ impl<'a, C, A> SubaccountPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -40999,7 +41517,7 @@ impl<'a, C, A> SubaccountPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -41017,8 +41535,8 @@ impl<'a, C, A> SubaccountPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Subaccount) -> SubaccountPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Subaccount) -> SubaccountPatchCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -41125,7 +41643,7 @@ impl<'a, C, A> SubaccountPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.subaccounts().insert(&req, "profileId") +/// let result = hub.subaccounts().insert(req, "profileId") /// .doit(); /// # } /// ``` @@ -41253,12 +41771,17 @@ impl<'a, C, A> SubaccountInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -41267,7 +41790,7 @@ impl<'a, C, A> SubaccountInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -41285,8 +41808,8 @@ impl<'a, C, A> SubaccountInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Subaccount) -> SubaccountInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Subaccount) -> SubaccountInsertCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -41530,12 +42053,17 @@ impl<'a, C, A> SubaccountListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -41544,7 +42072,7 @@ impl<'a, C, A> SubaccountListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -41694,7 +42222,7 @@ impl<'a, C, A> SubaccountListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.subaccounts().update(&req, "profileId") +/// let result = hub.subaccounts().update(req, "profileId") /// .doit(); /// # } /// ``` @@ -41822,12 +42350,17 @@ impl<'a, C, A> SubaccountUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -41836,7 +42369,7 @@ impl<'a, C, A> SubaccountUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -41854,8 +42387,8 @@ impl<'a, C, A> SubaccountUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Subaccount) -> SubaccountUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Subaccount) -> SubaccountUpdateCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -42067,12 +42600,17 @@ impl<'a, C, A> SubaccountGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -42081,7 +42619,7 @@ impl<'a, C, A> SubaccountGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -42313,12 +42851,17 @@ impl<'a, C, A> MobileCarrierGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -42327,7 +42870,7 @@ impl<'a, C, A> MobileCarrierGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -42557,12 +43100,17 @@ impl<'a, C, A> MobileCarrierListCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -42571,7 +43119,7 @@ impl<'a, C, A> MobileCarrierListCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -42793,12 +43341,17 @@ impl<'a, C, A> FloodlightConfigurationGetCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -42807,7 +43360,7 @@ impl<'a, C, A> FloodlightConfigurationGetCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -42924,7 +43477,7 @@ impl<'a, C, A> FloodlightConfigurationGetCall<'a, C, A> where C: BorrowMut<hyper /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.floodlight_configurations().update(&req, "profileId") +/// let result = hub.floodlight_configurations().update(req, "profileId") /// .doit(); /// # } /// ``` @@ -43052,12 +43605,17 @@ impl<'a, C, A> FloodlightConfigurationUpdateCall<'a, C, A> where C: BorrowMut<hy if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -43066,7 +43624,7 @@ impl<'a, C, A> FloodlightConfigurationUpdateCall<'a, C, A> where C: BorrowMut<hy Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -43084,8 +43642,8 @@ impl<'a, C, A> FloodlightConfigurationUpdateCall<'a, C, A> where C: BorrowMut<hy /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &FloodlightConfiguration) -> FloodlightConfigurationUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: FloodlightConfiguration) -> FloodlightConfigurationUpdateCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -43182,7 +43740,7 @@ impl<'a, C, A> FloodlightConfigurationUpdateCall<'a, C, A> where C: BorrowMut<hy /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.floodlight_configurations().patch(&req, "profileId", "id") +/// let result = hub.floodlight_configurations().patch(req, "profileId", "id") /// .doit(); /// # } /// ``` @@ -43312,12 +43870,17 @@ impl<'a, C, A> FloodlightConfigurationPatchCall<'a, C, A> where C: BorrowMut<hyp if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -43326,7 +43889,7 @@ impl<'a, C, A> FloodlightConfigurationPatchCall<'a, C, A> where C: BorrowMut<hyp Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -43344,8 +43907,8 @@ impl<'a, C, A> FloodlightConfigurationPatchCall<'a, C, A> where C: BorrowMut<hyp /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &FloodlightConfiguration) -> FloodlightConfigurationPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: FloodlightConfiguration) -> FloodlightConfigurationPatchCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -43574,12 +44137,17 @@ impl<'a, C, A> FloodlightConfigurationListCall<'a, C, A> where C: BorrowMut<hype if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -43588,7 +44156,7 @@ impl<'a, C, A> FloodlightConfigurationListCall<'a, C, A> where C: BorrowMut<hype Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -43816,12 +44384,17 @@ impl<'a, C, A> OperatingSystemListCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -43830,7 +44403,7 @@ impl<'a, C, A> OperatingSystemListCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -44052,12 +44625,17 @@ impl<'a, C, A> OperatingSystemGetCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -44066,7 +44644,7 @@ impl<'a, C, A> OperatingSystemGetCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -44321,12 +44899,17 @@ impl<'a, C, A> FileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -44335,7 +44918,7 @@ impl<'a, C, A> FileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -44613,12 +45196,17 @@ impl<'a, C, A> FileGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = if enable_resource_parsing { let mut json_response = String::new(); @@ -44627,7 +45215,7 @@ impl<'a, C, A> FileGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } } else { (res, Default::default()) }; @@ -44964,12 +45552,17 @@ impl<'a, C, A> PlacementGroupListCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -44978,7 +45571,7 @@ impl<'a, C, A> PlacementGroupListCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -45198,7 +45791,7 @@ impl<'a, C, A> PlacementGroupListCall<'a, C, A> where C: BorrowMut<hyper::Client /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.placement_groups().update(&req, "profileId") +/// let result = hub.placement_groups().update(req, "profileId") /// .doit(); /// # } /// ``` @@ -45326,12 +45919,17 @@ impl<'a, C, A> PlacementGroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -45340,7 +45938,7 @@ impl<'a, C, A> PlacementGroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -45358,8 +45956,8 @@ impl<'a, C, A> PlacementGroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clie /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PlacementGroup) -> PlacementGroupUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PlacementGroup) -> PlacementGroupUpdateCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -45456,7 +46054,7 @@ impl<'a, C, A> PlacementGroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.placement_groups().insert(&req, "profileId") +/// let result = hub.placement_groups().insert(req, "profileId") /// .doit(); /// # } /// ``` @@ -45584,12 +46182,17 @@ impl<'a, C, A> PlacementGroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -45598,7 +46201,7 @@ impl<'a, C, A> PlacementGroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -45616,8 +46219,8 @@ impl<'a, C, A> PlacementGroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Clie /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PlacementGroup) -> PlacementGroupInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PlacementGroup) -> PlacementGroupInsertCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -45829,12 +46432,17 @@ impl<'a, C, A> PlacementGroupGetCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -45843,7 +46451,7 @@ impl<'a, C, A> PlacementGroupGetCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -45960,7 +46568,7 @@ impl<'a, C, A> PlacementGroupGetCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.placement_groups().patch(&req, "profileId", "id") +/// let result = hub.placement_groups().patch(req, "profileId", "id") /// .doit(); /// # } /// ``` @@ -46090,12 +46698,17 @@ impl<'a, C, A> PlacementGroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -46104,7 +46717,7 @@ impl<'a, C, A> PlacementGroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -46122,8 +46735,8 @@ impl<'a, C, A> PlacementGroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Clien /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PlacementGroup) -> PlacementGroupPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PlacementGroup) -> PlacementGroupPatchCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -46397,12 +47010,17 @@ impl<'a, C, A> InventoryItemListCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -46411,7 +47029,7 @@ impl<'a, C, A> InventoryItemListCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -46704,12 +47322,17 @@ impl<'a, C, A> InventoryItemGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -46718,7 +47341,7 @@ impl<'a, C, A> InventoryItemGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -46960,12 +47583,17 @@ impl<'a, C, A> UserRolePermissionGetCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -46974,7 +47602,7 @@ impl<'a, C, A> UserRolePermissionGetCall<'a, C, A> where C: BorrowMut<hyper::Cli Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -47213,12 +47841,17 @@ impl<'a, C, A> UserRolePermissionListCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -47227,7 +47860,7 @@ impl<'a, C, A> UserRolePermissionListCall<'a, C, A> where C: BorrowMut<hyper::Cl Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -47455,12 +48088,17 @@ impl<'a, C, A> AccountPermissionGroupListCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -47469,7 +48107,7 @@ impl<'a, C, A> AccountPermissionGroupListCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -47691,12 +48329,17 @@ impl<'a, C, A> AccountPermissionGroupGetCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -47705,7 +48348,7 @@ impl<'a, C, A> AccountPermissionGroupGetCall<'a, C, A> where C: BorrowMut<hyper: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -47969,12 +48612,17 @@ impl<'a, C, A> ContentCategoryListCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -47983,7 +48631,7 @@ impl<'a, C, A> ContentCategoryListCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -48133,7 +48781,7 @@ impl<'a, C, A> ContentCategoryListCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.content_categories().update(&req, "profileId") +/// let result = hub.content_categories().update(req, "profileId") /// .doit(); /// # } /// ``` @@ -48261,12 +48909,17 @@ impl<'a, C, A> ContentCategoryUpdateCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -48275,7 +48928,7 @@ impl<'a, C, A> ContentCategoryUpdateCall<'a, C, A> where C: BorrowMut<hyper::Cli Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -48293,8 +48946,8 @@ impl<'a, C, A> ContentCategoryUpdateCall<'a, C, A> where C: BorrowMut<hyper::Cli /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ContentCategory) -> ContentCategoryUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ContentCategory) -> ContentCategoryUpdateCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -48391,7 +49044,7 @@ impl<'a, C, A> ContentCategoryUpdateCall<'a, C, A> where C: BorrowMut<hyper::Cli /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.content_categories().insert(&req, "profileId") +/// let result = hub.content_categories().insert(req, "profileId") /// .doit(); /// # } /// ``` @@ -48519,12 +49172,17 @@ impl<'a, C, A> ContentCategoryInsertCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -48533,7 +49191,7 @@ impl<'a, C, A> ContentCategoryInsertCall<'a, C, A> where C: BorrowMut<hyper::Cli Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -48551,8 +49209,8 @@ impl<'a, C, A> ContentCategoryInsertCall<'a, C, A> where C: BorrowMut<hyper::Cli /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ContentCategory) -> ContentCategoryInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ContentCategory) -> ContentCategoryInsertCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -48763,12 +49421,17 @@ impl<'a, C, A> ContentCategoryDeleteCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -48999,12 +49662,17 @@ impl<'a, C, A> ContentCategoryGetCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -49013,7 +49681,7 @@ impl<'a, C, A> ContentCategoryGetCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -49130,7 +49798,7 @@ impl<'a, C, A> ContentCategoryGetCall<'a, C, A> where C: BorrowMut<hyper::Client /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.content_categories().patch(&req, "profileId", "id") +/// let result = hub.content_categories().patch(req, "profileId", "id") /// .doit(); /// # } /// ``` @@ -49260,12 +49928,17 @@ impl<'a, C, A> ContentCategoryPatchCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -49274,7 +49947,7 @@ impl<'a, C, A> ContentCategoryPatchCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -49292,8 +49965,8 @@ impl<'a, C, A> ContentCategoryPatchCall<'a, C, A> where C: BorrowMut<hyper::Clie /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ContentCategory) -> ContentCategoryPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ContentCategory) -> ContentCategoryPatchCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -49400,7 +50073,7 @@ impl<'a, C, A> ContentCategoryPatchCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.creatives().update(&req, "profileId") +/// let result = hub.creatives().update(req, "profileId") /// .doit(); /// # } /// ``` @@ -49528,12 +50201,17 @@ impl<'a, C, A> CreativeUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -49542,7 +50220,7 @@ impl<'a, C, A> CreativeUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -49560,8 +50238,8 @@ impl<'a, C, A> CreativeUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Creative) -> CreativeUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Creative) -> CreativeUpdateCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -49658,7 +50336,7 @@ impl<'a, C, A> CreativeUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.creatives().insert(&req, "profileId") +/// let result = hub.creatives().insert(req, "profileId") /// .doit(); /// # } /// ``` @@ -49786,12 +50464,17 @@ impl<'a, C, A> CreativeInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -49800,7 +50483,7 @@ impl<'a, C, A> CreativeInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -49818,8 +50501,8 @@ impl<'a, C, A> CreativeInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Creative) -> CreativeInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Creative) -> CreativeInsertCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -50031,12 +50714,17 @@ impl<'a, C, A> CreativeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -50045,7 +50733,7 @@ impl<'a, C, A> CreativeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -50379,12 +51067,17 @@ impl<'a, C, A> CreativeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -50393,7 +51086,7 @@ impl<'a, C, A> CreativeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -50618,7 +51311,7 @@ impl<'a, C, A> CreativeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.creatives().patch(&req, "profileId", "id") +/// let result = hub.creatives().patch(req, "profileId", "id") /// .doit(); /// # } /// ``` @@ -50748,12 +51441,17 @@ impl<'a, C, A> CreativePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -50762,7 +51460,7 @@ impl<'a, C, A> CreativePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -50780,8 +51478,8 @@ impl<'a, C, A> CreativePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Creative) -> CreativePatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Creative) -> CreativePatchCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -51003,12 +51701,17 @@ impl<'a, C, A> CampaignGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -51017,7 +51720,7 @@ impl<'a, C, A> CampaignGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -51134,7 +51837,7 @@ impl<'a, C, A> CampaignGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.campaigns().insert(&req, "profileId", "defaultLandingPageName", "defaultLandingPageUrl") +/// let result = hub.campaigns().insert(req, "profileId", "defaultLandingPageName", "defaultLandingPageUrl") /// .doit(); /// # } /// ``` @@ -51266,12 +51969,17 @@ impl<'a, C, A> CampaignInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -51280,7 +51988,7 @@ impl<'a, C, A> CampaignInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -51298,8 +52006,8 @@ impl<'a, C, A> CampaignInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Campaign) -> CampaignInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Campaign) -> CampaignInsertCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -51416,7 +52124,7 @@ impl<'a, C, A> CampaignInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.campaigns().patch(&req, "profileId", "id") +/// let result = hub.campaigns().patch(req, "profileId", "id") /// .doit(); /// # } /// ``` @@ -51546,12 +52254,17 @@ impl<'a, C, A> CampaignPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -51560,7 +52273,7 @@ impl<'a, C, A> CampaignPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -51578,8 +52291,8 @@ impl<'a, C, A> CampaignPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Campaign) -> CampaignPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Campaign) -> CampaignPatchCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -51686,7 +52399,7 @@ impl<'a, C, A> CampaignPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.campaigns().update(&req, "profileId") +/// let result = hub.campaigns().update(req, "profileId") /// .doit(); /// # } /// ``` @@ -51814,12 +52527,17 @@ impl<'a, C, A> CampaignUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -51828,7 +52546,7 @@ impl<'a, C, A> CampaignUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -51846,8 +52564,8 @@ impl<'a, C, A> CampaignUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Campaign) -> CampaignUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Campaign) -> CampaignUpdateCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -52138,12 +52856,17 @@ impl<'a, C, A> CampaignListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -52152,7 +52875,7 @@ impl<'a, C, A> CampaignListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -52468,12 +53191,17 @@ impl<'a, C, A> EventTagDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -52760,12 +53488,17 @@ impl<'a, C, A> EventTagListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -52774,7 +53507,7 @@ impl<'a, C, A> EventTagListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -52953,7 +53686,7 @@ impl<'a, C, A> EventTagListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.event_tags().insert(&req, "profileId") +/// let result = hub.event_tags().insert(req, "profileId") /// .doit(); /// # } /// ``` @@ -53081,12 +53814,17 @@ impl<'a, C, A> EventTagInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -53095,7 +53833,7 @@ impl<'a, C, A> EventTagInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -53113,8 +53851,8 @@ impl<'a, C, A> EventTagInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &EventTag) -> EventTagInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: EventTag) -> EventTagInsertCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -53211,7 +53949,7 @@ impl<'a, C, A> EventTagInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.event_tags().patch(&req, "profileId", "id") +/// let result = hub.event_tags().patch(req, "profileId", "id") /// .doit(); /// # } /// ``` @@ -53341,12 +54079,17 @@ impl<'a, C, A> EventTagPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -53355,7 +54098,7 @@ impl<'a, C, A> EventTagPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -53373,8 +54116,8 @@ impl<'a, C, A> EventTagPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &EventTag) -> EventTagPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: EventTag) -> EventTagPatchCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -53481,7 +54224,7 @@ impl<'a, C, A> EventTagPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.event_tags().update(&req, "profileId") +/// let result = hub.event_tags().update(req, "profileId") /// .doit(); /// # } /// ``` @@ -53609,12 +54352,17 @@ impl<'a, C, A> EventTagUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -53623,7 +54371,7 @@ impl<'a, C, A> EventTagUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -53641,8 +54389,8 @@ impl<'a, C, A> EventTagUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &EventTag) -> EventTagUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: EventTag) -> EventTagUpdateCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -53854,12 +54602,17 @@ impl<'a, C, A> EventTagGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -53868,7 +54621,7 @@ impl<'a, C, A> EventTagGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -54100,12 +54853,17 @@ impl<'a, C, A> RemarketingListGetCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -54114,7 +54872,7 @@ impl<'a, C, A> RemarketingListGetCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -54231,7 +54989,7 @@ impl<'a, C, A> RemarketingListGetCall<'a, C, A> where C: BorrowMut<hyper::Client /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.remarketing_lists().update(&req, "profileId") +/// let result = hub.remarketing_lists().update(req, "profileId") /// .doit(); /// # } /// ``` @@ -54359,12 +55117,17 @@ impl<'a, C, A> RemarketingListUpdateCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -54373,7 +55136,7 @@ impl<'a, C, A> RemarketingListUpdateCall<'a, C, A> where C: BorrowMut<hyper::Cli Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -54391,8 +55154,8 @@ impl<'a, C, A> RemarketingListUpdateCall<'a, C, A> where C: BorrowMut<hyper::Cli /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &RemarketingList) -> RemarketingListUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: RemarketingList) -> RemarketingListUpdateCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -54639,12 +55402,17 @@ impl<'a, C, A> RemarketingListListCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -54653,7 +55421,7 @@ impl<'a, C, A> RemarketingListListCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -54819,7 +55587,7 @@ impl<'a, C, A> RemarketingListListCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.remarketing_lists().patch(&req, "profileId", "id") +/// let result = hub.remarketing_lists().patch(req, "profileId", "id") /// .doit(); /// # } /// ``` @@ -54949,12 +55717,17 @@ impl<'a, C, A> RemarketingListPatchCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -54963,7 +55736,7 @@ impl<'a, C, A> RemarketingListPatchCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -54981,8 +55754,8 @@ impl<'a, C, A> RemarketingListPatchCall<'a, C, A> where C: BorrowMut<hyper::Clie /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &RemarketingList) -> RemarketingListPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: RemarketingList) -> RemarketingListPatchCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -55089,7 +55862,7 @@ impl<'a, C, A> RemarketingListPatchCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.remarketing_lists().insert(&req, "profileId") +/// let result = hub.remarketing_lists().insert(req, "profileId") /// .doit(); /// # } /// ``` @@ -55217,12 +55990,17 @@ impl<'a, C, A> RemarketingListInsertCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -55231,7 +56009,7 @@ impl<'a, C, A> RemarketingListInsertCall<'a, C, A> where C: BorrowMut<hyper::Cli Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -55249,8 +56027,8 @@ impl<'a, C, A> RemarketingListInsertCall<'a, C, A> where C: BorrowMut<hyper::Cli /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &RemarketingList) -> RemarketingListInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: RemarketingList) -> RemarketingListInsertCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -55492,12 +56270,17 @@ impl<'a, C, A> CityListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -55506,7 +56289,7 @@ impl<'a, C, A> CityListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -55644,7 +56427,7 @@ impl<'a, C, A> CityListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.placement_strategies().update(&req, "profileId") +/// let result = hub.placement_strategies().update(req, "profileId") /// .doit(); /// # } /// ``` @@ -55772,12 +56555,17 @@ impl<'a, C, A> PlacementStrategyUpdateCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -55786,7 +56574,7 @@ impl<'a, C, A> PlacementStrategyUpdateCall<'a, C, A> where C: BorrowMut<hyper::C Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -55804,8 +56592,8 @@ impl<'a, C, A> PlacementStrategyUpdateCall<'a, C, A> where C: BorrowMut<hyper::C /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PlacementStrategy) -> PlacementStrategyUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PlacementStrategy) -> PlacementStrategyUpdateCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -56017,12 +56805,17 @@ impl<'a, C, A> PlacementStrategyGetCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -56031,7 +56824,7 @@ impl<'a, C, A> PlacementStrategyGetCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -56295,12 +57088,17 @@ impl<'a, C, A> PlacementStrategyListCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -56309,7 +57107,7 @@ impl<'a, C, A> PlacementStrategyListCall<'a, C, A> where C: BorrowMut<hyper::Cli Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -56573,12 +57371,17 @@ impl<'a, C, A> PlacementStrategyDeleteCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -56694,7 +57497,7 @@ impl<'a, C, A> PlacementStrategyDeleteCall<'a, C, A> where C: BorrowMut<hyper::C /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.placement_strategies().insert(&req, "profileId") +/// let result = hub.placement_strategies().insert(req, "profileId") /// .doit(); /// # } /// ``` @@ -56822,12 +57625,17 @@ impl<'a, C, A> PlacementStrategyInsertCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -56836,7 +57644,7 @@ impl<'a, C, A> PlacementStrategyInsertCall<'a, C, A> where C: BorrowMut<hyper::C Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -56854,8 +57662,8 @@ impl<'a, C, A> PlacementStrategyInsertCall<'a, C, A> where C: BorrowMut<hyper::C /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PlacementStrategy) -> PlacementStrategyInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PlacementStrategy) -> PlacementStrategyInsertCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -56952,7 +57760,7 @@ impl<'a, C, A> PlacementStrategyInsertCall<'a, C, A> where C: BorrowMut<hyper::C /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.placement_strategies().patch(&req, "profileId", "id") +/// let result = hub.placement_strategies().patch(req, "profileId", "id") /// .doit(); /// # } /// ``` @@ -57082,12 +57890,17 @@ impl<'a, C, A> PlacementStrategyPatchCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -57096,7 +57909,7 @@ impl<'a, C, A> PlacementStrategyPatchCall<'a, C, A> where C: BorrowMut<hyper::Cl Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -57114,8 +57927,8 @@ impl<'a, C, A> PlacementStrategyPatchCall<'a, C, A> where C: BorrowMut<hyper::Cl /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PlacementStrategy) -> PlacementStrategyPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PlacementStrategy) -> PlacementStrategyPatchCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -57378,12 +58191,17 @@ impl<'a, C, A> ProjectListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -57392,7 +58210,7 @@ impl<'a, C, A> ProjectListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -57665,12 +58483,17 @@ impl<'a, C, A> ProjectGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -57679,7 +58502,7 @@ impl<'a, C, A> ProjectGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -57796,7 +58619,7 @@ impl<'a, C, A> ProjectGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.directory_sites().insert(&req, "profileId") +/// let result = hub.directory_sites().insert(req, "profileId") /// .doit(); /// # } /// ``` @@ -57924,12 +58747,17 @@ impl<'a, C, A> DirectorySiteInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -57938,7 +58766,7 @@ impl<'a, C, A> DirectorySiteInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -57956,8 +58784,8 @@ impl<'a, C, A> DirectorySiteInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &DirectorySite) -> DirectorySiteInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: DirectorySite) -> DirectorySiteInsertCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -58236,12 +59064,17 @@ impl<'a, C, A> DirectorySiteListCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -58250,7 +59083,7 @@ impl<'a, C, A> DirectorySiteListCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -58564,12 +59397,17 @@ impl<'a, C, A> DirectorySiteGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -58578,7 +59416,7 @@ impl<'a, C, A> DirectorySiteGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -58695,7 +59533,7 @@ impl<'a, C, A> DirectorySiteGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.sizes().insert(&req, "profileId") +/// let result = hub.sizes().insert(req, "profileId") /// .doit(); /// # } /// ``` @@ -58823,12 +59661,17 @@ impl<'a, C, A> SizeInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -58837,7 +59680,7 @@ impl<'a, C, A> SizeInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -58855,8 +59698,8 @@ impl<'a, C, A> SizeInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Size) -> SizeInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Size) -> SizeInsertCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -59090,12 +59933,17 @@ impl<'a, C, A> SizeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -59104,7 +59952,7 @@ impl<'a, C, A> SizeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -59355,12 +60203,17 @@ impl<'a, C, A> SizeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -59369,7 +60222,7 @@ impl<'a, C, A> SizeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -59601,12 +60454,17 @@ impl<'a, C, A> AccountActiveAdSummaryGetCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -59615,7 +60473,7 @@ impl<'a, C, A> AccountActiveAdSummaryGetCall<'a, C, A> where C: BorrowMut<hyper: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -59732,7 +60590,7 @@ impl<'a, C, A> AccountActiveAdSummaryGetCall<'a, C, A> where C: BorrowMut<hyper: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.account_user_profiles().update(&req, "profileId") +/// let result = hub.account_user_profiles().update(req, "profileId") /// .doit(); /// # } /// ``` @@ -59860,12 +60718,17 @@ impl<'a, C, A> AccountUserProfileUpdateCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -59874,7 +60737,7 @@ impl<'a, C, A> AccountUserProfileUpdateCall<'a, C, A> where C: BorrowMut<hyper:: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -59892,8 +60755,8 @@ impl<'a, C, A> AccountUserProfileUpdateCall<'a, C, A> where C: BorrowMut<hyper:: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AccountUserProfile) -> AccountUserProfileUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AccountUserProfile) -> AccountUserProfileUpdateCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -60152,12 +61015,17 @@ impl<'a, C, A> AccountUserProfileListCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -60166,7 +61034,7 @@ impl<'a, C, A> AccountUserProfileListCall<'a, C, A> where C: BorrowMut<hyper::Cl Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -60337,7 +61205,7 @@ impl<'a, C, A> AccountUserProfileListCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.account_user_profiles().insert(&req, "profileId") +/// let result = hub.account_user_profiles().insert(req, "profileId") /// .doit(); /// # } /// ``` @@ -60465,12 +61333,17 @@ impl<'a, C, A> AccountUserProfileInsertCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -60479,7 +61352,7 @@ impl<'a, C, A> AccountUserProfileInsertCall<'a, C, A> where C: BorrowMut<hyper:: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -60497,8 +61370,8 @@ impl<'a, C, A> AccountUserProfileInsertCall<'a, C, A> where C: BorrowMut<hyper:: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AccountUserProfile) -> AccountUserProfileInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AccountUserProfile) -> AccountUserProfileInsertCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -60595,7 +61468,7 @@ impl<'a, C, A> AccountUserProfileInsertCall<'a, C, A> where C: BorrowMut<hyper:: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.account_user_profiles().patch(&req, "profileId", "id") +/// let result = hub.account_user_profiles().patch(req, "profileId", "id") /// .doit(); /// # } /// ``` @@ -60725,12 +61598,17 @@ impl<'a, C, A> AccountUserProfilePatchCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -60739,7 +61617,7 @@ impl<'a, C, A> AccountUserProfilePatchCall<'a, C, A> where C: BorrowMut<hyper::C Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -60757,8 +61635,8 @@ impl<'a, C, A> AccountUserProfilePatchCall<'a, C, A> where C: BorrowMut<hyper::C /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AccountUserProfile) -> AccountUserProfilePatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AccountUserProfile) -> AccountUserProfilePatchCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -60980,12 +61858,17 @@ impl<'a, C, A> AccountUserProfileGetCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -60994,7 +61877,7 @@ impl<'a, C, A> AccountUserProfileGetCall<'a, C, A> where C: BorrowMut<hyper::Cli Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -61224,12 +62107,17 @@ impl<'a, C, A> CountryListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -61238,7 +62126,7 @@ impl<'a, C, A> CountryListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -61460,12 +62348,17 @@ impl<'a, C, A> CountryGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -61474,7 +62367,7 @@ impl<'a, C, A> CountryGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -61708,12 +62601,17 @@ impl<'a, C, A> OrderDocumentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -61722,7 +62620,7 @@ impl<'a, C, A> OrderDocumentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -62021,12 +62919,17 @@ impl<'a, C, A> OrderDocumentListCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -62035,7 +62938,7 @@ impl<'a, C, A> OrderDocumentListCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -62333,12 +63236,17 @@ impl<'a, C, A> PostalCodeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -62347,7 +63255,7 @@ impl<'a, C, A> PostalCodeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -62577,12 +63485,17 @@ impl<'a, C, A> PostalCodeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -62591,7 +63504,7 @@ impl<'a, C, A> PostalCodeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -62811,12 +63724,17 @@ impl<'a, C, A> BrowserListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -62825,7 +63743,7 @@ impl<'a, C, A> BrowserListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -63047,12 +63965,17 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -63061,7 +63984,7 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -63330,12 +64253,17 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -63344,7 +64272,7 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -63501,7 +64429,7 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().update(&req, "profileId") +/// let result = hub.accounts().update(req, "profileId") /// .doit(); /// # } /// ``` @@ -63629,12 +64557,17 @@ impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -63643,7 +64576,7 @@ impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -63661,8 +64594,8 @@ impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Account) -> AccountUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Account) -> AccountUpdateCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -63759,7 +64692,7 @@ impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().patch(&req, "profileId", "id") +/// let result = hub.accounts().patch(req, "profileId", "id") /// .doit(); /// # } /// ``` @@ -63889,12 +64822,17 @@ impl<'a, C, A> AccountPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -63903,7 +64841,7 @@ impl<'a, C, A> AccountPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -63921,8 +64859,8 @@ impl<'a, C, A> AccountPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Account) -> AccountPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Account) -> AccountPatchCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -64029,7 +64967,7 @@ impl<'a, C, A> AccountPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.placements().patch(&req, "profileId", "id") +/// let result = hub.placements().patch(req, "profileId", "id") /// .doit(); /// # } /// ``` @@ -64159,12 +65097,17 @@ impl<'a, C, A> PlacementPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -64173,7 +65116,7 @@ impl<'a, C, A> PlacementPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -64191,8 +65134,8 @@ impl<'a, C, A> PlacementPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Placement) -> PlacementPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Placement) -> PlacementPatchCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -64546,12 +65489,17 @@ impl<'a, C, A> PlacementListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -64560,7 +65508,7 @@ impl<'a, C, A> PlacementListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -64804,7 +65752,7 @@ impl<'a, C, A> PlacementListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.placements().insert(&req, "profileId") +/// let result = hub.placements().insert(req, "profileId") /// .doit(); /// # } /// ``` @@ -64932,12 +65880,17 @@ impl<'a, C, A> PlacementInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -64946,7 +65899,7 @@ impl<'a, C, A> PlacementInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -64964,8 +65917,8 @@ impl<'a, C, A> PlacementInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Placement) -> PlacementInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Placement) -> PlacementInsertCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -65062,7 +66015,7 @@ impl<'a, C, A> PlacementInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.placements().update(&req, "profileId") +/// let result = hub.placements().update(req, "profileId") /// .doit(); /// # } /// ``` @@ -65190,12 +66143,17 @@ impl<'a, C, A> PlacementUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -65204,7 +66162,7 @@ impl<'a, C, A> PlacementUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -65222,8 +66180,8 @@ impl<'a, C, A> PlacementUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Placement) -> PlacementUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Placement) -> PlacementUpdateCall<'a, C, A> { + self._request = new_value; self } /// User profile ID associated with this request. @@ -65456,12 +66414,17 @@ impl<'a, C, A> PlacementGeneratetagCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -65470,7 +66433,7 @@ impl<'a, C, A> PlacementGeneratetagCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -65715,12 +66678,17 @@ impl<'a, C, A> PlacementGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -65729,7 +66697,7 @@ impl<'a, C, A> PlacementGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/discovery1-cli/Cargo.toml b/gen/discovery1-cli/Cargo.toml index 130a2d964b..eb0c9d5072 100644 --- a/gen/discovery1-cli/Cargo.toml +++ b/gen/discovery1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-discovery1-cli" -version = "0.0.1+00000000" +version = "0.1.0+00000000" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with discovery (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/discovery1-cli" diff --git a/gen/discovery1-cli/README.md b/gen/discovery1-cli/README.md index 38aa82e3a9..b5a9e60dc0 100644 --- a/gen/discovery1-cli/README.md +++ b/gen/discovery1-cli/README.md @@ -1,4 +1,99 @@ -# HELLO DISCOVERY:V1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `discovery1` command-line interface *(CLI)* allows to use most features of the *Google discovery* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *discovery* API at revision *00000000*. The CLI is at version *0.1.0*. + +```bash + discovery1 [options] apis get-rest <api> <version> [-p <v>...] [-o <out>] + discovery1 [options] apis list [-p <v>...] [-o <out>] + discovery1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_discovery1_cli/index.html + +Configuration: + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `discovery1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/discovery1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/discovery1-secret.json`, assuming that the required *discovery* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `discovery1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/discovery1-cli/mkdocs.yml b/gen/discovery1-cli/mkdocs.yml index 781e10e1ff..8ed74f72fc 100644 --- a/gen/discovery1-cli/mkdocs.yml +++ b/gen/discovery1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: discovery v0.0.1+00000000 +site_name: discovery v0.1.0+00000000 site_url: http://byron.github.io/google-apis-rs/google-discovery1-cli site_description: Write integrating applications with bcore diff --git a/gen/discovery1-cli/src/cmn.rs b/gen/discovery1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/discovery1-cli/src/cmn.rs +++ b/gen/discovery1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/discovery1-cli/src/main.rs b/gen/discovery1-cli/src/main.rs index 2af64066eb..8669b9b718 100644 --- a/gen/discovery1-cli/src/main.rs +++ b/gen/discovery1-cli/src/main.rs @@ -19,23 +19,24 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - discovery1 [options] apis get-rest <api> <version> [-p <v>]... [-o <out>] - discovery1 [options] apis list [-p <v>]... [-o <out>] + discovery1 [options] apis get-rest <api> <version> [-p <v>...] [-o <out>] + discovery1 [options] apis list [-p <v>...] [-o <out>] discovery1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_discovery1_cli/index.html Configuration: --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -228,6 +229,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -235,8 +237,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/discovery1/Cargo.toml b/gen/discovery1/Cargo.toml index 93660a0b9c..48b88f74db 100644 --- a/gen/discovery1/Cargo.toml +++ b/gen/discovery1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-discovery1" -version = "0.1.5+00000000" +version = "0.1.6+00000000" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with discovery (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/discovery1" diff --git a/gen/discovery1/README.md b/gen/discovery1/README.md index dd1e6d9524..4dcb56e4df 100644 --- a/gen/discovery1/README.md +++ b/gen/discovery1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-discovery1` library allows access to all features of the *Google discovery* service. -This documentation was generated from *discovery* crate version *0.1.5+00000000*, where *00000000* is the exact revision of the *discovery:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *discovery* crate version *0.1.6+00000000*, where *00000000* is the exact revision of the *discovery:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *discovery* *v1* API can be found at the [official documentation site](https://developers.google.com/discovery/). @@ -99,14 +99,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/discovery1/src/cmn.rs b/gen/discovery1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/discovery1/src/cmn.rs +++ b/gen/discovery1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/discovery1/src/lib.rs b/gen/discovery1/src/lib.rs index c19d85461c..634908fd3a 100644 --- a/gen/discovery1/src/lib.rs +++ b/gen/discovery1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *discovery* crate version *0.1.5+00000000*, where *00000000* is the exact revision of the *discovery:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *discovery* crate version *0.1.6+00000000*, where *00000000* is the exact revision of the *discovery:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *discovery* *v1* API can be found at the //! [official documentation site](https://developers.google.com/discovery/). @@ -100,14 +100,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -195,7 +196,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -247,14 +248,15 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -275,7 +277,7 @@ impl<'a, C, A> Discovery<C, A> Discovery { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -284,7 +286,7 @@ impl<'a, C, A> Discovery<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -996,12 +998,17 @@ impl<'a, C, A> ApiGetRestCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1010,7 +1017,7 @@ impl<'a, C, A> ApiGetRestCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1189,12 +1196,17 @@ impl<'a, C, A> ApiListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1203,7 +1215,7 @@ impl<'a, C, A> ApiListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/dns1-cli/Cargo.toml b/gen/dns1-cli/Cargo.toml index 9da48f56b3..9f56f057ce 100644 --- a/gen/dns1-cli/Cargo.toml +++ b/gen/dns1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-dns1-cli" -version = "0.0.1+20150218" +version = "0.1.0+20150218" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with dns (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/dns1-cli" diff --git a/gen/dns1-cli/README.md b/gen/dns1-cli/README.md index c6cee63985..b743aab867 100644 --- a/gen/dns1-cli/README.md +++ b/gen/dns1-cli/README.md @@ -1,4 +1,110 @@ -# HELLO DNS:V1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `dns1` command-line interface *(CLI)* allows to use most features of the *Google dns* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *dns* API at revision *20150218*. The CLI is at version *0.1.0*. + +```bash + dns1 [options] changes create <project> <managed-zone> -r <kv>... [-p <v>...] [-o <out>] + dns1 [options] changes get <project> <managed-zone> <change-id> [-p <v>...] [-o <out>] + dns1 [options] changes list <project> <managed-zone> [-p <v>...] [-o <out>] + dns1 [options] managed-zones create <project> -r <kv>... [-p <v>...] [-o <out>] + dns1 [options] managed-zones delete <project> <managed-zone> [-p <v>...] + dns1 [options] managed-zones get <project> <managed-zone> [-p <v>...] [-o <out>] + dns1 [options] managed-zones list <project> [-p <v>...] [-o <out>] + dns1 [options] projects get <project> [-p <v>...] [-o <out>] + dns1 [options] resource-record-sets list <project> <managed-zone> [-p <v>...] [-o <out>] + dns1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_dns1_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `dns1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/dns1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/dns1-secret.json`, assuming that the required *dns* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `dns1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/dns1-cli/mkdocs.yml b/gen/dns1-cli/mkdocs.yml index bd14ac1162..3acc121f45 100644 --- a/gen/dns1-cli/mkdocs.yml +++ b/gen/dns1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: dns v0.0.1+20150218 +site_name: dns v0.1.0+20150218 site_url: http://byron.github.io/google-apis-rs/google-dns1-cli site_description: Write integrating applications with bcore diff --git a/gen/dns1-cli/src/cmn.rs b/gen/dns1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/dns1-cli/src/cmn.rs +++ b/gen/dns1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/dns1-cli/src/main.rs b/gen/dns1-cli/src/main.rs index 807caab1e9..50875d0cb4 100644 --- a/gen/dns1-cli/src/main.rs +++ b/gen/dns1-cli/src/main.rs @@ -19,34 +19,35 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - dns1 [options] changes create <project> <managed-zone> -r <kv>... [-p <v>]... [-o <out>] - dns1 [options] changes get <project> <managed-zone> <change-id> [-p <v>]... [-o <out>] - dns1 [options] changes list <project> <managed-zone> [-p <v>]... [-o <out>] - dns1 [options] managed-zones create <project> -r <kv>... [-p <v>]... [-o <out>] - dns1 [options] managed-zones delete <project> <managed-zone> [-p <v>]... - dns1 [options] managed-zones get <project> <managed-zone> [-p <v>]... [-o <out>] - dns1 [options] managed-zones list <project> [-p <v>]... [-o <out>] - dns1 [options] projects get <project> [-p <v>]... [-o <out>] - dns1 [options] resource-record-sets list <project> <managed-zone> [-p <v>]... [-o <out>] + dns1 [options] changes create <project> <managed-zone> -r <kv>... [-p <v>...] [-o <out>] + dns1 [options] changes get <project> <managed-zone> <change-id> [-p <v>...] [-o <out>] + dns1 [options] changes list <project> <managed-zone> [-p <v>...] [-o <out>] + dns1 [options] managed-zones create <project> -r <kv>... [-p <v>...] [-o <out>] + dns1 [options] managed-zones delete <project> <managed-zone> [-p <v>...] + dns1 [options] managed-zones get <project> <managed-zone> [-p <v>...] [-o <out>] + dns1 [options] managed-zones list <project> [-p <v>...] [-o <out>] + dns1 [options] projects get <project> [-p <v>...] [-o <out>] + dns1 [options] resource-record-sets list <project> <managed-zone> [-p <v>...] [-o <out>] dns1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_dns1_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -68,8 +69,42 @@ struct Engine { impl Engine { fn _changes_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Change::default(); - let mut call = self.hub.changes().create(&request, &self.opt.arg_project, &self.opt.arg_managed_zone); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "status" => { + request.status = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "start-time" => { + request.start_time = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.changes().create(request, &self.opt.arg_project, &self.opt.arg_managed_zone); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -91,36 +126,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "status" => { - request.status = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "start-time" => { - request.start_time = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -164,6 +177,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -219,6 +235,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -235,37 +254,24 @@ impl Engine { fn _managed_zones_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::ManagedZone::default(); - let mut call = self.hub.managed_zones().create(&request, &self.opt.arg_project); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ManagedZone::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -294,15 +300,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.managed_zones().create(request, &self.opt.arg_project); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -346,6 +377,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -387,6 +421,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -436,6 +473,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -479,6 +519,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -534,6 +577,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -658,6 +704,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -665,8 +712,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/dns1/Cargo.toml b/gen/dns1/Cargo.toml index 3c837ce947..003af1da95 100644 --- a/gen/dns1/Cargo.toml +++ b/gen/dns1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-dns1" -version = "0.1.5+20150218" +version = "0.1.6+20150218" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with dns (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/dns1" diff --git a/gen/dns1/README.md b/gen/dns1/README.md index 22e29d70c2..4324d3f3d4 100644 --- a/gen/dns1/README.md +++ b/gen/dns1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-dns1` library allows access to all features of the *Google dns* service. -This documentation was generated from *dns* crate version *0.1.5+20150218*, where *20150218* is the exact revision of the *dns:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *dns* crate version *0.1.6+20150218*, where *20150218* is the exact revision of the *dns:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *dns* *v1* API can be found at the [official documentation site](https://developers.google.com/cloud-dns). @@ -110,14 +110,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/dns1/src/cmn.rs b/gen/dns1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/dns1/src/cmn.rs +++ b/gen/dns1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/dns1/src/lib.rs b/gen/dns1/src/lib.rs index 6f9faf1b9e..16a604a6c4 100644 --- a/gen/dns1/src/lib.rs +++ b/gen/dns1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *dns* crate version *0.1.5+20150218*, where *20150218* is the exact revision of the *dns:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *dns* crate version *0.1.6+20150218*, where *20150218* is the exact revision of the *dns:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *dns* *v1* API can be found at the //! [official documentation site](https://developers.google.com/cloud-dns). @@ -111,14 +111,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -206,7 +207,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -290,14 +291,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -318,7 +320,7 @@ impl<'a, C, A> Dns<C, A> Dns { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -336,7 +338,7 @@ impl<'a, C, A> Dns<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -635,10 +637,10 @@ impl<'a, C, A> ChangeMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Identifies the project addressed by this request. /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or id. - pub fn create(&self, request: &Change, project: &str, managed_zone: &str) -> ChangeCreateCall<'a, C, A> { + pub fn create(&self, request: Change, project: &str, managed_zone: &str) -> ChangeCreateCall<'a, C, A> { ChangeCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _managed_zone: managed_zone.to_string(), _delegate: Default::default(), @@ -740,10 +742,10 @@ impl<'a, C, A> ManagedZoneMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `project` - Identifies the project addressed by this request. - pub fn create(&self, request: &ManagedZone, project: &str) -> ManagedZoneCreateCall<'a, C, A> { + pub fn create(&self, request: ManagedZone, project: &str) -> ManagedZoneCreateCall<'a, C, A> { ManagedZoneCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -971,7 +973,7 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.changes().create(&req, "project", "managedZone") +/// let result = hub.changes().create(req, "project", "managedZone") /// .doit(); /// # } /// ``` @@ -1101,12 +1103,17 @@ impl<'a, C, A> ChangeCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1115,7 +1122,7 @@ impl<'a, C, A> ChangeCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1133,8 +1140,8 @@ impl<'a, C, A> ChangeCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Change) -> ChangeCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Change) -> ChangeCreateCall<'a, C, A> { + self._request = new_value; self } /// Identifies the project addressed by this request. @@ -1376,12 +1383,17 @@ impl<'a, C, A> ChangeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1390,7 +1402,7 @@ impl<'a, C, A> ChangeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1652,12 +1664,17 @@ impl<'a, C, A> ChangeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1666,7 +1683,7 @@ impl<'a, C, A> ChangeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1793,7 +1810,7 @@ impl<'a, C, A> ChangeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.managed_zones().create(&req, "project") +/// let result = hub.managed_zones().create(req, "project") /// .doit(); /// # } /// ``` @@ -1921,12 +1938,17 @@ impl<'a, C, A> ManagedZoneCreateCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1935,7 +1957,7 @@ impl<'a, C, A> ManagedZoneCreateCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1953,8 +1975,8 @@ impl<'a, C, A> ManagedZoneCreateCall<'a, C, A> where C: BorrowMut<hyper::Client> /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ManagedZone) -> ManagedZoneCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ManagedZone) -> ManagedZoneCreateCall<'a, C, A> { + self._request = new_value; self } /// Identifies the project addressed by this request. @@ -2165,12 +2187,17 @@ impl<'a, C, A> ManagedZoneDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -2401,12 +2428,17 @@ impl<'a, C, A> ManagedZoneGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2415,7 +2447,7 @@ impl<'a, C, A> ManagedZoneGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2655,12 +2687,17 @@ impl<'a, C, A> ManagedZoneListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2669,7 +2706,7 @@ impl<'a, C, A> ManagedZoneListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2925,12 +2962,17 @@ impl<'a, C, A> ResourceRecordSetListCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2939,7 +2981,7 @@ impl<'a, C, A> ResourceRecordSetListCall<'a, C, A> where C: BorrowMut<hyper::Cli Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3197,12 +3239,17 @@ impl<'a, C, A> ProjectGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3211,7 +3258,7 @@ impl<'a, C, A> ProjectGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/doubleclickbidmanager1-cli/Cargo.toml b/gen/doubleclickbidmanager1-cli/Cargo.toml index 2f78759e79..1e48003072 100644 --- a/gen/doubleclickbidmanager1-cli/Cargo.toml +++ b/gen/doubleclickbidmanager1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-doubleclickbidmanager1-cli" -version = "0.0.1+20150326" +version = "0.1.0+20150326" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with DoubleClick Bid Manager (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/doubleclickbidmanager1-cli" diff --git a/gen/doubleclickbidmanager1-cli/README.md b/gen/doubleclickbidmanager1-cli/README.md index 6f2e9c0986..bd1204a576 100644 --- a/gen/doubleclickbidmanager1-cli/README.md +++ b/gen/doubleclickbidmanager1-cli/README.md @@ -1,4 +1,105 @@ -# HELLO DOUBLECLICKBIDMANAGER:V1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `doubleclickbidmanager1` command-line interface *(CLI)* allows to use most features of the *Google DoubleClick Bid Manager* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *DoubleClick Bid Manager* API at revision *20150326*. The CLI is at version *0.1.0*. + +```bash + doubleclickbidmanager1 [options] lineitems downloadlineitems -r <kv>... [-p <v>...] [-o <out>] + doubleclickbidmanager1 [options] lineitems uploadlineitems -r <kv>... [-p <v>...] [-o <out>] + doubleclickbidmanager1 [options] queries createquery -r <kv>... [-p <v>...] [-o <out>] + doubleclickbidmanager1 [options] queries deletequery <query-id> [-p <v>...] + doubleclickbidmanager1 [options] queries getquery <query-id> [-p <v>...] [-o <out>] + doubleclickbidmanager1 [options] queries listqueries [-p <v>...] [-o <out>] + doubleclickbidmanager1 [options] queries runquery <query-id> -r <kv>... [-p <v>...] + doubleclickbidmanager1 [options] reports listreports <query-id> [-p <v>...] [-o <out>] + doubleclickbidmanager1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_doubleclickbidmanager1_cli/index.html + +Configuration: + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `doubleclickbidmanager1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/doubleclickbidmanager1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/doubleclickbidmanager1-secret.json`, assuming that the required *doubleclickbidmanager* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `doubleclickbidmanager1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/doubleclickbidmanager1-cli/mkdocs.yml b/gen/doubleclickbidmanager1-cli/mkdocs.yml index 3d333e5ce3..15eee9e5e6 100644 --- a/gen/doubleclickbidmanager1-cli/mkdocs.yml +++ b/gen/doubleclickbidmanager1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: DoubleClick Bid Manager v0.0.1+20150326 +site_name: DoubleClick Bid Manager v0.1.0+20150326 site_url: http://byron.github.io/google-apis-rs/google-doubleclickbidmanager1-cli site_description: Write integrating applications with bcore diff --git a/gen/doubleclickbidmanager1-cli/src/cmn.rs b/gen/doubleclickbidmanager1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/doubleclickbidmanager1-cli/src/cmn.rs +++ b/gen/doubleclickbidmanager1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/doubleclickbidmanager1-cli/src/main.rs b/gen/doubleclickbidmanager1-cli/src/main.rs index 7d77d39ddd..e6d7946a10 100644 --- a/gen/doubleclickbidmanager1-cli/src/main.rs +++ b/gen/doubleclickbidmanager1-cli/src/main.rs @@ -19,29 +19,30 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - doubleclickbidmanager1 [options] lineitems downloadlineitems -r <kv>... [-p <v>]... [-o <out>] - doubleclickbidmanager1 [options] lineitems uploadlineitems -r <kv>... [-p <v>]... [-o <out>] - doubleclickbidmanager1 [options] queries createquery -r <kv>... [-p <v>]... [-o <out>] - doubleclickbidmanager1 [options] queries deletequery <query-id> [-p <v>]... - doubleclickbidmanager1 [options] queries getquery <query-id> [-p <v>]... [-o <out>] - doubleclickbidmanager1 [options] queries listqueries [-p <v>]... [-o <out>] - doubleclickbidmanager1 [options] queries runquery <query-id> -r <kv>... [-p <v>]... - doubleclickbidmanager1 [options] reports listreports <query-id> [-p <v>]... [-o <out>] + doubleclickbidmanager1 [options] lineitems downloadlineitems -r <kv>... [-p <v>...] [-o <out>] + doubleclickbidmanager1 [options] lineitems uploadlineitems -r <kv>... [-p <v>...] [-o <out>] + doubleclickbidmanager1 [options] queries createquery -r <kv>... [-p <v>...] [-o <out>] + doubleclickbidmanager1 [options] queries deletequery <query-id> [-p <v>...] + doubleclickbidmanager1 [options] queries getquery <query-id> [-p <v>...] [-o <out>] + doubleclickbidmanager1 [options] queries listqueries [-p <v>...] [-o <out>] + doubleclickbidmanager1 [options] queries runquery <query-id> -r <kv>... [-p <v>...] + doubleclickbidmanager1 [options] reports listreports <query-id> [-p <v>...] [-o <out>] doubleclickbidmanager1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_doubleclickbidmanager1_cli/index.html Configuration: --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -63,8 +64,42 @@ struct Engine { impl Engine { fn _lineitems_downloadlineitems(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::DownloadLineItemsRequest::default(); - let mut call = self.hub.lineitems().downloadlineitems(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "filter-type" => { + request.filter_type = Some(value.unwrap_or("").to_string()); + }, + "filter-ids" => { + if request.filter_ids.is_none() { + request.filter_ids = Some(Default::default()); + } + request.filter_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "format" => { + request.format = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.lineitems().downloadlineitems(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -86,31 +121,6 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "filter-type" => { - request.filter_type = Some(value.unwrap_or("").to_string()); - }, - "filter-ids" => { - if request.filter_ids.is_none() { - request.filter_ids = Some(Default::default()); - } - request.filter_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "format" => { - request.format = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None @@ -132,8 +142,39 @@ impl Engine { fn _lineitems_uploadlineitems(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::UploadLineItemsRequest::default(); - let mut call = self.hub.lineitems().uploadlineitems(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "line-items" => { + request.line_items = Some(value.unwrap_or("").to_string()); + }, + "dry-run" => { + request.dry_run = Some(arg_from_str(value.unwrap_or("false"), err, "dry-run", "boolean")); + }, + "format" => { + request.format = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.lineitems().uploadlineitems(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -155,28 +196,6 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "line-items" => { - request.line_items = Some(value.unwrap_or("").to_string()); - }, - "dry-run" => { - request.dry_run = Some(arg_from_str(value.unwrap_or("false"), err, "dry-run", "boolean")); - }, - "format" => { - request.format = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None @@ -198,36 +217,23 @@ impl Engine { fn _queries_createquery(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Query::default(); - let mut call = self.hub.queries().createquery(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Query::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_metadata_init(request: &mut api::Query) { if request.metadata.is_none() { request.metadata = Some(Default::default()); @@ -246,7 +252,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -352,10 +358,32 @@ impl Engine { request.metadata.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.queries().createquery(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None @@ -504,8 +532,42 @@ impl Engine { fn _queries_runquery(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::RunQueryRequest::default(); - let mut call = self.hub.queries().runquery(&request, &self.opt.arg_query_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "report-data-end-time-ms" => { + request.report_data_end_time_ms = Some(value.unwrap_or("").to_string()); + }, + "timezone-code" => { + request.timezone_code = Some(value.unwrap_or("").to_string()); + }, + "report-data-start-time-ms" => { + request.report_data_start_time_ms = Some(value.unwrap_or("").to_string()); + }, + "data-range" => { + request.data_range = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.queries().runquery(request, &self.opt.arg_query_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -527,31 +589,6 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "report-data-end-time-ms" => { - request.report_data_end_time_ms = Some(value.unwrap_or("").to_string()); - }, - "timezone-code" => { - request.timezone_code = Some(value.unwrap_or("").to_string()); - }, - "report-data-start-time-ms" => { - request.report_data_start_time_ms = Some(value.unwrap_or("").to_string()); - }, - "data-range" => { - request.data_range = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None @@ -715,6 +752,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -722,8 +760,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/doubleclickbidmanager1/Cargo.toml b/gen/doubleclickbidmanager1/Cargo.toml index 67344ad6f4..546244700f 100644 --- a/gen/doubleclickbidmanager1/Cargo.toml +++ b/gen/doubleclickbidmanager1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-doubleclickbidmanager1" -version = "0.1.5+20150326" +version = "0.1.6+20150326" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with DoubleClick Bid Manager (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/doubleclickbidmanager1" diff --git a/gen/doubleclickbidmanager1/README.md b/gen/doubleclickbidmanager1/README.md index 142374c500..b80e5d3b0a 100644 --- a/gen/doubleclickbidmanager1/README.md +++ b/gen/doubleclickbidmanager1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-doubleclickbidmanager1` library allows access to all features of the *Google DoubleClick Bid Manager* service. -This documentation was generated from *DoubleClick Bid Manager* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *doubleclickbidmanager:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *DoubleClick Bid Manager* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *doubleclickbidmanager:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *DoubleClick Bid Manager* *v1* API can be found at the [official documentation site](https://developers.google.com/bid-manager/). @@ -104,14 +104,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/doubleclickbidmanager1/src/cmn.rs b/gen/doubleclickbidmanager1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/doubleclickbidmanager1/src/cmn.rs +++ b/gen/doubleclickbidmanager1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/doubleclickbidmanager1/src/lib.rs b/gen/doubleclickbidmanager1/src/lib.rs index b1e9fb7b72..c3437654cf 100644 --- a/gen/doubleclickbidmanager1/src/lib.rs +++ b/gen/doubleclickbidmanager1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *DoubleClick Bid Manager* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *doubleclickbidmanager:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *DoubleClick Bid Manager* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *doubleclickbidmanager:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *DoubleClick Bid Manager* *v1* API can be found at the //! [official documentation site](https://developers.google.com/bid-manager/). @@ -105,14 +105,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -200,7 +201,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -252,14 +253,15 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -280,7 +282,7 @@ impl<'a, C, A> DoubleClickBidManager<C, A> DoubleClickBidManager { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -295,7 +297,7 @@ impl<'a, C, A> DoubleClickBidManager<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -792,10 +794,10 @@ impl<'a, C, A> LineitemMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn uploadlineitems(&self, request: &UploadLineItemsRequest) -> LineitemUploadlineitemCall<'a, C, A> { + pub fn uploadlineitems(&self, request: UploadLineItemsRequest) -> LineitemUploadlineitemCall<'a, C, A> { LineitemUploadlineitemCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _additional_params: Default::default(), } @@ -808,10 +810,10 @@ impl<'a, C, A> LineitemMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn downloadlineitems(&self, request: &DownloadLineItemsRequest) -> LineitemDownloadlineitemCall<'a, C, A> { + pub fn downloadlineitems(&self, request: DownloadLineItemsRequest) -> LineitemDownloadlineitemCall<'a, C, A> { LineitemDownloadlineitemCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _additional_params: Default::default(), } @@ -949,10 +951,10 @@ impl<'a, C, A> QueryMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn createquery(&self, request: &Query) -> QueryCreatequeryCall<'a, C, A> { + pub fn createquery(&self, request: Query) -> QueryCreatequeryCall<'a, C, A> { QueryCreatequeryCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _additional_params: Default::default(), } @@ -982,10 +984,10 @@ impl<'a, C, A> QueryMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `queryId` - Query ID to run. - pub fn runquery(&self, request: &RunQueryRequest, query_id: &str) -> QueryRunqueryCall<'a, C, A> { + pub fn runquery(&self, request: RunQueryRequest, query_id: &str) -> QueryRunqueryCall<'a, C, A> { QueryRunqueryCall { hub: self.hub, - _request: request.clone(), + _request: request, _query_id: query_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), @@ -1033,7 +1035,7 @@ impl<'a, C, A> QueryMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.lineitems().uploadlineitems(&req) +/// let result = hub.lineitems().uploadlineitems(req) /// .doit(); /// # } /// ``` @@ -1128,12 +1130,17 @@ impl<'a, C, A> LineitemUploadlineitemCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1142,7 +1149,7 @@ impl<'a, C, A> LineitemUploadlineitemCall<'a, C, A> where C: BorrowMut<hyper::Cl Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1160,8 +1167,8 @@ impl<'a, C, A> LineitemUploadlineitemCall<'a, C, A> where C: BorrowMut<hyper::Cl /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &UploadLineItemsRequest) -> LineitemUploadlineitemCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: UploadLineItemsRequest) -> LineitemUploadlineitemCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -1232,7 +1239,7 @@ impl<'a, C, A> LineitemUploadlineitemCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.lineitems().downloadlineitems(&req) +/// let result = hub.lineitems().downloadlineitems(req) /// .doit(); /// # } /// ``` @@ -1327,12 +1334,17 @@ impl<'a, C, A> LineitemDownloadlineitemCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1341,7 +1353,7 @@ impl<'a, C, A> LineitemDownloadlineitemCall<'a, C, A> where C: BorrowMut<hyper:: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1359,8 +1371,8 @@ impl<'a, C, A> LineitemDownloadlineitemCall<'a, C, A> where C: BorrowMut<hyper:: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &DownloadLineItemsRequest) -> LineitemDownloadlineitemCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: DownloadLineItemsRequest) -> LineitemDownloadlineitemCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -1537,12 +1549,17 @@ impl<'a, C, A> ReportListreportCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1551,7 +1568,7 @@ impl<'a, C, A> ReportListreportCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1722,12 +1739,17 @@ impl<'a, C, A> QueryListqueryCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1736,7 +1758,7 @@ impl<'a, C, A> QueryListqueryCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1923,12 +1945,17 @@ impl<'a, C, A> QueryGetqueryCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1937,7 +1964,7 @@ impl<'a, C, A> QueryGetqueryCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2028,7 +2055,7 @@ impl<'a, C, A> QueryGetqueryCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.queries().createquery(&req) +/// let result = hub.queries().createquery(req) /// .doit(); /// # } /// ``` @@ -2123,12 +2150,17 @@ impl<'a, C, A> QueryCreatequeryCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2137,7 +2169,7 @@ impl<'a, C, A> QueryCreatequeryCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2155,8 +2187,8 @@ impl<'a, C, A> QueryCreatequeryCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Query) -> QueryCreatequeryCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Query) -> QueryCreatequeryCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -2332,12 +2364,17 @@ impl<'a, C, A> QueryDeletequeryCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -2427,7 +2464,7 @@ impl<'a, C, A> QueryDeletequeryCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.queries().runquery(&req, "queryId") +/// let result = hub.queries().runquery(req, "queryId") /// .doit(); /// # } /// ``` @@ -2547,12 +2584,17 @@ impl<'a, C, A> QueryRunqueryCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -2569,8 +2611,8 @@ impl<'a, C, A> QueryRunqueryCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &RunQueryRequest) -> QueryRunqueryCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: RunQueryRequest) -> QueryRunqueryCall<'a, C, A> { + self._request = new_value; self } /// Query ID to run. diff --git a/gen/doubleclicksearch2-cli/Cargo.toml b/gen/doubleclicksearch2-cli/Cargo.toml index 25bdaa16f5..7c4a12d671 100644 --- a/gen/doubleclicksearch2-cli/Cargo.toml +++ b/gen/doubleclicksearch2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-doubleclicksearch2-cli" -version = "0.0.1+20150303" +version = "0.1.0+20150303" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with doubleclicksearch (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/doubleclicksearch2-cli" diff --git a/gen/doubleclicksearch2-cli/README.md b/gen/doubleclicksearch2-cli/README.md index 95f5cfe03c..f0e24ef6bf 100644 --- a/gen/doubleclicksearch2-cli/README.md +++ b/gen/doubleclicksearch2-cli/README.md @@ -1,4 +1,111 @@ -# HELLO DOUBLECLICKSEARCH:V2 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `doubleclicksearch2` command-line interface *(CLI)* allows to use most features of the *Google doubleclicksearch* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *doubleclicksearch* API at revision *20150303*. The CLI is at version *0.1.0*. + +```bash + doubleclicksearch2 [options] conversion get <agency-id> <advertiser-id> <engine-account-id> <end-date> <row-count> <start-date> <start-row> [-p <v>...] [-o <out>] + doubleclicksearch2 [options] conversion insert -r <kv>... [-p <v>...] [-o <out>] + doubleclicksearch2 [options] conversion patch <advertiser-id> <agency-id> <end-date> <engine-account-id> <row-count> <start-date> <start-row> -r <kv>... [-p <v>...] [-o <out>] + doubleclicksearch2 [options] conversion update -r <kv>... [-p <v>...] [-o <out>] + doubleclicksearch2 [options] conversion update-availability -r <kv>... [-p <v>...] [-o <out>] + doubleclicksearch2 [options] reports generate -r <kv>... [-p <v>...] [-o <out>] + doubleclicksearch2 [options] reports get <report-id> [-p <v>...] [-o <out>] + doubleclicksearch2 [options] reports get-file <report-id> <report-fragment> [-p <v>...] [-o <out>] + doubleclicksearch2 [options] reports request -r <kv>... [-p <v>...] [-o <out>] + doubleclicksearch2 [options] saved-columns list <agency-id> <advertiser-id> [-p <v>...] [-o <out>] + doubleclicksearch2 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_doubleclicksearch2_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `doubleclicksearch2-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/doubleclicksearch2-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/doubleclicksearch2-secret.json`, assuming that the required *doubleclicksearch* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `doubleclicksearch2 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/doubleclicksearch2-cli/mkdocs.yml b/gen/doubleclicksearch2-cli/mkdocs.yml index 640977eece..6c3c82aac1 100644 --- a/gen/doubleclicksearch2-cli/mkdocs.yml +++ b/gen/doubleclicksearch2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: doubleclicksearch v0.0.1+20150303 +site_name: doubleclicksearch v0.1.0+20150303 site_url: http://byron.github.io/google-apis-rs/google-doubleclicksearch2-cli site_description: Write integrating applications with bcore diff --git a/gen/doubleclicksearch2-cli/src/cmn.rs b/gen/doubleclicksearch2-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/doubleclicksearch2-cli/src/cmn.rs +++ b/gen/doubleclicksearch2-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/doubleclicksearch2-cli/src/main.rs b/gen/doubleclicksearch2-cli/src/main.rs index be9b9e50ab..b62982b009 100644 --- a/gen/doubleclicksearch2-cli/src/main.rs +++ b/gen/doubleclicksearch2-cli/src/main.rs @@ -19,35 +19,36 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - doubleclicksearch2 [options] conversion get <agency-id> <advertiser-id> <engine-account-id> <end-date> <row-count> <start-date> <start-row> [-p <v>]... [-o <out>] - doubleclicksearch2 [options] conversion insert -r <kv>... [-p <v>]... [-o <out>] - doubleclicksearch2 [options] conversion patch <advertiser-id> <agency-id> <end-date> <engine-account-id> <row-count> <start-date> <start-row> -r <kv>... [-p <v>]... [-o <out>] - doubleclicksearch2 [options] conversion update -r <kv>... [-p <v>]... [-o <out>] - doubleclicksearch2 [options] conversion update-availability -r <kv>... [-p <v>]... [-o <out>] - doubleclicksearch2 [options] reports generate -r <kv>... [-p <v>]... [-o <out>] - doubleclicksearch2 [options] reports get <report-id> [-p <v>]... [-o <out>] - doubleclicksearch2 [options] reports get-file <report-id> <report-fragment> [-p <v>]... [-o <out>] - doubleclicksearch2 [options] reports request -r <kv>... [-p <v>]... [-o <out>] - doubleclicksearch2 [options] saved-columns list <agency-id> <advertiser-id> [-p <v>]... [-o <out>] + doubleclicksearch2 [options] conversion get <agency-id> <advertiser-id> <engine-account-id> <end-date> <row-count> <start-date> <start-row> [-p <v>...] [-o <out>] + doubleclicksearch2 [options] conversion insert -r <kv>... [-p <v>...] [-o <out>] + doubleclicksearch2 [options] conversion patch <advertiser-id> <agency-id> <end-date> <engine-account-id> <row-count> <start-date> <start-row> -r <kv>... [-p <v>...] [-o <out>] + doubleclicksearch2 [options] conversion update -r <kv>... [-p <v>...] [-o <out>] + doubleclicksearch2 [options] conversion update-availability -r <kv>... [-p <v>...] [-o <out>] + doubleclicksearch2 [options] reports generate -r <kv>... [-p <v>...] [-o <out>] + doubleclicksearch2 [options] reports get <report-id> [-p <v>...] [-o <out>] + doubleclicksearch2 [options] reports get-file <report-id> <report-fragment> [-p <v>...] [-o <out>] + doubleclicksearch2 [options] reports request -r <kv>... [-p <v>...] [-o <out>] + doubleclicksearch2 [options] saved-columns list <agency-id> <advertiser-id> [-p <v>...] [-o <out>] doubleclicksearch2 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_doubleclicksearch2_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -112,6 +113,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -128,8 +132,33 @@ impl Engine { fn _conversion_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::ConversionList::default(); - let mut call = self.hub.conversion().insert(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.conversion().insert(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -151,27 +180,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -188,12 +204,37 @@ impl Engine { fn _conversion_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::ConversionList::default(); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } let end_date: i32 = arg_from_str(&self.opt.arg_end_date, err, "<end-date>", "integer"); let row_count: i32 = arg_from_str(&self.opt.arg_row_count, err, "<row-count>", "integer"); let start_date: i32 = arg_from_str(&self.opt.arg_start_date, err, "<start-date>", "integer"); let start_row: u32 = arg_from_str(&self.opt.arg_start_row, err, "<start-row>", "integer"); - let mut call = self.hub.conversion().patch(&request, &self.opt.arg_advertiser_id, &self.opt.arg_agency_id, end_date, &self.opt.arg_engine_account_id, row_count, start_date, start_row); + let mut call = self.hub.conversion().patch(request, &self.opt.arg_advertiser_id, &self.opt.arg_agency_id, end_date, &self.opt.arg_engine_account_id, row_count, start_date, start_row); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -215,27 +256,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -252,8 +280,33 @@ impl Engine { fn _conversion_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::ConversionList::default(); - let mut call = self.hub.conversion().update(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.conversion().update(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -275,27 +328,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -312,8 +352,30 @@ impl Engine { fn _conversion_update_availability(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::UpdateAvailabilityRequest::default(); - let mut call = self.hub.conversion().update_availability(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.conversion().update_availability(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -335,24 +397,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -369,36 +421,23 @@ impl Engine { fn _reports_generate(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::ReportRequest::default(); - let mut call = self.hub.reports().generate(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ReportRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_report_scope_init(request: &mut api::ReportRequest) { if request.report_scope.is_none() { request.report_scope = Some(Default::default()); @@ -411,7 +450,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "report-scope.ad-group-id" => { request_report_scope_init(&mut request); request.report_scope.as_mut().unwrap().ad_group_id = Some(value.unwrap_or("").to_string()); @@ -493,15 +532,40 @@ impl Engine { request.include_removed_entities = Some(arg_from_str(value.unwrap_or("false"), err, "include-removed-entities", "boolean")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.reports().generate(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -545,6 +609,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -593,6 +660,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -612,36 +682,23 @@ impl Engine { fn _reports_request(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::ReportRequest::default(); - let mut call = self.hub.reports().request(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ReportRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_report_scope_init(request: &mut api::ReportRequest) { if request.report_scope.is_none() { request.report_scope = Some(Default::default()); @@ -654,7 +711,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "report-scope.ad-group-id" => { request_report_scope_init(&mut request); request.report_scope.as_mut().unwrap().ad_group_id = Some(value.unwrap_or("").to_string()); @@ -736,15 +793,40 @@ impl Engine { request.include_removed_entities = Some(arg_from_str(value.unwrap_or("false"), err, "include-removed-entities", "boolean")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.reports().request(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -788,6 +870,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -909,6 +994,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -916,8 +1002,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/doubleclicksearch2/Cargo.toml b/gen/doubleclicksearch2/Cargo.toml index cc2a7ec17b..ecf9b7695f 100644 --- a/gen/doubleclicksearch2/Cargo.toml +++ b/gen/doubleclicksearch2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-doubleclicksearch2" -version = "0.1.5+20150303" +version = "0.1.6+20150303" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with doubleclicksearch (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/doubleclicksearch2" diff --git a/gen/doubleclicksearch2/README.md b/gen/doubleclicksearch2/README.md index 7d2bfea501..a42321bd28 100644 --- a/gen/doubleclicksearch2/README.md +++ b/gen/doubleclicksearch2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-doubleclicksearch2` library allows access to all features of the *Google doubleclicksearch* service. -This documentation was generated from *doubleclicksearch* crate version *0.1.5+20150303*, where *20150303* is the exact revision of the *doubleclicksearch:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *doubleclicksearch* crate version *0.1.6+20150303*, where *20150303* is the exact revision of the *doubleclicksearch:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *doubleclicksearch* *v2* API can be found at the [official documentation site](https://developers.google.com/doubleclick-search/). @@ -110,14 +110,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/doubleclicksearch2/src/cmn.rs b/gen/doubleclicksearch2/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/doubleclicksearch2/src/cmn.rs +++ b/gen/doubleclicksearch2/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/doubleclicksearch2/src/lib.rs b/gen/doubleclicksearch2/src/lib.rs index dfad7d3e36..12bd60ce24 100644 --- a/gen/doubleclicksearch2/src/lib.rs +++ b/gen/doubleclicksearch2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *doubleclicksearch* crate version *0.1.5+20150303*, where *20150303* is the exact revision of the *doubleclicksearch:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *doubleclicksearch* crate version *0.1.6+20150303*, where *20150303* is the exact revision of the *doubleclicksearch:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *doubleclicksearch* *v2* API can be found at the //! [official documentation site](https://developers.google.com/doubleclick-search/). @@ -111,14 +111,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -206,7 +207,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -280,14 +281,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -308,7 +310,7 @@ impl<'a, C, A> Doubleclicksearch<C, A> Doubleclicksearch { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -323,7 +325,7 @@ impl<'a, C, A> Doubleclicksearch<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -892,10 +894,10 @@ impl<'a, C, A> ConversionMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &ConversionList) -> ConversionInsertCall<'a, C, A> { + pub fn insert(&self, request: ConversionList) -> ConversionInsertCall<'a, C, A> { ConversionInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -942,10 +944,10 @@ impl<'a, C, A> ConversionMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn update_availability(&self, request: &UpdateAvailabilityRequest) -> ConversionUpdateAvailabilityCall<'a, C, A> { + pub fn update_availability(&self, request: UpdateAvailabilityRequest) -> ConversionUpdateAvailabilityCall<'a, C, A> { ConversionUpdateAvailabilityCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -966,10 +968,10 @@ impl<'a, C, A> ConversionMethods<'a, C, A> { /// * `rowCount` - The number of conversions to return per call. /// * `startDate` - First date (inclusive) on which to retrieve conversions. Format is yyyymmdd. /// * `startRow` - The 0-based starting index for retrieving conversions results. - pub fn patch(&self, request: &ConversionList, advertiser_id: &str, agency_id: &str, end_date: i32, engine_account_id: &str, row_count: i32, start_date: i32, start_row: u32) -> ConversionPatchCall<'a, C, A> { + pub fn patch(&self, request: ConversionList, advertiser_id: &str, agency_id: &str, end_date: i32, engine_account_id: &str, row_count: i32, start_date: i32, start_row: u32) -> ConversionPatchCall<'a, C, A> { ConversionPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _advertiser_id: advertiser_id.to_string(), _agency_id: agency_id.to_string(), _end_date: end_date, @@ -990,10 +992,10 @@ impl<'a, C, A> ConversionMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn update(&self, request: &ConversionList) -> ConversionUpdateCall<'a, C, A> { + pub fn update(&self, request: ConversionList) -> ConversionUpdateCall<'a, C, A> { ConversionUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1127,10 +1129,10 @@ impl<'a, C, A> ReportMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn generate(&self, request: &ReportRequest) -> ReportGenerateCall<'a, C, A> { + pub fn generate(&self, request: ReportRequest) -> ReportGenerateCall<'a, C, A> { ReportGenerateCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1161,10 +1163,10 @@ impl<'a, C, A> ReportMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn request(&self, request: &ReportRequest) -> ReportRequestCall<'a, C, A> { + pub fn request(&self, request: ReportRequest) -> ReportRequestCall<'a, C, A> { ReportRequestCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1212,7 +1214,7 @@ impl<'a, C, A> ReportMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.conversion().insert(&req) +/// let result = hub.conversion().insert(req) /// .doit(); /// # } /// ``` @@ -1314,12 +1316,17 @@ impl<'a, C, A> ConversionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1328,7 +1335,7 @@ impl<'a, C, A> ConversionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1346,8 +1353,8 @@ impl<'a, C, A> ConversionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ConversionList) -> ConversionInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ConversionList) -> ConversionInsertCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -1579,12 +1586,17 @@ impl<'a, C, A> ConversionGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1593,7 +1605,7 @@ impl<'a, C, A> ConversionGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1788,7 +1800,7 @@ impl<'a, C, A> ConversionGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.conversion().update_availability(&req) +/// let result = hub.conversion().update_availability(req) /// .doit(); /// # } /// ``` @@ -1890,12 +1902,17 @@ impl<'a, C, A> ConversionUpdateAvailabilityCall<'a, C, A> where C: BorrowMut<hyp if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1904,7 +1921,7 @@ impl<'a, C, A> ConversionUpdateAvailabilityCall<'a, C, A> where C: BorrowMut<hyp Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1922,8 +1939,8 @@ impl<'a, C, A> ConversionUpdateAvailabilityCall<'a, C, A> where C: BorrowMut<hyp /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &UpdateAvailabilityRequest) -> ConversionUpdateAvailabilityCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: UpdateAvailabilityRequest) -> ConversionUpdateAvailabilityCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -2010,7 +2027,7 @@ impl<'a, C, A> ConversionUpdateAvailabilityCall<'a, C, A> where C: BorrowMut<hyp /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.conversion().patch(&req, "advertiserId", "agencyId", -66, "engineAccountId", -21, -21, 67) +/// let result = hub.conversion().patch(req, "advertiserId", "agencyId", -66, "engineAccountId", -21, -21, 67) /// .doit(); /// # } /// ``` @@ -2126,12 +2143,17 @@ impl<'a, C, A> ConversionPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2140,7 +2162,7 @@ impl<'a, C, A> ConversionPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2158,8 +2180,8 @@ impl<'a, C, A> ConversionPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ConversionList) -> ConversionPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ConversionList) -> ConversionPatchCall<'a, C, A> { + self._request = new_value; self } /// Numeric ID of the advertiser. @@ -2316,7 +2338,7 @@ impl<'a, C, A> ConversionPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.conversion().update(&req) +/// let result = hub.conversion().update(req) /// .doit(); /// # } /// ``` @@ -2418,12 +2440,17 @@ impl<'a, C, A> ConversionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2432,7 +2459,7 @@ impl<'a, C, A> ConversionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2450,8 +2477,8 @@ impl<'a, C, A> ConversionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ConversionList) -> ConversionUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ConversionList) -> ConversionUpdateCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -2653,12 +2680,17 @@ impl<'a, C, A> SavedColumnListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2667,7 +2699,7 @@ impl<'a, C, A> SavedColumnListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2901,12 +2933,17 @@ impl<'a, C, A> ReportGetFileCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -3022,7 +3059,7 @@ impl<'a, C, A> ReportGetFileCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.reports().generate(&req) +/// let result = hub.reports().generate(req) /// .doit(); /// # } /// ``` @@ -3124,12 +3161,17 @@ impl<'a, C, A> ReportGenerateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3138,7 +3180,7 @@ impl<'a, C, A> ReportGenerateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3156,8 +3198,8 @@ impl<'a, C, A> ReportGenerateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ReportRequest) -> ReportGenerateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ReportRequest) -> ReportGenerateCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -3357,12 +3399,17 @@ impl<'a, C, A> ReportGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3371,7 +3418,7 @@ impl<'a, C, A> ReportGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3478,7 +3525,7 @@ impl<'a, C, A> ReportGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.reports().request(&req) +/// let result = hub.reports().request(req) /// .doit(); /// # } /// ``` @@ -3580,12 +3627,17 @@ impl<'a, C, A> ReportRequestCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3594,7 +3646,7 @@ impl<'a, C, A> ReportRequestCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3612,8 +3664,8 @@ impl<'a, C, A> ReportRequestCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ReportRequest) -> ReportRequestCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ReportRequest) -> ReportRequestCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong diff --git a/gen/drive2-cli/Cargo.toml b/gen/drive2-cli/Cargo.toml index f2e5ed3826..b0d4ee2b08 100644 --- a/gen/drive2-cli/Cargo.toml +++ b/gen/drive2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-drive2-cli" -version = "0.0.1+20150326" +version = "0.1.0+20150326" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with drive (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/drive2-cli" diff --git a/gen/drive2-cli/README.md b/gen/drive2-cli/README.md index f608701e6a..bb3da110f4 100644 --- a/gen/drive2-cli/README.md +++ b/gen/drive2-cli/README.md @@ -1,4 +1,160 @@ -# HELLO DRIVE:V2 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `drive2` command-line interface *(CLI)* allows to use most features of the *Google drive* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *drive* API at revision *20150326*. The CLI is at version *0.1.0*. + +```bash + drive2 [options] about get [-p <v>...] [-o <out>] + drive2 [options] apps get <app-id> [-p <v>...] [-o <out>] + drive2 [options] apps list [-p <v>...] [-o <out>] + drive2 [options] changes get <change-id> [-p <v>...] [-o <out>] + drive2 [options] changes list [-p <v>...] [-o <out>] + drive2 [options] changes watch -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] channels stop -r <kv>... [-p <v>...] + drive2 [options] children delete <folder-id> <child-id> [-p <v>...] + drive2 [options] children get <folder-id> <child-id> [-p <v>...] [-o <out>] + drive2 [options] children insert <folder-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] children list <folder-id> [-p <v>...] [-o <out>] + drive2 [options] comments delete <file-id> <comment-id> [-p <v>...] + drive2 [options] comments get <file-id> <comment-id> [-p <v>...] [-o <out>] + drive2 [options] comments insert <file-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] comments list <file-id> [-p <v>...] [-o <out>] + drive2 [options] comments patch <file-id> <comment-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] comments update <file-id> <comment-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] files copy <file-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] files delete <file-id> [-p <v>...] + drive2 [options] files empty-trash [-p <v>...] + drive2 [options] files get <file-id> [-p <v>...] [-o <out>] + drive2 [options] files insert -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + drive2 [options] files list [-p <v>...] [-o <out>] + drive2 [options] files patch <file-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] files touch <file-id> [-p <v>...] [-o <out>] + drive2 [options] files trash <file-id> [-p <v>...] [-o <out>] + drive2 [options] files untrash <file-id> [-p <v>...] [-o <out>] + drive2 [options] files update <file-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + drive2 [options] files watch <file-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] parents delete <file-id> <parent-id> [-p <v>...] + drive2 [options] parents get <file-id> <parent-id> [-p <v>...] [-o <out>] + drive2 [options] parents insert <file-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] parents list <file-id> [-p <v>...] [-o <out>] + drive2 [options] permissions delete <file-id> <permission-id> [-p <v>...] + drive2 [options] permissions get <file-id> <permission-id> [-p <v>...] [-o <out>] + drive2 [options] permissions get-id-for-email <email> [-p <v>...] [-o <out>] + drive2 [options] permissions insert <file-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] permissions list <file-id> [-p <v>...] [-o <out>] + drive2 [options] permissions patch <file-id> <permission-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] permissions update <file-id> <permission-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] properties delete <file-id> <property-key> [-p <v>...] + drive2 [options] properties get <file-id> <property-key> [-p <v>...] [-o <out>] + drive2 [options] properties insert <file-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] properties list <file-id> [-p <v>...] [-o <out>] + drive2 [options] properties patch <file-id> <property-key> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] properties update <file-id> <property-key> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] realtime get <file-id> [-p <v>...] [-o <out>] + drive2 [options] realtime update <file-id> -u (simple|resumable) <file> <mime> [-p <v>...] + drive2 [options] replies delete <file-id> <comment-id> <reply-id> [-p <v>...] + drive2 [options] replies get <file-id> <comment-id> <reply-id> [-p <v>...] [-o <out>] + drive2 [options] replies insert <file-id> <comment-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] replies list <file-id> <comment-id> [-p <v>...] [-o <out>] + drive2 [options] replies patch <file-id> <comment-id> <reply-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] replies update <file-id> <comment-id> <reply-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] revisions delete <file-id> <revision-id> [-p <v>...] + drive2 [options] revisions get <file-id> <revision-id> [-p <v>...] [-o <out>] + drive2 [options] revisions list <file-id> [-p <v>...] [-o <out>] + drive2 [options] revisions patch <file-id> <revision-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] revisions update <file-id> <revision-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_drive2_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `drive2-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/drive2-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/drive2-secret.json`, assuming that the required *drive* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `drive2 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/drive2-cli/mkdocs.yml b/gen/drive2-cli/mkdocs.yml index 37a34c2823..e9bde4857e 100644 --- a/gen/drive2-cli/mkdocs.yml +++ b/gen/drive2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: drive v0.0.1+20150326 +site_name: drive v0.1.0+20150326 site_url: http://byron.github.io/google-apis-rs/google-drive2-cli site_description: Write integrating applications with bcore diff --git a/gen/drive2-cli/src/cmn.rs b/gen/drive2-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/drive2-cli/src/cmn.rs +++ b/gen/drive2-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/drive2-cli/src/main.rs b/gen/drive2-cli/src/main.rs index fe8a8773c0..2f657f55fb 100644 --- a/gen/drive2-cli/src/main.rs +++ b/gen/drive2-cli/src/main.rs @@ -19,84 +19,85 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - drive2 [options] about get [-p <v>]... [-o <out>] - drive2 [options] apps get <app-id> [-p <v>]... [-o <out>] - drive2 [options] apps list [-p <v>]... [-o <out>] - drive2 [options] changes get <change-id> [-p <v>]... [-o <out>] - drive2 [options] changes list [-p <v>]... [-o <out>] - drive2 [options] changes watch -r <kv>... [-p <v>]... [-o <out>] - drive2 [options] channels stop -r <kv>... [-p <v>]... - drive2 [options] children delete <folder-id> <child-id> [-p <v>]... - drive2 [options] children get <folder-id> <child-id> [-p <v>]... [-o <out>] - drive2 [options] children insert <folder-id> -r <kv>... [-p <v>]... [-o <out>] - drive2 [options] children list <folder-id> [-p <v>]... [-o <out>] - drive2 [options] comments delete <file-id> <comment-id> [-p <v>]... - drive2 [options] comments get <file-id> <comment-id> [-p <v>]... [-o <out>] - drive2 [options] comments insert <file-id> -r <kv>... [-p <v>]... [-o <out>] - drive2 [options] comments list <file-id> [-p <v>]... [-o <out>] - drive2 [options] comments patch <file-id> <comment-id> -r <kv>... [-p <v>]... [-o <out>] - drive2 [options] comments update <file-id> <comment-id> -r <kv>... [-p <v>]... [-o <out>] - drive2 [options] files copy <file-id> -r <kv>... [-p <v>]... [-o <out>] - drive2 [options] files delete <file-id> [-p <v>]... - drive2 [options] files empty-trash [-p <v>]... - drive2 [options] files get <file-id> [-p <v>]... [-o <out>] - drive2 [options] files insert -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] - drive2 [options] files list [-p <v>]... [-o <out>] - drive2 [options] files patch <file-id> -r <kv>... [-p <v>]... [-o <out>] - drive2 [options] files touch <file-id> [-p <v>]... [-o <out>] - drive2 [options] files trash <file-id> [-p <v>]... [-o <out>] - drive2 [options] files untrash <file-id> [-p <v>]... [-o <out>] - drive2 [options] files update <file-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] - drive2 [options] files watch <file-id> -r <kv>... [-p <v>]... [-o <out>] - drive2 [options] parents delete <file-id> <parent-id> [-p <v>]... - drive2 [options] parents get <file-id> <parent-id> [-p <v>]... [-o <out>] - drive2 [options] parents insert <file-id> -r <kv>... [-p <v>]... [-o <out>] - drive2 [options] parents list <file-id> [-p <v>]... [-o <out>] - drive2 [options] permissions delete <file-id> <permission-id> [-p <v>]... - drive2 [options] permissions get <file-id> <permission-id> [-p <v>]... [-o <out>] - drive2 [options] permissions get-id-for-email <email> [-p <v>]... [-o <out>] - drive2 [options] permissions insert <file-id> -r <kv>... [-p <v>]... [-o <out>] - drive2 [options] permissions list <file-id> [-p <v>]... [-o <out>] - drive2 [options] permissions patch <file-id> <permission-id> -r <kv>... [-p <v>]... [-o <out>] - drive2 [options] permissions update <file-id> <permission-id> -r <kv>... [-p <v>]... [-o <out>] - drive2 [options] properties delete <file-id> <property-key> [-p <v>]... - drive2 [options] properties get <file-id> <property-key> [-p <v>]... [-o <out>] - drive2 [options] properties insert <file-id> -r <kv>... [-p <v>]... [-o <out>] - drive2 [options] properties list <file-id> [-p <v>]... [-o <out>] - drive2 [options] properties patch <file-id> <property-key> -r <kv>... [-p <v>]... [-o <out>] - drive2 [options] properties update <file-id> <property-key> -r <kv>... [-p <v>]... [-o <out>] - drive2 [options] realtime get <file-id> [-p <v>]... [-o <out>] - drive2 [options] realtime update <file-id> -u (simple|resumable) <file> <mime> [-p <v>]... - drive2 [options] replies delete <file-id> <comment-id> <reply-id> [-p <v>]... - drive2 [options] replies get <file-id> <comment-id> <reply-id> [-p <v>]... [-o <out>] - drive2 [options] replies insert <file-id> <comment-id> -r <kv>... [-p <v>]... [-o <out>] - drive2 [options] replies list <file-id> <comment-id> [-p <v>]... [-o <out>] - drive2 [options] replies patch <file-id> <comment-id> <reply-id> -r <kv>... [-p <v>]... [-o <out>] - drive2 [options] replies update <file-id> <comment-id> <reply-id> -r <kv>... [-p <v>]... [-o <out>] - drive2 [options] revisions delete <file-id> <revision-id> [-p <v>]... - drive2 [options] revisions get <file-id> <revision-id> [-p <v>]... [-o <out>] - drive2 [options] revisions list <file-id> [-p <v>]... [-o <out>] - drive2 [options] revisions patch <file-id> <revision-id> -r <kv>... [-p <v>]... [-o <out>] - drive2 [options] revisions update <file-id> <revision-id> -r <kv>... [-p <v>]... [-o <out>] + drive2 [options] about get [-p <v>...] [-o <out>] + drive2 [options] apps get <app-id> [-p <v>...] [-o <out>] + drive2 [options] apps list [-p <v>...] [-o <out>] + drive2 [options] changes get <change-id> [-p <v>...] [-o <out>] + drive2 [options] changes list [-p <v>...] [-o <out>] + drive2 [options] changes watch -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] channels stop -r <kv>... [-p <v>...] + drive2 [options] children delete <folder-id> <child-id> [-p <v>...] + drive2 [options] children get <folder-id> <child-id> [-p <v>...] [-o <out>] + drive2 [options] children insert <folder-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] children list <folder-id> [-p <v>...] [-o <out>] + drive2 [options] comments delete <file-id> <comment-id> [-p <v>...] + drive2 [options] comments get <file-id> <comment-id> [-p <v>...] [-o <out>] + drive2 [options] comments insert <file-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] comments list <file-id> [-p <v>...] [-o <out>] + drive2 [options] comments patch <file-id> <comment-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] comments update <file-id> <comment-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] files copy <file-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] files delete <file-id> [-p <v>...] + drive2 [options] files empty-trash [-p <v>...] + drive2 [options] files get <file-id> [-p <v>...] [-o <out>] + drive2 [options] files insert -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + drive2 [options] files list [-p <v>...] [-o <out>] + drive2 [options] files patch <file-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] files touch <file-id> [-p <v>...] [-o <out>] + drive2 [options] files trash <file-id> [-p <v>...] [-o <out>] + drive2 [options] files untrash <file-id> [-p <v>...] [-o <out>] + drive2 [options] files update <file-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + drive2 [options] files watch <file-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] parents delete <file-id> <parent-id> [-p <v>...] + drive2 [options] parents get <file-id> <parent-id> [-p <v>...] [-o <out>] + drive2 [options] parents insert <file-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] parents list <file-id> [-p <v>...] [-o <out>] + drive2 [options] permissions delete <file-id> <permission-id> [-p <v>...] + drive2 [options] permissions get <file-id> <permission-id> [-p <v>...] [-o <out>] + drive2 [options] permissions get-id-for-email <email> [-p <v>...] [-o <out>] + drive2 [options] permissions insert <file-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] permissions list <file-id> [-p <v>...] [-o <out>] + drive2 [options] permissions patch <file-id> <permission-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] permissions update <file-id> <permission-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] properties delete <file-id> <property-key> [-p <v>...] + drive2 [options] properties get <file-id> <property-key> [-p <v>...] [-o <out>] + drive2 [options] properties insert <file-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] properties list <file-id> [-p <v>...] [-o <out>] + drive2 [options] properties patch <file-id> <property-key> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] properties update <file-id> <property-key> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] realtime get <file-id> [-p <v>...] [-o <out>] + drive2 [options] realtime update <file-id> -u (simple|resumable) <file> <mime> [-p <v>...] + drive2 [options] replies delete <file-id> <comment-id> <reply-id> [-p <v>...] + drive2 [options] replies get <file-id> <comment-id> <reply-id> [-p <v>...] [-o <out>] + drive2 [options] replies insert <file-id> <comment-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] replies list <file-id> <comment-id> [-p <v>...] [-o <out>] + drive2 [options] replies patch <file-id> <comment-id> <reply-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] replies update <file-id> <comment-id> <reply-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] revisions delete <file-id> <revision-id> [-p <v>...] + drive2 [options] revisions get <file-id> <revision-id> [-p <v>...] [-o <out>] + drive2 [options] revisions list <file-id> [-p <v>...] [-o <out>] + drive2 [options] revisions patch <file-id> <revision-id> -r <kv>... [-p <v>...] [-o <out>] + drive2 [options] revisions update <file-id> <revision-id> -r <kv>... [-p <v>...] [-o <out>] drive2 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_drive2_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -154,6 +155,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -197,6 +201,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -249,6 +256,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -292,6 +302,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -350,6 +363,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -366,8 +382,64 @@ impl Engine { fn _changes_watch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Channel::default(); - let mut call = self.hub.changes().watch(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "resource-uri" => { + request.resource_uri = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "resource-id" => { + request.resource_id = Some(value.unwrap_or("").to_string()); + }, + "payload" => { + request.payload = Some(arg_from_str(value.unwrap_or("false"), err, "payload", "boolean")); + }, + "token" => { + request.token = Some(value.unwrap_or("").to_string()); + }, + "params" => { + if request.params.is_none() { + request.params = Some(Default::default()); + } + let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); + request.params.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); + }, + "expiration" => { + request.expiration = Some(value.unwrap_or("").to_string()); + }, + "address" => { + request.address = Some(value.unwrap_or("").to_string()); + }, + "type" => { + request.type_ = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.changes().watch(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -404,14 +476,48 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _channels_stop(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::Channel::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "resource-uri" => { request.resource_uri = Some(value.unwrap_or("").to_string()); }, @@ -447,33 +553,11 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _channels_stop(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::Channel::default(); - let mut call = self.hub.channels().stop(&request); + let mut call = self.hub.channels().stop(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -495,58 +579,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "resource-uri" => { - request.resource_uri = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "resource-id" => { - request.resource_id = Some(value.unwrap_or("").to_string()); - }, - "payload" => { - request.payload = Some(arg_from_str(value.unwrap_or("false"), err, "payload", "boolean")); - }, - "token" => { - request.token = Some(value.unwrap_or("").to_string()); - }, - "params" => { - if request.params.is_none() { - request.params = Some(Default::default()); - } - let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); - request.params.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); - }, - "expiration" => { - request.expiration = Some(value.unwrap_or("").to_string()); - }, - "address" => { - request.address = Some(value.unwrap_or("").to_string()); - }, - "type" => { - request.type_ = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -588,6 +628,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -629,6 +672,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -645,8 +691,42 @@ impl Engine { fn _children_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::ChildReference::default(); - let mut call = self.hub.children().insert(&request, &self.opt.arg_folder_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "child-link" => { + request.child_link = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "self-link" => { + request.self_link = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.children().insert(request, &self.opt.arg_folder_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -668,36 +748,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "child-link" => { - request.child_link = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "self-link" => { - request.self_link = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -750,6 +808,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -793,6 +854,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -837,6 +901,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -853,36 +920,23 @@ impl Engine { fn _comments_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Comment::default(); - let mut call = self.hub.comments().insert(&request, &self.opt.arg_file_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Comment::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_author_init(request: &mut api::Comment) { if request.author.is_none() { request.author = Some(Default::default()); @@ -902,7 +956,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -982,15 +1036,40 @@ impl Engine { request.file_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.comments().insert(request, &self.opt.arg_file_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1046,6 +1125,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1062,36 +1144,23 @@ impl Engine { fn _comments_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Comment::default(); - let mut call = self.hub.comments().patch(&request, &self.opt.arg_file_id, &self.opt.arg_comment_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Comment::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_author_init(request: &mut api::Comment) { if request.author.is_none() { request.author = Some(Default::default()); @@ -1111,7 +1180,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -1191,15 +1260,40 @@ impl Engine { request.file_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.comments().patch(request, &self.opt.arg_file_id, &self.opt.arg_comment_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1216,36 +1310,23 @@ impl Engine { fn _comments_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Comment::default(); - let mut call = self.hub.comments().update(&request, &self.opt.arg_file_id, &self.opt.arg_comment_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Comment::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_author_init(request: &mut api::Comment) { if request.author.is_none() { request.author = Some(Default::default()); @@ -1265,7 +1346,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -1345,57 +1426,14 @@ impl Engine { request.file_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _files_copy(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::File::default(); - let mut call = self.hub.files().copy(&request, &self.opt.arg_file_id); + let mut call = self.hub.comments().update(request, &self.opt.arg_file_id, &self.opt.arg_comment_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { - "visibility" => { - call = call.visibility(value.unwrap_or("")); - }, - "timed-text-track-name" => { - call = call.timed_text_track_name(value.unwrap_or("")); - }, - "timed-text-language" => { - call = call.timed_text_language(value.unwrap_or("")); - }, - "pinned" => { - call = call.pinned(arg_from_str(value.unwrap_or("false"), err, "pinned", "boolean")); - }, - "ocr-language" => { - call = call.ocr_language(value.unwrap_or("")); - }, - "ocr" => { - call = call.ocr(arg_from_str(value.unwrap_or("false"), err, "ocr", "boolean")); - }, - "convert" => { - call = call.convert(arg_from_str(value.unwrap_or("false"), err, "convert", "boolean")); - }, "alt" |"fields" |"key" @@ -1414,13 +1452,47 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _files_copy(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::File::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_image_media_metadata_init(request: &mut api::File) { if request.image_media_metadata.is_none() { request.image_media_metadata = Some(Default::default()); @@ -1490,7 +1562,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "mime-type" => { request.mime_type = Some(value.unwrap_or("").to_string()); }, @@ -1898,15 +1970,61 @@ impl Engine { request.modified_date = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.files().copy(request, &self.opt.arg_file_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "visibility" => { + call = call.visibility(value.unwrap_or("")); + }, + "timed-text-track-name" => { + call = call.timed_text_track_name(value.unwrap_or("")); + }, + "timed-text-language" => { + call = call.timed_text_language(value.unwrap_or("")); + }, + "pinned" => { + call = call.pinned(arg_from_str(value.unwrap_or("false"), err, "pinned", "boolean")); + }, + "ocr-language" => { + call = call.ocr_language(value.unwrap_or("")); + }, + "ocr" => { + call = call.ocr(arg_from_str(value.unwrap_or("false"), err, "ocr", "boolean")); + }, + "convert" => { + call = call.convert(arg_from_str(value.unwrap_or("false"), err, "convert", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1950,6 +2068,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1991,6 +2112,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2048,6 +2172,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2068,60 +2195,23 @@ impl Engine { fn _files_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::File::default(); - let mut call = self.hub.files().insert(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "visibility" => { - call = call.visibility(value.unwrap_or("")); - }, - "use-content-as-indexable-text" => { - call = call.use_content_as_indexable_text(arg_from_str(value.unwrap_or("false"), err, "use-content-as-indexable-text", "boolean")); - }, - "timed-text-track-name" => { - call = call.timed_text_track_name(value.unwrap_or("")); - }, - "timed-text-language" => { - call = call.timed_text_language(value.unwrap_or("")); - }, - "pinned" => { - call = call.pinned(arg_from_str(value.unwrap_or("false"), err, "pinned", "boolean")); - }, - "ocr-language" => { - call = call.ocr_language(value.unwrap_or("")); - }, - "ocr" => { - call = call.ocr(arg_from_str(value.unwrap_or("false"), err, "ocr", "boolean")); - }, - "convert" => { - call = call.convert(arg_from_str(value.unwrap_or("false"), err, "convert", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::File::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_image_media_metadata_init(request: &mut api::File) { if request.image_media_metadata.is_none() { request.image_media_metadata = Some(Default::default()); @@ -2191,7 +2281,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "mime-type" => { request.mime_type = Some(value.unwrap_or("").to_string()); }, @@ -2599,10 +2689,56 @@ impl Engine { request.modified_date = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.files().insert(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "visibility" => { + call = call.visibility(value.unwrap_or("")); + }, + "use-content-as-indexable-text" => { + call = call.use_content_as_indexable_text(arg_from_str(value.unwrap_or("false"), err, "use-content-as-indexable-text", "boolean")); + }, + "timed-text-track-name" => { + call = call.timed_text_track_name(value.unwrap_or("")); + }, + "timed-text-language" => { + call = call.timed_text_language(value.unwrap_or("")); + }, + "pinned" => { + call = call.pinned(arg_from_str(value.unwrap_or("false"), err, "pinned", "boolean")); + }, + "ocr-language" => { + call = call.ocr_language(value.unwrap_or("")); + }, + "ocr" => { + call = call.ocr(arg_from_str(value.unwrap_or("false"), err, "ocr", "boolean")); + }, + "convert" => { + call = call.convert(arg_from_str(value.unwrap_or("false"), err, "convert", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = if self.opt.cmd_simple { "simple" @@ -2617,6 +2753,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -2676,6 +2815,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2692,72 +2834,23 @@ impl Engine { fn _files_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::File::default(); - let mut call = self.hub.files().patch(&request, &self.opt.arg_file_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "use-content-as-indexable-text" => { - call = call.use_content_as_indexable_text(arg_from_str(value.unwrap_or("false"), err, "use-content-as-indexable-text", "boolean")); - }, - "update-viewed-date" => { - call = call.update_viewed_date(arg_from_str(value.unwrap_or("false"), err, "update-viewed-date", "boolean")); - }, - "timed-text-track-name" => { - call = call.timed_text_track_name(value.unwrap_or("")); - }, - "timed-text-language" => { - call = call.timed_text_language(value.unwrap_or("")); - }, - "set-modified-date" => { - call = call.set_modified_date(arg_from_str(value.unwrap_or("false"), err, "set-modified-date", "boolean")); - }, - "remove-parents" => { - call = call.remove_parents(value.unwrap_or("")); - }, - "pinned" => { - call = call.pinned(arg_from_str(value.unwrap_or("false"), err, "pinned", "boolean")); - }, - "ocr-language" => { - call = call.ocr_language(value.unwrap_or("")); - }, - "ocr" => { - call = call.ocr(arg_from_str(value.unwrap_or("false"), err, "ocr", "boolean")); - }, - "new-revision" => { - call = call.new_revision(arg_from_str(value.unwrap_or("false"), err, "new-revision", "boolean")); - }, - "convert" => { - call = call.convert(arg_from_str(value.unwrap_or("false"), err, "convert", "boolean")); - }, - "add-parents" => { - call = call.add_parents(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::File::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_image_media_metadata_init(request: &mut api::File) { if request.image_media_metadata.is_none() { request.image_media_metadata = Some(Default::default()); @@ -2827,7 +2920,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "mime-type" => { request.mime_type = Some(value.unwrap_or("").to_string()); }, @@ -3235,15 +3328,76 @@ impl Engine { request.modified_date = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.files().patch(request, &self.opt.arg_file_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "use-content-as-indexable-text" => { + call = call.use_content_as_indexable_text(arg_from_str(value.unwrap_or("false"), err, "use-content-as-indexable-text", "boolean")); + }, + "update-viewed-date" => { + call = call.update_viewed_date(arg_from_str(value.unwrap_or("false"), err, "update-viewed-date", "boolean")); + }, + "timed-text-track-name" => { + call = call.timed_text_track_name(value.unwrap_or("")); + }, + "timed-text-language" => { + call = call.timed_text_language(value.unwrap_or("")); + }, + "set-modified-date" => { + call = call.set_modified_date(arg_from_str(value.unwrap_or("false"), err, "set-modified-date", "boolean")); + }, + "remove-parents" => { + call = call.remove_parents(value.unwrap_or("")); + }, + "pinned" => { + call = call.pinned(arg_from_str(value.unwrap_or("false"), err, "pinned", "boolean")); + }, + "ocr-language" => { + call = call.ocr_language(value.unwrap_or("")); + }, + "ocr" => { + call = call.ocr(arg_from_str(value.unwrap_or("false"), err, "ocr", "boolean")); + }, + "new-revision" => { + call = call.new_revision(arg_from_str(value.unwrap_or("false"), err, "new-revision", "boolean")); + }, + "convert" => { + call = call.convert(arg_from_str(value.unwrap_or("false"), err, "convert", "boolean")); + }, + "add-parents" => { + call = call.add_parents(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3287,6 +3441,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3330,6 +3487,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3373,6 +3533,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3389,72 +3552,23 @@ impl Engine { fn _files_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::File::default(); - let mut call = self.hub.files().update(&request, &self.opt.arg_file_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "use-content-as-indexable-text" => { - call = call.use_content_as_indexable_text(arg_from_str(value.unwrap_or("false"), err, "use-content-as-indexable-text", "boolean")); - }, - "update-viewed-date" => { - call = call.update_viewed_date(arg_from_str(value.unwrap_or("false"), err, "update-viewed-date", "boolean")); - }, - "timed-text-track-name" => { - call = call.timed_text_track_name(value.unwrap_or("")); - }, - "timed-text-language" => { - call = call.timed_text_language(value.unwrap_or("")); - }, - "set-modified-date" => { - call = call.set_modified_date(arg_from_str(value.unwrap_or("false"), err, "set-modified-date", "boolean")); - }, - "remove-parents" => { - call = call.remove_parents(value.unwrap_or("")); - }, - "pinned" => { - call = call.pinned(arg_from_str(value.unwrap_or("false"), err, "pinned", "boolean")); - }, - "ocr-language" => { - call = call.ocr_language(value.unwrap_or("")); - }, - "ocr" => { - call = call.ocr(arg_from_str(value.unwrap_or("false"), err, "ocr", "boolean")); - }, - "new-revision" => { - call = call.new_revision(arg_from_str(value.unwrap_or("false"), err, "new-revision", "boolean")); - }, - "convert" => { - call = call.convert(arg_from_str(value.unwrap_or("false"), err, "convert", "boolean")); - }, - "add-parents" => { - call = call.add_parents(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::File::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_image_media_metadata_init(request: &mut api::File) { if request.image_media_metadata.is_none() { request.image_media_metadata = Some(Default::default()); @@ -3524,7 +3638,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "mime-type" => { request.mime_type = Some(value.unwrap_or("").to_string()); }, @@ -3932,10 +4046,68 @@ impl Engine { request.modified_date = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.files().update(request, &self.opt.arg_file_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "use-content-as-indexable-text" => { + call = call.use_content_as_indexable_text(arg_from_str(value.unwrap_or("false"), err, "use-content-as-indexable-text", "boolean")); + }, + "update-viewed-date" => { + call = call.update_viewed_date(arg_from_str(value.unwrap_or("false"), err, "update-viewed-date", "boolean")); + }, + "timed-text-track-name" => { + call = call.timed_text_track_name(value.unwrap_or("")); + }, + "timed-text-language" => { + call = call.timed_text_language(value.unwrap_or("")); + }, + "set-modified-date" => { + call = call.set_modified_date(arg_from_str(value.unwrap_or("false"), err, "set-modified-date", "boolean")); + }, + "remove-parents" => { + call = call.remove_parents(value.unwrap_or("")); + }, + "pinned" => { + call = call.pinned(arg_from_str(value.unwrap_or("false"), err, "pinned", "boolean")); + }, + "ocr-language" => { + call = call.ocr_language(value.unwrap_or("")); + }, + "ocr" => { + call = call.ocr(arg_from_str(value.unwrap_or("false"), err, "ocr", "boolean")); + }, + "new-revision" => { + call = call.new_revision(arg_from_str(value.unwrap_or("false"), err, "new-revision", "boolean")); + }, + "convert" => { + call = call.convert(arg_from_str(value.unwrap_or("false"), err, "convert", "boolean")); + }, + "add-parents" => { + call = call.add_parents(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = if self.opt.cmd_simple { "simple" @@ -3950,6 +4122,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -3967,9 +4142,65 @@ impl Engine { fn _files_watch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Channel::default(); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "resource-uri" => { + request.resource_uri = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "resource-id" => { + request.resource_id = Some(value.unwrap_or("").to_string()); + }, + "payload" => { + request.payload = Some(arg_from_str(value.unwrap_or("false"), err, "payload", "boolean")); + }, + "token" => { + request.token = Some(value.unwrap_or("").to_string()); + }, + "params" => { + if request.params.is_none() { + request.params = Some(Default::default()); + } + let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); + request.params.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); + }, + "expiration" => { + request.expiration = Some(value.unwrap_or("").to_string()); + }, + "address" => { + request.address = Some(value.unwrap_or("").to_string()); + }, + "type" => { + request.type_ = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } let mut download_mode = false; - let mut call = self.hub.files().watch(&request, &self.opt.arg_file_id); + let mut call = self.hub.files().watch(request, &self.opt.arg_file_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -4006,58 +4237,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "resource-uri" => { - request.resource_uri = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "resource-id" => { - request.resource_id = Some(value.unwrap_or("").to_string()); - }, - "payload" => { - request.payload = Some(arg_from_str(value.unwrap_or("false"), err, "payload", "boolean")); - }, - "token" => { - request.token = Some(value.unwrap_or("").to_string()); - }, - "params" => { - if request.params.is_none() { - request.params = Some(Default::default()); - } - let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); - request.params.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); - }, - "expiration" => { - request.expiration = Some(value.unwrap_or("").to_string()); - }, - "address" => { - request.address = Some(value.unwrap_or("").to_string()); - }, - "type" => { - request.type_ = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4105,6 +4292,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -4146,6 +4336,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4162,8 +4355,45 @@ impl Engine { fn _parents_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::ParentReference::default(); - let mut call = self.hub.parents().insert(&request, &self.opt.arg_file_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "self-link" => { + request.self_link = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "is-root" => { + request.is_root = Some(arg_from_str(value.unwrap_or("false"), err, "is-root", "boolean")); + }, + "parent-link" => { + request.parent_link = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.parents().insert(request, &self.opt.arg_file_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -4185,39 +4415,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "self-link" => { - request.self_link = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "is-root" => { - request.is_root = Some(arg_from_str(value.unwrap_or("false"), err, "is-root", "boolean")); - }, - "parent-link" => { - request.parent_link = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4261,6 +4466,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4304,6 +4512,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -4345,6 +4556,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4388,6 +4602,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4404,43 +4621,24 @@ impl Engine { fn _permissions_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Permission::default(); - let mut call = self.hub.permissions().insert(&request, &self.opt.arg_file_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "send-notification-emails" => { - call = call.send_notification_emails(arg_from_str(value.unwrap_or("false"), err, "send-notification-emails", "boolean")); - }, - "email-message" => { - call = call.email_message(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Permission::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "with-link" => { request.with_link = Some(arg_from_str(value.unwrap_or("false"), err, "with-link", "boolean")); }, @@ -4487,15 +4685,46 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.permissions().insert(request, &self.opt.arg_file_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "send-notification-emails" => { + call = call.send_notification_emails(arg_from_str(value.unwrap_or("false"), err, "send-notification-emails", "boolean")); + }, + "email-message" => { + call = call.email_message(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4539,6 +4768,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4555,40 +4787,24 @@ impl Engine { fn _permissions_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Permission::default(); - let mut call = self.hub.permissions().patch(&request, &self.opt.arg_file_id, &self.opt.arg_permission_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "transfer-ownership" => { - call = call.transfer_ownership(arg_from_str(value.unwrap_or("false"), err, "transfer-ownership", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Permission::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "with-link" => { request.with_link = Some(arg_from_str(value.unwrap_or("false"), err, "with-link", "boolean")); }, @@ -4635,15 +4851,43 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.permissions().patch(request, &self.opt.arg_file_id, &self.opt.arg_permission_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "transfer-ownership" => { + call = call.transfer_ownership(arg_from_str(value.unwrap_or("false"), err, "transfer-ownership", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4660,40 +4904,24 @@ impl Engine { fn _permissions_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Permission::default(); - let mut call = self.hub.permissions().update(&request, &self.opt.arg_file_id, &self.opt.arg_permission_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "transfer-ownership" => { - call = call.transfer_ownership(arg_from_str(value.unwrap_or("false"), err, "transfer-ownership", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Permission::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "with-link" => { request.with_link = Some(arg_from_str(value.unwrap_or("false"), err, "with-link", "boolean")); }, @@ -4740,15 +4968,43 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.permissions().update(request, &self.opt.arg_file_id, &self.opt.arg_permission_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "transfer-ownership" => { + call = call.transfer_ownership(arg_from_str(value.unwrap_or("false"), err, "transfer-ownership", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4795,6 +5051,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -4839,6 +5098,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4855,8 +5117,48 @@ impl Engine { fn _properties_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Property::default(); - let mut call = self.hub.properties().insert(&request, &self.opt.arg_file_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "value" => { + request.value = Some(value.unwrap_or("").to_string()); + }, + "etag" => { + request.etag = Some(value.unwrap_or("").to_string()); + }, + "visibility" => { + request.visibility = Some(value.unwrap_or("").to_string()); + }, + "key" => { + request.key = Some(value.unwrap_or("").to_string()); + }, + "self-link" => { + request.self_link = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.properties().insert(request, &self.opt.arg_file_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -4878,42 +5180,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "value" => { - request.value = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "visibility" => { - request.visibility = Some(value.unwrap_or("").to_string()); - }, - "key" => { - request.key = Some(value.unwrap_or("").to_string()); - }, - "self-link" => { - request.self_link = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4957,6 +5231,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4973,8 +5250,48 @@ impl Engine { fn _properties_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Property::default(); - let mut call = self.hub.properties().patch(&request, &self.opt.arg_file_id, &self.opt.arg_property_key); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "value" => { + request.value = Some(value.unwrap_or("").to_string()); + }, + "etag" => { + request.etag = Some(value.unwrap_or("").to_string()); + }, + "visibility" => { + request.visibility = Some(value.unwrap_or("").to_string()); + }, + "key" => { + request.key = Some(value.unwrap_or("").to_string()); + }, + "self-link" => { + request.self_link = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.properties().patch(request, &self.opt.arg_file_id, &self.opt.arg_property_key); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -4999,42 +5316,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "value" => { - request.value = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "visibility" => { - request.visibility = Some(value.unwrap_or("").to_string()); - }, - "key" => { - request.key = Some(value.unwrap_or("").to_string()); - }, - "self-link" => { - request.self_link = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5051,8 +5340,48 @@ impl Engine { fn _properties_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Property::default(); - let mut call = self.hub.properties().update(&request, &self.opt.arg_file_id, &self.opt.arg_property_key); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "value" => { + request.value = Some(value.unwrap_or("").to_string()); + }, + "etag" => { + request.etag = Some(value.unwrap_or("").to_string()); + }, + "visibility" => { + request.visibility = Some(value.unwrap_or("").to_string()); + }, + "key" => { + request.key = Some(value.unwrap_or("").to_string()); + }, + "self-link" => { + request.self_link = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.properties().update(request, &self.opt.arg_file_id, &self.opt.arg_property_key); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -5077,42 +5406,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "value" => { - request.value = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "visibility" => { - request.visibility = Some(value.unwrap_or("").to_string()); - }, - "key" => { - request.key = Some(value.unwrap_or("").to_string()); - }, - "self-link" => { - request.self_link = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5163,6 +5464,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5221,6 +5525,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), "resumable" => call.upload_resumable(input_file.unwrap(), mime_type.unwrap()), @@ -5263,6 +5570,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -5307,6 +5617,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5323,36 +5636,23 @@ impl Engine { fn _replies_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::CommentReply::default(); - let mut call = self.hub.replies().insert(&request, &self.opt.arg_file_id, &self.opt.arg_comment_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::CommentReply::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_author_init(request: &mut api::CommentReply) { if request.author.is_none() { request.author = Some(Default::default()); @@ -5366,7 +5666,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -5423,15 +5723,40 @@ impl Engine { request.created_date = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.replies().insert(request, &self.opt.arg_file_id, &self.opt.arg_comment_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5484,6 +5809,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5500,36 +5828,23 @@ impl Engine { fn _replies_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::CommentReply::default(); - let mut call = self.hub.replies().patch(&request, &self.opt.arg_file_id, &self.opt.arg_comment_id, &self.opt.arg_reply_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::CommentReply::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_author_init(request: &mut api::CommentReply) { if request.author.is_none() { request.author = Some(Default::default()); @@ -5543,7 +5858,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -5600,15 +5915,40 @@ impl Engine { request.created_date = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.replies().patch(request, &self.opt.arg_file_id, &self.opt.arg_comment_id, &self.opt.arg_reply_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5625,36 +5965,23 @@ impl Engine { fn _replies_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::CommentReply::default(); - let mut call = self.hub.replies().update(&request, &self.opt.arg_file_id, &self.opt.arg_comment_id, &self.opt.arg_reply_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::CommentReply::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_author_init(request: &mut api::CommentReply) { if request.author.is_none() { request.author = Some(Default::default()); @@ -5668,7 +5995,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -5725,15 +6052,40 @@ impl Engine { request.created_date = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.replies().update(request, &self.opt.arg_file_id, &self.opt.arg_comment_id, &self.opt.arg_reply_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5777,6 +6129,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -5818,6 +6173,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5861,6 +6219,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5877,36 +6238,23 @@ impl Engine { fn _revisions_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Revision::default(); - let mut call = self.hub.revisions().patch(&request, &self.opt.arg_file_id, &self.opt.arg_revision_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Revision::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_last_modifying_user_init(request: &mut api::Revision) { if request.last_modifying_user.is_none() { request.last_modifying_user = Some(Default::default()); @@ -5920,7 +6268,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "mime-type" => { request.mime_type = Some(value.unwrap_or("").to_string()); }, @@ -6013,15 +6361,40 @@ impl Engine { request.published = Some(arg_from_str(value.unwrap_or("false"), err, "published", "boolean")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.revisions().patch(request, &self.opt.arg_file_id, &self.opt.arg_revision_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6038,36 +6411,23 @@ impl Engine { fn _revisions_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Revision::default(); - let mut call = self.hub.revisions().update(&request, &self.opt.arg_file_id, &self.opt.arg_revision_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Revision::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_last_modifying_user_init(request: &mut api::Revision) { if request.last_modifying_user.is_none() { request.last_modifying_user = Some(Default::default()); @@ -6081,7 +6441,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "mime-type" => { request.mime_type = Some(value.unwrap_or("").to_string()); }, @@ -6174,15 +6534,40 @@ impl Engine { request.published = Some(arg_from_str(value.unwrap_or("false"), err, "published", "boolean")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.revisions().update(request, &self.opt.arg_file_id, &self.opt.arg_revision_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6405,7 +6790,7 @@ impl Engine { }; match cmn::application_secret_from_directory(&config_dir, "drive2-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\"}}") { + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"De0ub0IbWruJbBXUyseFYvZ-\",\"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\":\"276875258587-5gbp23a7aqnrl6p06c0jt5fskuktactq.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)) } @@ -6452,6 +6837,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -6459,8 +6845,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/drive2/Cargo.toml b/gen/drive2/Cargo.toml index 483a1f010f..d7dab1d66d 100644 --- a/gen/drive2/Cargo.toml +++ b/gen/drive2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-drive2" -version = "0.1.5+20150326" +version = "0.1.6+20150326" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with drive (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/drive2" diff --git a/gen/drive2/README.md b/gen/drive2/README.md index d62a16b915..f6ef1fdfeb 100644 --- a/gen/drive2/README.md +++ b/gen/drive2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-drive2` library allows access to all features of the *Google drive* service. -This documentation was generated from *drive* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *drive:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *drive* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *drive:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *drive* *v2* API can be found at the [official documentation site](https://developers.google.com/drive/). @@ -153,7 +153,7 @@ let mut req = File::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.files().patch(&req, "fileId") +let result = hub.files().patch(req, "fileId") .use_content_as_indexable_text(true) .update_viewed_date(false) .timed_text_track_name("sed") @@ -172,14 +172,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/drive2/src/cmn.rs b/gen/drive2/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/drive2/src/cmn.rs +++ b/gen/drive2/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/drive2/src/lib.rs b/gen/drive2/src/lib.rs index 8a1b200b80..e9bee16c78 100644 --- a/gen/drive2/src/lib.rs +++ b/gen/drive2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *drive* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *drive:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *drive* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *drive:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *drive* *v2* API can be found at the //! [official documentation site](https://developers.google.com/drive/). @@ -154,7 +154,7 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.files().patch(&req, "fileId") +//! let result = hub.files().patch(req, "fileId") //! .use_content_as_indexable_text(false) //! .update_viewed_date(true) //! .timed_text_track_name("gubergren") @@ -173,14 +173,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -268,7 +269,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -369,7 +370,7 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.files().patch(&req, "fileId") +/// let result = hub.files().patch(req, "fileId") /// .use_content_as_indexable_text(true) /// .update_viewed_date(true) /// .timed_text_track_name("duo") @@ -388,14 +389,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -416,7 +418,7 @@ impl<'a, C, A> Drive<C, A> Drive { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -461,7 +463,7 @@ impl<'a, C, A> Drive<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -1942,10 +1944,10 @@ impl<'a, C, A> FileMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `fileId` - The ID for the file in question. - pub fn watch(&self, request: &Channel, file_id: &str) -> FileWatchCall<'a, C, A> { + pub fn watch(&self, request: Channel, file_id: &str) -> FileWatchCall<'a, C, A> { FileWatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _file_id: file_id.to_string(), _update_viewed_date: Default::default(), _revision_id: Default::default(), @@ -1964,10 +1966,10 @@ impl<'a, C, A> FileMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &File) -> FileInsertCall<'a, C, A> { + pub fn insert(&self, request: File) -> FileInsertCall<'a, C, A> { FileInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _visibility: Default::default(), _use_content_as_indexable_text: Default::default(), _timed_text_track_name: Default::default(), @@ -2007,10 +2009,10 @@ impl<'a, C, A> FileMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `fileId` - The ID of the file to copy. - pub fn copy(&self, request: &File, file_id: &str) -> FileCopyCall<'a, C, A> { + pub fn copy(&self, request: File, file_id: &str) -> FileCopyCall<'a, C, A> { FileCopyCall { hub: self.hub, - _request: request.clone(), + _request: request, _file_id: file_id.to_string(), _visibility: Default::default(), _timed_text_track_name: Default::default(), @@ -2096,10 +2098,10 @@ impl<'a, C, A> FileMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `fileId` - The ID of the file to update. - pub fn update(&self, request: &File, file_id: &str) -> FileUpdateCall<'a, C, A> { + pub fn update(&self, request: File, file_id: &str) -> FileUpdateCall<'a, C, A> { FileUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _file_id: file_id.to_string(), _use_content_as_indexable_text: Default::default(), _update_viewed_date: Default::default(), @@ -2144,10 +2146,10 @@ impl<'a, C, A> FileMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `fileId` - The ID of the file to update. - pub fn patch(&self, request: &File, file_id: &str) -> FilePatchCall<'a, C, A> { + pub fn patch(&self, request: File, file_id: &str) -> FilePatchCall<'a, C, A> { FilePatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _file_id: file_id.to_string(), _use_content_as_indexable_text: Default::default(), _update_viewed_date: Default::default(), @@ -2482,10 +2484,10 @@ impl<'a, C, A> CommentMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `fileId` - The ID of the file. - pub fn insert(&self, request: &Comment, file_id: &str) -> CommentInsertCall<'a, C, A> { + pub fn insert(&self, request: Comment, file_id: &str) -> CommentInsertCall<'a, C, A> { CommentInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _file_id: file_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2502,10 +2504,10 @@ impl<'a, C, A> CommentMethods<'a, C, A> { /// * `request` - No description provided. /// * `fileId` - The ID of the file. /// * `commentId` - The ID of the comment. - pub fn patch(&self, request: &Comment, file_id: &str, comment_id: &str) -> CommentPatchCall<'a, C, A> { + pub fn patch(&self, request: Comment, file_id: &str, comment_id: &str) -> CommentPatchCall<'a, C, A> { CommentPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _file_id: file_id.to_string(), _comment_id: comment_id.to_string(), _delegate: Default::default(), @@ -2523,10 +2525,10 @@ impl<'a, C, A> CommentMethods<'a, C, A> { /// * `request` - No description provided. /// * `fileId` - The ID of the file. /// * `commentId` - The ID of the comment. - pub fn update(&self, request: &Comment, file_id: &str, comment_id: &str) -> CommentUpdateCall<'a, C, A> { + pub fn update(&self, request: Comment, file_id: &str, comment_id: &str) -> CommentUpdateCall<'a, C, A> { CommentUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _file_id: file_id.to_string(), _comment_id: comment_id.to_string(), _delegate: Default::default(), @@ -2663,10 +2665,10 @@ impl<'a, C, A> ChildrenMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `folderId` - The ID of the folder. - pub fn insert(&self, request: &ChildReference, folder_id: &str) -> ChildrenInsertCall<'a, C, A> { + pub fn insert(&self, request: ChildReference, folder_id: &str) -> ChildrenInsertCall<'a, C, A> { ChildrenInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _folder_id: folder_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2722,10 +2724,10 @@ impl<'a, C, A> ChannelMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn stop(&self, request: &Channel) -> ChannelStopCall<'a, C, A> { + pub fn stop(&self, request: Channel) -> ChannelStopCall<'a, C, A> { ChannelStopCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2817,10 +2819,10 @@ impl<'a, C, A> ParentMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `fileId` - The ID of the file. - pub fn insert(&self, request: &ParentReference, file_id: &str) -> ParentInsertCall<'a, C, A> { + pub fn insert(&self, request: ParentReference, file_id: &str) -> ParentInsertCall<'a, C, A> { ParentInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _file_id: file_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2898,10 +2900,10 @@ impl<'a, C, A> ReplyMethods<'a, C, A> { /// * `fileId` - The ID of the file. /// * `commentId` - The ID of the comment. /// * `replyId` - The ID of the reply. - pub fn patch(&self, request: &CommentReply, file_id: &str, comment_id: &str, reply_id: &str) -> ReplyPatchCall<'a, C, A> { + pub fn patch(&self, request: CommentReply, file_id: &str, comment_id: &str, reply_id: &str) -> ReplyPatchCall<'a, C, A> { ReplyPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _file_id: file_id.to_string(), _comment_id: comment_id.to_string(), _reply_id: reply_id.to_string(), @@ -2964,10 +2966,10 @@ impl<'a, C, A> ReplyMethods<'a, C, A> { /// * `request` - No description provided. /// * `fileId` - The ID of the file. /// * `commentId` - The ID of the comment. - pub fn insert(&self, request: &CommentReply, file_id: &str, comment_id: &str) -> ReplyInsertCall<'a, C, A> { + pub fn insert(&self, request: CommentReply, file_id: &str, comment_id: &str) -> ReplyInsertCall<'a, C, A> { ReplyInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _file_id: file_id.to_string(), _comment_id: comment_id.to_string(), _delegate: Default::default(), @@ -3007,10 +3009,10 @@ impl<'a, C, A> ReplyMethods<'a, C, A> { /// * `fileId` - The ID of the file. /// * `commentId` - The ID of the comment. /// * `replyId` - The ID of the reply. - pub fn update(&self, request: &CommentReply, file_id: &str, comment_id: &str, reply_id: &str) -> ReplyUpdateCall<'a, C, A> { + pub fn update(&self, request: CommentReply, file_id: &str, comment_id: &str, reply_id: &str) -> ReplyUpdateCall<'a, C, A> { ReplyUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _file_id: file_id.to_string(), _comment_id: comment_id.to_string(), _reply_id: reply_id.to_string(), @@ -3088,10 +3090,10 @@ impl<'a, C, A> PermissionMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `fileId` - The ID for the file. - pub fn insert(&self, request: &Permission, file_id: &str) -> PermissionInsertCall<'a, C, A> { + pub fn insert(&self, request: Permission, file_id: &str) -> PermissionInsertCall<'a, C, A> { PermissionInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _file_id: file_id.to_string(), _send_notification_emails: Default::default(), _email_message: Default::default(), @@ -3110,10 +3112,10 @@ impl<'a, C, A> PermissionMethods<'a, C, A> { /// * `request` - No description provided. /// * `fileId` - The ID for the file. /// * `permissionId` - The ID for the permission. - pub fn update(&self, request: &Permission, file_id: &str, permission_id: &str) -> PermissionUpdateCall<'a, C, A> { + pub fn update(&self, request: Permission, file_id: &str, permission_id: &str) -> PermissionUpdateCall<'a, C, A> { PermissionUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _file_id: file_id.to_string(), _permission_id: permission_id.to_string(), _transfer_ownership: Default::default(), @@ -3132,10 +3134,10 @@ impl<'a, C, A> PermissionMethods<'a, C, A> { /// * `request` - No description provided. /// * `fileId` - The ID for the file. /// * `permissionId` - The ID for the permission. - pub fn patch(&self, request: &Permission, file_id: &str, permission_id: &str) -> PermissionPatchCall<'a, C, A> { + pub fn patch(&self, request: Permission, file_id: &str, permission_id: &str) -> PermissionPatchCall<'a, C, A> { PermissionPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _file_id: file_id.to_string(), _permission_id: permission_id.to_string(), _transfer_ownership: Default::default(), @@ -3246,10 +3248,10 @@ impl<'a, C, A> ChangeMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn watch(&self, request: &Channel) -> ChangeWatchCall<'a, C, A> { + pub fn watch(&self, request: Channel) -> ChangeWatchCall<'a, C, A> { ChangeWatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _start_change_id: Default::default(), _page_token: Default::default(), _max_results: Default::default(), @@ -3345,10 +3347,10 @@ impl<'a, C, A> PropertyMethods<'a, C, A> { /// * `request` - No description provided. /// * `fileId` - The ID of the file. /// * `propertyKey` - The key of the property. - pub fn patch(&self, request: &Property, file_id: &str, property_key: &str) -> PropertyPatchCall<'a, C, A> { + pub fn patch(&self, request: Property, file_id: &str, property_key: &str) -> PropertyPatchCall<'a, C, A> { PropertyPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _file_id: file_id.to_string(), _property_key: property_key.to_string(), _visibility: Default::default(), @@ -3386,10 +3388,10 @@ impl<'a, C, A> PropertyMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `fileId` - The ID of the file. - pub fn insert(&self, request: &Property, file_id: &str) -> PropertyInsertCall<'a, C, A> { + pub fn insert(&self, request: Property, file_id: &str) -> PropertyInsertCall<'a, C, A> { PropertyInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _file_id: file_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3423,10 +3425,10 @@ impl<'a, C, A> PropertyMethods<'a, C, A> { /// * `request` - No description provided. /// * `fileId` - The ID of the file. /// * `propertyKey` - The key of the property. - pub fn update(&self, request: &Property, file_id: &str, property_key: &str) -> PropertyUpdateCall<'a, C, A> { + pub fn update(&self, request: Property, file_id: &str, property_key: &str) -> PropertyUpdateCall<'a, C, A> { PropertyUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _file_id: file_id.to_string(), _property_key: property_key.to_string(), _visibility: Default::default(), @@ -3544,10 +3546,10 @@ impl<'a, C, A> RevisionMethods<'a, C, A> { /// * `request` - No description provided. /// * `fileId` - The ID for the file. /// * `revisionId` - The ID for the revision. - pub fn update(&self, request: &Revision, file_id: &str, revision_id: &str) -> RevisionUpdateCall<'a, C, A> { + pub fn update(&self, request: Revision, file_id: &str, revision_id: &str) -> RevisionUpdateCall<'a, C, A> { RevisionUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _file_id: file_id.to_string(), _revision_id: revision_id.to_string(), _delegate: Default::default(), @@ -3582,10 +3584,10 @@ impl<'a, C, A> RevisionMethods<'a, C, A> { /// * `request` - No description provided. /// * `fileId` - The ID for the file. /// * `revisionId` - The ID for the revision. - pub fn patch(&self, request: &Revision, file_id: &str, revision_id: &str) -> RevisionPatchCall<'a, C, A> { + pub fn patch(&self, request: Revision, file_id: &str, revision_id: &str) -> RevisionPatchCall<'a, C, A> { RevisionPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _file_id: file_id.to_string(), _revision_id: revision_id.to_string(), _delegate: Default::default(), @@ -3640,7 +3642,7 @@ impl<'a, C, A> RevisionMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.files().watch(&req, "fileId") +/// let result = hub.files().watch(req, "fileId") /// .update_viewed_date(false) /// .revision_id("labore") /// .projection("eirmod") @@ -3804,12 +3806,17 @@ impl<'a, C, A> FileWatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = if enable_resource_parsing { let mut json_response = String::new(); @@ -3818,7 +3825,7 @@ impl<'a, C, A> FileWatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } } else { (res, Default::default()) }; @@ -3836,8 +3843,8 @@ impl<'a, C, A> FileWatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Channel) -> FileWatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Channel) -> FileWatchCall<'a, C, A> { + self._request = new_value; self } /// The ID for the file in question. @@ -3963,7 +3970,7 @@ impl<'a, C, A> FileWatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload_resumable(...)`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.files().insert(&req) +/// let result = hub.files().insert(req) /// .visibility("invidunt") /// .use_content_as_indexable_text(false) /// .timed_text_track_name("accusam") @@ -4047,14 +4054,15 @@ impl<'a, C, A> FileInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/drive/v2/files".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/drive/v2/files".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/drive/v2/files".to_string() + ("https://www.googleapis.com/resumable/upload/drive/v2/files".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } @@ -4149,12 +4157,17 @@ impl<'a, C, A> FileInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -4164,9 +4177,9 @@ impl<'a, C, A> FileInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -4176,7 +4189,7 @@ impl<'a, C, A> FileInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -4207,7 +4220,7 @@ impl<'a, C, A> FileInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4251,8 +4264,8 @@ impl<'a, C, A> FileInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &File) -> FileInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: File) -> FileInsertCall<'a, C, A> { + self._request = new_value; self } /// The visibility of the new file. This parameter is only relevant when convert=false. @@ -4508,12 +4521,17 @@ impl<'a, C, A> FileUntrashCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4522,7 +4540,7 @@ impl<'a, C, A> FileUntrashCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4629,7 +4647,7 @@ impl<'a, C, A> FileUntrashCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.files().copy(&req, "fileId") +/// let result = hub.files().copy(req, "fileId") /// .visibility("et") /// .timed_text_track_name("amet") /// .timed_text_language("et") @@ -4792,12 +4810,17 @@ impl<'a, C, A> FileCopyCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4806,7 +4829,7 @@ impl<'a, C, A> FileCopyCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4824,8 +4847,8 @@ impl<'a, C, A> FileCopyCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &File) -> FileCopyCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: File) -> FileCopyCall<'a, C, A> { + self._request = new_value; self } /// The ID of the file to copy. @@ -5084,12 +5107,17 @@ impl<'a, C, A> FileTrashCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5098,7 +5126,7 @@ impl<'a, C, A> FileTrashCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5291,12 +5319,17 @@ impl<'a, C, A> FileEmptyTrashCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -5504,12 +5537,17 @@ impl<'a, C, A> FileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5518,7 +5556,7 @@ impl<'a, C, A> FileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5763,12 +5801,17 @@ impl<'a, C, A> FileTouchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5777,7 +5820,7 @@ impl<'a, C, A> FileTouchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5885,7 +5928,7 @@ impl<'a, C, A> FileTouchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload_resumable(...)`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.files().update(&req, "fileId") +/// let result = hub.files().update(req, "fileId") /// .use_content_as_indexable_text(true) /// .update_viewed_date(true) /// .timed_text_track_name("sit") @@ -5991,14 +6034,15 @@ impl<'a, C, A> FileUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/drive/v2/files/{fileId}".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/drive/v2/files/{fileId}".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/drive/v2/files/{fileId}".to_string() + ("https://www.googleapis.com/resumable/upload/drive/v2/files/{fileId}".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } @@ -6117,12 +6161,17 @@ impl<'a, C, A> FileUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -6132,9 +6181,9 @@ impl<'a, C, A> FileUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -6144,7 +6193,7 @@ impl<'a, C, A> FileUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -6175,7 +6224,7 @@ impl<'a, C, A> FileUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6219,8 +6268,8 @@ impl<'a, C, A> FileUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &File) -> FileUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: File) -> FileUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the file to update. @@ -6513,12 +6562,17 @@ impl<'a, C, A> FileDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -6624,7 +6678,7 @@ impl<'a, C, A> FileDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.files().patch(&req, "fileId") +/// let result = hub.files().patch(req, "fileId") /// .use_content_as_indexable_text(false) /// .update_viewed_date(true) /// .timed_text_track_name("et") @@ -6812,12 +6866,17 @@ impl<'a, C, A> FilePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6826,7 +6885,7 @@ impl<'a, C, A> FilePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6844,8 +6903,8 @@ impl<'a, C, A> FilePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &File) -> FilePatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: File) -> FilePatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the file to update. @@ -7180,12 +7239,17 @@ impl<'a, C, A> FileGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = if enable_resource_parsing { let mut json_response = String::new(); @@ -7194,7 +7258,7 @@ impl<'a, C, A> FileGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } } else { (res, Default::default()) }; @@ -7431,12 +7495,17 @@ impl<'a, C, A> AboutGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7445,7 +7514,7 @@ impl<'a, C, A> AboutGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7607,14 +7676,15 @@ impl<'a, C, A> RealtimeUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A } - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/drive/v2/files/{fileId}/realtime".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/drive/v2/files/{fileId}/realtime".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/drive/v2/files/{fileId}/realtime".to_string() + ("https://www.googleapis.com/resumable/upload/drive/v2/files/{fileId}/realtime".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } @@ -7720,12 +7790,17 @@ impl<'a, C, A> RealtimeUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -7735,9 +7810,9 @@ impl<'a, C, A> RealtimeUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -7747,7 +7822,7 @@ impl<'a, C, A> RealtimeUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -8028,12 +8103,17 @@ impl<'a, C, A> RealtimeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -8259,12 +8339,17 @@ impl<'a, C, A> AppGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8273,7 +8358,7 @@ impl<'a, C, A> AppGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8482,12 +8567,17 @@ impl<'a, C, A> AppListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8496,7 +8586,7 @@ impl<'a, C, A> AppListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8728,12 +8818,17 @@ impl<'a, C, A> CommentDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -8969,12 +9064,17 @@ impl<'a, C, A> CommentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8983,7 +9083,7 @@ impl<'a, C, A> CommentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9107,7 +9207,7 @@ impl<'a, C, A> CommentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.comments().insert(&req, "fileId") +/// let result = hub.comments().insert(req, "fileId") /// .doit(); /// # } /// ``` @@ -9235,12 +9335,17 @@ impl<'a, C, A> CommentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9249,7 +9354,7 @@ impl<'a, C, A> CommentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9267,8 +9372,8 @@ impl<'a, C, A> CommentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Comment) -> CommentInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Comment) -> CommentInsertCall<'a, C, A> { + self._request = new_value; self } /// The ID of the file. @@ -9365,7 +9470,7 @@ impl<'a, C, A> CommentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.comments().patch(&req, "fileId", "commentId") +/// let result = hub.comments().patch(req, "fileId", "commentId") /// .doit(); /// # } /// ``` @@ -9495,12 +9600,17 @@ impl<'a, C, A> CommentPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9509,7 +9619,7 @@ impl<'a, C, A> CommentPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9527,8 +9637,8 @@ impl<'a, C, A> CommentPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Comment) -> CommentPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Comment) -> CommentPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the file. @@ -9635,7 +9745,7 @@ impl<'a, C, A> CommentPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.comments().update(&req, "fileId", "commentId") +/// let result = hub.comments().update(req, "fileId", "commentId") /// .doit(); /// # } /// ``` @@ -9765,12 +9875,17 @@ impl<'a, C, A> CommentUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9779,7 +9894,7 @@ impl<'a, C, A> CommentUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9797,8 +9912,8 @@ impl<'a, C, A> CommentUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Comment) -> CommentUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Comment) -> CommentUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the file. @@ -10038,12 +10153,17 @@ impl<'a, C, A> CommentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10052,7 +10172,7 @@ impl<'a, C, A> CommentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10315,12 +10435,17 @@ impl<'a, C, A> ChildrenListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10329,7 +10454,7 @@ impl<'a, C, A> ChildrenListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10572,12 +10697,17 @@ impl<'a, C, A> ChildrenGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10586,7 +10716,7 @@ impl<'a, C, A> ChildrenGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10817,12 +10947,17 @@ impl<'a, C, A> ChildrenDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -10938,7 +11073,7 @@ impl<'a, C, A> ChildrenDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.children().insert(&req, "folderId") +/// let result = hub.children().insert(req, "folderId") /// .doit(); /// # } /// ``` @@ -11066,12 +11201,17 @@ impl<'a, C, A> ChildrenInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11080,7 +11220,7 @@ impl<'a, C, A> ChildrenInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11098,8 +11238,8 @@ impl<'a, C, A> ChildrenInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ChildReference) -> ChildrenInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ChildReference) -> ChildrenInsertCall<'a, C, A> { + self._request = new_value; self } /// The ID of the folder. @@ -11196,7 +11336,7 @@ impl<'a, C, A> ChildrenInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.channels().stop(&req) +/// let result = hub.channels().stop(req) /// .doit(); /// # } /// ``` @@ -11297,12 +11437,17 @@ impl<'a, C, A> ChannelStopCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -11319,8 +11464,8 @@ impl<'a, C, A> ChannelStopCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Channel) -> ChannelStopCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Channel) -> ChannelStopCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -11520,12 +11665,17 @@ impl<'a, C, A> ParentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11534,7 +11684,7 @@ impl<'a, C, A> ParentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11755,12 +11905,17 @@ impl<'a, C, A> ParentDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -11876,7 +12031,7 @@ impl<'a, C, A> ParentDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.parents().insert(&req, "fileId") +/// let result = hub.parents().insert(req, "fileId") /// .doit(); /// # } /// ``` @@ -12004,12 +12159,17 @@ impl<'a, C, A> ParentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12018,7 +12178,7 @@ impl<'a, C, A> ParentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12036,8 +12196,8 @@ impl<'a, C, A> ParentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ParentReference) -> ParentInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ParentReference) -> ParentInsertCall<'a, C, A> { + self._request = new_value; self } /// The ID of the file. @@ -12249,12 +12409,17 @@ impl<'a, C, A> ParentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12263,7 +12428,7 @@ impl<'a, C, A> ParentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12380,7 +12545,7 @@ impl<'a, C, A> ParentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.replies().patch(&req, "fileId", "commentId", "replyId") +/// let result = hub.replies().patch(req, "fileId", "commentId", "replyId") /// .doit(); /// # } /// ``` @@ -12512,12 +12677,17 @@ impl<'a, C, A> ReplyPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12526,7 +12696,7 @@ impl<'a, C, A> ReplyPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12544,8 +12714,8 @@ impl<'a, C, A> ReplyPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &CommentReply) -> ReplyPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CommentReply) -> ReplyPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the file. @@ -12792,12 +12962,17 @@ impl<'a, C, A> ReplyListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12806,7 +12981,7 @@ impl<'a, C, A> ReplyListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13066,12 +13241,17 @@ impl<'a, C, A> ReplyGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13080,7 +13260,7 @@ impl<'a, C, A> ReplyGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13214,7 +13394,7 @@ impl<'a, C, A> ReplyGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.replies().insert(&req, "fileId", "commentId") +/// let result = hub.replies().insert(req, "fileId", "commentId") /// .doit(); /// # } /// ``` @@ -13344,12 +13524,17 @@ impl<'a, C, A> ReplyInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13358,7 +13543,7 @@ impl<'a, C, A> ReplyInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13376,8 +13561,8 @@ impl<'a, C, A> ReplyInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &CommentReply) -> ReplyInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CommentReply) -> ReplyInsertCall<'a, C, A> { + self._request = new_value; self } /// The ID of the file. @@ -13600,12 +13785,17 @@ impl<'a, C, A> ReplyDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -13731,7 +13921,7 @@ impl<'a, C, A> ReplyDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.replies().update(&req, "fileId", "commentId", "replyId") +/// let result = hub.replies().update(req, "fileId", "commentId", "replyId") /// .doit(); /// # } /// ``` @@ -13863,12 +14053,17 @@ impl<'a, C, A> ReplyUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13877,7 +14072,7 @@ impl<'a, C, A> ReplyUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13895,8 +14090,8 @@ impl<'a, C, A> ReplyUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &CommentReply) -> ReplyUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CommentReply) -> ReplyUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the file. @@ -14127,12 +14322,17 @@ impl<'a, C, A> PermissionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -14248,7 +14448,7 @@ impl<'a, C, A> PermissionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.permissions().insert(&req, "fileId") +/// let result = hub.permissions().insert(req, "fileId") /// .send_notification_emails(false) /// .email_message("ipsum") /// .doit(); @@ -14386,12 +14586,17 @@ impl<'a, C, A> PermissionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14400,7 +14605,7 @@ impl<'a, C, A> PermissionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14418,8 +14623,8 @@ impl<'a, C, A> PermissionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Permission) -> PermissionInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Permission) -> PermissionInsertCall<'a, C, A> { + self._request = new_value; self } /// The ID for the file. @@ -14530,7 +14735,7 @@ impl<'a, C, A> PermissionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.permissions().update(&req, "fileId", "permissionId") +/// let result = hub.permissions().update(req, "fileId", "permissionId") /// .transfer_ownership(true) /// .doit(); /// # } @@ -14665,12 +14870,17 @@ impl<'a, C, A> PermissionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14679,7 +14889,7 @@ impl<'a, C, A> PermissionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14697,8 +14907,8 @@ impl<'a, C, A> PermissionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Permission) -> PermissionUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Permission) -> PermissionUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID for the file. @@ -14812,7 +15022,7 @@ impl<'a, C, A> PermissionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.permissions().patch(&req, "fileId", "permissionId") +/// let result = hub.permissions().patch(req, "fileId", "permissionId") /// .transfer_ownership(true) /// .doit(); /// # } @@ -14947,12 +15157,17 @@ impl<'a, C, A> PermissionPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14961,7 +15176,7 @@ impl<'a, C, A> PermissionPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14979,8 +15194,8 @@ impl<'a, C, A> PermissionPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Permission) -> PermissionPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Permission) -> PermissionPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID for the file. @@ -15207,12 +15422,17 @@ impl<'a, C, A> PermissionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15221,7 +15441,7 @@ impl<'a, C, A> PermissionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15443,12 +15663,17 @@ impl<'a, C, A> PermissionGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15457,7 +15682,7 @@ impl<'a, C, A> PermissionGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15687,12 +15912,17 @@ impl<'a, C, A> PermissionGetIdForEmailCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15701,7 +15931,7 @@ impl<'a, C, A> PermissionGetIdForEmailCall<'a, C, A> where C: BorrowMut<hyper::C Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15808,7 +16038,7 @@ impl<'a, C, A> PermissionGetIdForEmailCall<'a, C, A> where C: BorrowMut<hyper::C /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.changes().watch(&req) +/// let result = hub.changes().watch(req) /// .start_change_id("vero") /// .page_token("ut") /// .max_results(-30) @@ -15935,12 +16165,17 @@ impl<'a, C, A> ChangeWatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15949,7 +16184,7 @@ impl<'a, C, A> ChangeWatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15967,8 +16202,8 @@ impl<'a, C, A> ChangeWatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Channel) -> ChangeWatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Channel) -> ChangeWatchCall<'a, C, A> { + self._request = new_value; self } /// Change ID to start listing changes from. @@ -16202,12 +16437,17 @@ impl<'a, C, A> ChangeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16216,7 +16456,7 @@ impl<'a, C, A> ChangeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16461,12 +16701,17 @@ impl<'a, C, A> ChangeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16475,7 +16720,7 @@ impl<'a, C, A> ChangeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16582,7 +16827,7 @@ impl<'a, C, A> ChangeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.properties().patch(&req, "fileId", "propertyKey") +/// let result = hub.properties().patch(req, "fileId", "propertyKey") /// .visibility("sed") /// .doit(); /// # } @@ -16717,12 +16962,17 @@ impl<'a, C, A> PropertyPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16731,7 +16981,7 @@ impl<'a, C, A> PropertyPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16749,8 +16999,8 @@ impl<'a, C, A> PropertyPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Property) -> PropertyPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Property) -> PropertyPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the file. @@ -16983,12 +17233,17 @@ impl<'a, C, A> PropertyDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -17111,7 +17366,7 @@ impl<'a, C, A> PropertyDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.properties().insert(&req, "fileId") +/// let result = hub.properties().insert(req, "fileId") /// .doit(); /// # } /// ``` @@ -17239,12 +17494,17 @@ impl<'a, C, A> PropertyInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -17253,7 +17513,7 @@ impl<'a, C, A> PropertyInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -17271,8 +17531,8 @@ impl<'a, C, A> PropertyInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Property) -> PropertyInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Property) -> PropertyInsertCall<'a, C, A> { + self._request = new_value; self } /// The ID of the file. @@ -17482,12 +17742,17 @@ impl<'a, C, A> PropertyListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -17496,7 +17761,7 @@ impl<'a, C, A> PropertyListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -17603,7 +17868,7 @@ impl<'a, C, A> PropertyListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.properties().update(&req, "fileId", "propertyKey") +/// let result = hub.properties().update(req, "fileId", "propertyKey") /// .visibility("sea") /// .doit(); /// # } @@ -17738,12 +18003,17 @@ impl<'a, C, A> PropertyUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -17752,7 +18022,7 @@ impl<'a, C, A> PropertyUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -17770,8 +18040,8 @@ impl<'a, C, A> PropertyUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Property) -> PropertyUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Property) -> PropertyUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the file. @@ -18005,12 +18275,17 @@ impl<'a, C, A> PropertyGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -18019,7 +18294,7 @@ impl<'a, C, A> PropertyGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -18258,12 +18533,17 @@ impl<'a, C, A> RevisionGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -18272,7 +18552,7 @@ impl<'a, C, A> RevisionGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -18503,12 +18783,17 @@ impl<'a, C, A> RevisionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -18624,7 +18909,7 @@ impl<'a, C, A> RevisionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.revisions().update(&req, "fileId", "revisionId") +/// let result = hub.revisions().update(req, "fileId", "revisionId") /// .doit(); /// # } /// ``` @@ -18754,12 +19039,17 @@ impl<'a, C, A> RevisionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -18768,7 +19058,7 @@ impl<'a, C, A> RevisionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -18786,8 +19076,8 @@ impl<'a, C, A> RevisionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Revision) -> RevisionUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Revision) -> RevisionUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID for the file. @@ -19007,12 +19297,17 @@ impl<'a, C, A> RevisionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -19021,7 +19316,7 @@ impl<'a, C, A> RevisionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -19128,7 +19423,7 @@ impl<'a, C, A> RevisionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.revisions().patch(&req, "fileId", "revisionId") +/// let result = hub.revisions().patch(req, "fileId", "revisionId") /// .doit(); /// # } /// ``` @@ -19258,12 +19553,17 @@ impl<'a, C, A> RevisionPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -19272,7 +19572,7 @@ impl<'a, C, A> RevisionPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -19290,8 +19590,8 @@ impl<'a, C, A> RevisionPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Revision) -> RevisionPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Revision) -> RevisionPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID for the file. diff --git a/gen/fitness1-cli/Cargo.toml b/gen/fitness1-cli/Cargo.toml index eed958e233..be9e471130 100644 --- a/gen/fitness1-cli/Cargo.toml +++ b/gen/fitness1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-fitness1-cli" -version = "0.0.1+20150326" +version = "0.1.0+20150326" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with fitness (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/fitness1-cli" diff --git a/gen/fitness1-cli/README.md b/gen/fitness1-cli/README.md index d965bec711..af9b79b831 100644 --- a/gen/fitness1-cli/README.md +++ b/gen/fitness1-cli/README.md @@ -1,4 +1,113 @@ -# HELLO FITNESS:V1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `fitness1` command-line interface *(CLI)* allows to use most features of the *Google fitness* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *fitness* API at revision *20150326*. The CLI is at version *0.1.0*. + +```bash + fitness1 [options] users data-sources-create <user-id> -r <kv>... [-p <v>...] [-o <out>] + fitness1 [options] users data-sources-datasets-delete <user-id> <data-source-id> <dataset-id> [-p <v>...] + fitness1 [options] users data-sources-datasets-get <user-id> <data-source-id> <dataset-id> [-p <v>...] [-o <out>] + fitness1 [options] users data-sources-datasets-patch <user-id> <data-source-id> <dataset-id> -r <kv>... [-p <v>...] [-o <out>] + fitness1 [options] users data-sources-delete <user-id> <data-source-id> [-p <v>...] [-o <out>] + fitness1 [options] users data-sources-get <user-id> <data-source-id> [-p <v>...] [-o <out>] + fitness1 [options] users data-sources-list <user-id> [-p <v>...] [-o <out>] + fitness1 [options] users data-sources-patch <user-id> <data-source-id> -r <kv>... [-p <v>...] [-o <out>] + fitness1 [options] users data-sources-update <user-id> <data-source-id> -r <kv>... [-p <v>...] [-o <out>] + fitness1 [options] users sessions-delete <user-id> <session-id> [-p <v>...] + fitness1 [options] users sessions-list <user-id> [-p <v>...] [-o <out>] + fitness1 [options] users sessions-update <user-id> <session-id> -r <kv>... [-p <v>...] [-o <out>] + fitness1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_fitness1_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `fitness1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/fitness1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/fitness1-secret.json`, assuming that the required *fitness* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `fitness1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/fitness1-cli/mkdocs.yml b/gen/fitness1-cli/mkdocs.yml index 55ac96db9d..e4ffda32a7 100644 --- a/gen/fitness1-cli/mkdocs.yml +++ b/gen/fitness1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: fitness v0.0.1+20150326 +site_name: fitness v0.1.0+20150326 site_url: http://byron.github.io/google-apis-rs/google-fitness1-cli site_description: Write integrating applications with bcore diff --git a/gen/fitness1-cli/src/cmn.rs b/gen/fitness1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/fitness1-cli/src/cmn.rs +++ b/gen/fitness1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/fitness1-cli/src/main.rs b/gen/fitness1-cli/src/main.rs index 5f00dd060f..b2021101f5 100644 --- a/gen/fitness1-cli/src/main.rs +++ b/gen/fitness1-cli/src/main.rs @@ -19,37 +19,38 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - fitness1 [options] users data-sources-create <user-id> -r <kv>... [-p <v>]... [-o <out>] - fitness1 [options] users data-sources-datasets-delete <user-id> <data-source-id> <dataset-id> [-p <v>]... - fitness1 [options] users data-sources-datasets-get <user-id> <data-source-id> <dataset-id> [-p <v>]... [-o <out>] - fitness1 [options] users data-sources-datasets-patch <user-id> <data-source-id> <dataset-id> -r <kv>... [-p <v>]... [-o <out>] - fitness1 [options] users data-sources-delete <user-id> <data-source-id> [-p <v>]... [-o <out>] - fitness1 [options] users data-sources-get <user-id> <data-source-id> [-p <v>]... [-o <out>] - fitness1 [options] users data-sources-list <user-id> [-p <v>]... [-o <out>] - fitness1 [options] users data-sources-patch <user-id> <data-source-id> -r <kv>... [-p <v>]... [-o <out>] - fitness1 [options] users data-sources-update <user-id> <data-source-id> -r <kv>... [-p <v>]... [-o <out>] - fitness1 [options] users sessions-delete <user-id> <session-id> [-p <v>]... - fitness1 [options] users sessions-list <user-id> [-p <v>]... [-o <out>] - fitness1 [options] users sessions-update <user-id> <session-id> -r <kv>... [-p <v>]... [-o <out>] + fitness1 [options] users data-sources-create <user-id> -r <kv>... [-p <v>...] [-o <out>] + fitness1 [options] users data-sources-datasets-delete <user-id> <data-source-id> <dataset-id> [-p <v>...] + fitness1 [options] users data-sources-datasets-get <user-id> <data-source-id> <dataset-id> [-p <v>...] [-o <out>] + fitness1 [options] users data-sources-datasets-patch <user-id> <data-source-id> <dataset-id> -r <kv>... [-p <v>...] [-o <out>] + fitness1 [options] users data-sources-delete <user-id> <data-source-id> [-p <v>...] [-o <out>] + fitness1 [options] users data-sources-get <user-id> <data-source-id> [-p <v>...] [-o <out>] + fitness1 [options] users data-sources-list <user-id> [-p <v>...] [-o <out>] + fitness1 [options] users data-sources-patch <user-id> <data-source-id> -r <kv>... [-p <v>...] [-o <out>] + fitness1 [options] users data-sources-update <user-id> <data-source-id> -r <kv>... [-p <v>...] [-o <out>] + fitness1 [options] users sessions-delete <user-id> <session-id> [-p <v>...] + fitness1 [options] users sessions-list <user-id> [-p <v>...] [-o <out>] + fitness1 [options] users sessions-update <user-id> <session-id> -r <kv>... [-p <v>...] [-o <out>] fitness1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_fitness1_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -71,36 +72,23 @@ struct Engine { impl Engine { fn _users_data_sources_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::DataSource::default(); - let mut call = self.hub.users().data_sources_create(&request, &self.opt.arg_user_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::DataSource::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_application_init(request: &mut api::DataSource) { if request.application.is_none() { request.application = Some(Default::default()); @@ -119,7 +107,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "name" => { request.name = Some(value.unwrap_or("").to_string()); }, @@ -175,15 +163,40 @@ impl Engine { request.type_ = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.users().data_sources_create(request, &self.opt.arg_user_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -233,6 +246,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -280,6 +296,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -296,8 +315,42 @@ impl Engine { fn _users_data_sources_datasets_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Dataset::default(); - let mut call = self.hub.users().data_sources_datasets_patch(&request, &self.opt.arg_user_id, &self.opt.arg_data_source_id, &self.opt.arg_dataset_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "min-start-time-ns" => { + request.min_start_time_ns = Some(value.unwrap_or("").to_string()); + }, + "next-page-token" => { + request.next_page_token = Some(value.unwrap_or("").to_string()); + }, + "max-end-time-ns" => { + request.max_end_time_ns = Some(value.unwrap_or("").to_string()); + }, + "data-source-id" => { + request.data_source_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.users().data_sources_datasets_patch(request, &self.opt.arg_user_id, &self.opt.arg_data_source_id, &self.opt.arg_dataset_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -322,36 +375,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "min-start-time-ns" => { - request.min_start_time_ns = Some(value.unwrap_or("").to_string()); - }, - "next-page-token" => { - request.next_page_token = Some(value.unwrap_or("").to_string()); - }, - "max-end-time-ns" => { - request.max_end_time_ns = Some(value.unwrap_or("").to_string()); - }, - "data-source-id" => { - request.data_source_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -395,6 +426,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -438,6 +472,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -484,6 +521,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -500,36 +540,23 @@ impl Engine { fn _users_data_sources_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::DataSource::default(); - let mut call = self.hub.users().data_sources_patch(&request, &self.opt.arg_user_id, &self.opt.arg_data_source_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::DataSource::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_application_init(request: &mut api::DataSource) { if request.application.is_none() { request.application = Some(Default::default()); @@ -548,7 +575,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "name" => { request.name = Some(value.unwrap_or("").to_string()); }, @@ -604,15 +631,40 @@ impl Engine { request.type_ = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.users().data_sources_patch(request, &self.opt.arg_user_id, &self.opt.arg_data_source_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -629,36 +681,23 @@ impl Engine { fn _users_data_sources_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::DataSource::default(); - let mut call = self.hub.users().data_sources_update(&request, &self.opt.arg_user_id, &self.opt.arg_data_source_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::DataSource::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_application_init(request: &mut api::DataSource) { if request.application.is_none() { request.application = Some(Default::default()); @@ -677,7 +716,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "name" => { request.name = Some(value.unwrap_or("").to_string()); }, @@ -733,15 +772,40 @@ impl Engine { request.type_ = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.users().data_sources_update(request, &self.opt.arg_user_id, &self.opt.arg_data_source_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -788,6 +852,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -841,6 +908,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -857,46 +927,30 @@ impl Engine { fn _users_sessions_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Session::default(); - let mut call = self.hub.users().sessions_update(&request, &self.opt.arg_user_id, &self.opt.arg_session_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "current-time-millis" => { - call = call.current_time_millis(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Session::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_application_init(request: &mut api::Session) { if request.application.is_none() { request.application = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "modified-time-millis" => { request.modified_time_millis = Some(value.unwrap_or("").to_string()); }, @@ -942,15 +996,43 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.users().sessions_update(request, &self.opt.arg_user_id, &self.opt.arg_session_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "current-time-millis" => { + call = call.current_time_millis(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1066,6 +1148,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -1073,8 +1156,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/fitness1/Cargo.toml b/gen/fitness1/Cargo.toml index 71bdfe1062..80e28a822b 100644 --- a/gen/fitness1/Cargo.toml +++ b/gen/fitness1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-fitness1" -version = "0.1.5+20150326" +version = "0.1.6+20150326" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with fitness (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/fitness1" diff --git a/gen/fitness1/README.md b/gen/fitness1/README.md index bc703665b3..c261e229c4 100644 --- a/gen/fitness1/README.md +++ b/gen/fitness1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-fitness1` library allows access to all features of the *Google fitness* service. -This documentation was generated from *fitness* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *fitness:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *fitness* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *fitness:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *fitness* *v1* API can be found at the [official documentation site](https://developers.google.com/fit/rest/). @@ -102,21 +102,22 @@ let mut req = DataSource::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.users().data_sources_update(&req, "userId", "dataSourceId") +let result = hub.users().data_sources_update(req, "userId", "dataSourceId") .doit(); match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/fitness1/src/cmn.rs b/gen/fitness1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/fitness1/src/cmn.rs +++ b/gen/fitness1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/fitness1/src/lib.rs b/gen/fitness1/src/lib.rs index 189affe5e1..572e097076 100644 --- a/gen/fitness1/src/lib.rs +++ b/gen/fitness1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *fitness* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *fitness:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *fitness* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *fitness:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *fitness* *v1* API can be found at the //! [official documentation site](https://developers.google.com/fit/rest/). @@ -103,21 +103,22 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.users().data_sources_update(&req, "userId", "dataSourceId") +//! let result = hub.users().data_sources_update(req, "userId", "dataSourceId") //! .doit(); //! //! match result { //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -205,7 +206,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -298,21 +299,22 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().data_sources_update(&req, "userId", "dataSourceId") +/// let result = hub.users().data_sources_update(req, "userId", "dataSourceId") /// .doit(); /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -333,7 +335,7 @@ impl<'a, C, A> Fitness<C, A> Fitness { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -342,7 +344,7 @@ impl<'a, C, A> Fitness<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -763,10 +765,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `userId` - Create the data source for the person identified. Use me to indicate the authenticated user. Only me is supported at this time. - pub fn data_sources_create(&self, request: &DataSource, user_id: &str) -> UserDataSourceCreateCall<'a, C, A> { + pub fn data_sources_create(&self, request: DataSource, user_id: &str) -> UserDataSourceCreateCall<'a, C, A> { UserDataSourceCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_id: user_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -807,10 +809,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// * `userId` - Patch a dataset for the person identified. Use me to indicate the authenticated user. Only me is supported at this time. /// * `dataSourceId` - The data stream ID of the data source that created the dataset. /// * `datasetId` - Dataset identifier that is a composite of the minimum data point start time and maximum data point end time represented as nanoseconds from the epoch. The ID is formatted like: "startTime-endTime" where startTime and endTime are 64 bit integers. - pub fn data_sources_datasets_patch(&self, request: &Dataset, user_id: &str, data_source_id: &str, dataset_id: &str) -> UserDataSourceDatasetPatchCall<'a, C, A> { + pub fn data_sources_datasets_patch(&self, request: Dataset, user_id: &str, data_source_id: &str, dataset_id: &str) -> UserDataSourceDatasetPatchCall<'a, C, A> { UserDataSourceDatasetPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_id: user_id.to_string(), _data_source_id: data_source_id.to_string(), _dataset_id: dataset_id.to_string(), @@ -871,10 +873,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// * `request` - No description provided. /// * `userId` - Update the data source for the person identified. Use me to indicate the authenticated user. Only me is supported at this time. /// * `dataSourceId` - The data stream ID of the data source to update. - pub fn data_sources_update(&self, request: &DataSource, user_id: &str, data_source_id: &str) -> UserDataSourceUpdateCall<'a, C, A> { + pub fn data_sources_update(&self, request: DataSource, user_id: &str, data_source_id: &str) -> UserDataSourceUpdateCall<'a, C, A> { UserDataSourceUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_id: user_id.to_string(), _data_source_id: data_source_id.to_string(), _delegate: Default::default(), @@ -913,10 +915,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// * `request` - No description provided. /// * `userId` - Create sessions for the person identified. Use me to indicate the authenticated user. Only me is supported at this time. /// * `sessionId` - The ID of the session to be created. - pub fn sessions_update(&self, request: &Session, user_id: &str, session_id: &str) -> UserSessionUpdateCall<'a, C, A> { + pub fn sessions_update(&self, request: Session, user_id: &str, session_id: &str) -> UserSessionUpdateCall<'a, C, A> { UserSessionUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_id: user_id.to_string(), _session_id: session_id.to_string(), _current_time_millis: Default::default(), @@ -937,10 +939,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// * `request` - No description provided. /// * `userId` - Update the data source for the person identified. Use me to indicate the authenticated user. Only me is supported at this time. /// * `dataSourceId` - The data stream ID of the data source to update. - pub fn data_sources_patch(&self, request: &DataSource, user_id: &str, data_source_id: &str) -> UserDataSourcePatchCall<'a, C, A> { + pub fn data_sources_patch(&self, request: DataSource, user_id: &str, data_source_id: &str) -> UserDataSourcePatchCall<'a, C, A> { UserDataSourcePatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_id: user_id.to_string(), _data_source_id: data_source_id.to_string(), _delegate: Default::default(), @@ -1123,12 +1125,17 @@ impl<'a, C, A> UserDataSourceDeleteCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1137,7 +1144,7 @@ impl<'a, C, A> UserDataSourceDeleteCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1381,12 +1388,17 @@ impl<'a, C, A> UserDataSourceDatasetGetCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1395,7 +1407,7 @@ impl<'a, C, A> UserDataSourceDatasetGetCall<'a, C, A> where C: BorrowMut<hyper:: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1536,7 +1548,7 @@ impl<'a, C, A> UserDataSourceDatasetGetCall<'a, C, A> where C: BorrowMut<hyper:: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().data_sources_create(&req, "userId") +/// let result = hub.users().data_sources_create(req, "userId") /// .doit(); /// # } /// ``` @@ -1664,12 +1676,17 @@ impl<'a, C, A> UserDataSourceCreateCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1678,7 +1695,7 @@ impl<'a, C, A> UserDataSourceCreateCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1696,8 +1713,8 @@ impl<'a, C, A> UserDataSourceCreateCall<'a, C, A> where C: BorrowMut<hyper::Clie /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &DataSource) -> UserDataSourceCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: DataSource) -> UserDataSourceCreateCall<'a, C, A> { + self._request = new_value; self } /// Create the data source for the person identified. Use me to indicate the authenticated user. Only me is supported at this time. @@ -1920,12 +1937,17 @@ impl<'a, C, A> UserDataSourceDatasetDeleteCall<'a, C, A> where C: BorrowMut<hype if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -2065,7 +2087,7 @@ impl<'a, C, A> UserDataSourceDatasetDeleteCall<'a, C, A> where C: BorrowMut<hype /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().data_sources_datasets_patch(&req, "userId", "dataSourceId", "datasetId") +/// let result = hub.users().data_sources_datasets_patch(req, "userId", "dataSourceId", "datasetId") /// .current_time_millis("justo") /// .doit(); /// # } @@ -2202,12 +2224,17 @@ impl<'a, C, A> UserDataSourceDatasetPatchCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2216,7 +2243,7 @@ impl<'a, C, A> UserDataSourceDatasetPatchCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2234,8 +2261,8 @@ impl<'a, C, A> UserDataSourceDatasetPatchCall<'a, C, A> where C: BorrowMut<hyper /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Dataset) -> UserDataSourceDatasetPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Dataset) -> UserDataSourceDatasetPatchCall<'a, C, A> { + self._request = new_value; self } /// Patch a dataset for the person identified. Use me to indicate the authenticated user. Only me is supported at this time. @@ -2478,12 +2505,17 @@ impl<'a, C, A> UserSessionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -2721,12 +2753,17 @@ impl<'a, C, A> UserDataSourceGetCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2735,7 +2772,7 @@ impl<'a, C, A> UserDataSourceGetCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2854,7 +2891,7 @@ impl<'a, C, A> UserDataSourceGetCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().data_sources_update(&req, "userId", "dataSourceId") +/// let result = hub.users().data_sources_update(req, "userId", "dataSourceId") /// .doit(); /// # } /// ``` @@ -2984,12 +3021,17 @@ impl<'a, C, A> UserDataSourceUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2998,7 +3040,7 @@ impl<'a, C, A> UserDataSourceUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3016,8 +3058,8 @@ impl<'a, C, A> UserDataSourceUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clie /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &DataSource) -> UserDataSourceUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: DataSource) -> UserDataSourceUpdateCall<'a, C, A> { + self._request = new_value; self } /// Update the data source for the person identified. Use me to indicate the authenticated user. Only me is supported at this time. @@ -3257,12 +3299,17 @@ impl<'a, C, A> UserSessionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3271,7 +3318,7 @@ impl<'a, C, A> UserSessionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3406,7 +3453,7 @@ impl<'a, C, A> UserSessionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().sessions_update(&req, "userId", "sessionId") +/// let result = hub.users().sessions_update(req, "userId", "sessionId") /// .current_time_millis("eirmod") /// .doit(); /// # } @@ -3541,12 +3588,17 @@ impl<'a, C, A> UserSessionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3555,7 +3607,7 @@ impl<'a, C, A> UserSessionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3573,8 +3625,8 @@ impl<'a, C, A> UserSessionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client> /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Session) -> UserSessionUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Session) -> UserSessionUpdateCall<'a, C, A> { + self._request = new_value; self } /// Create sessions for the person identified. Use me to indicate the authenticated user. Only me is supported at this time. @@ -3690,7 +3742,7 @@ impl<'a, C, A> UserSessionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().data_sources_patch(&req, "userId", "dataSourceId") +/// let result = hub.users().data_sources_patch(req, "userId", "dataSourceId") /// .doit(); /// # } /// ``` @@ -3820,12 +3872,17 @@ impl<'a, C, A> UserDataSourcePatchCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3834,7 +3891,7 @@ impl<'a, C, A> UserDataSourcePatchCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3852,8 +3909,8 @@ impl<'a, C, A> UserDataSourcePatchCall<'a, C, A> where C: BorrowMut<hyper::Clien /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &DataSource) -> UserDataSourcePatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: DataSource) -> UserDataSourcePatchCall<'a, C, A> { + self._request = new_value; self } /// Update the data source for the person identified. Use me to indicate the authenticated user. Only me is supported at this time. @@ -4082,12 +4139,17 @@ impl<'a, C, A> UserDataSourceListCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4096,7 +4158,7 @@ impl<'a, C, A> UserDataSourceListCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/freebase1-cli/Cargo.toml b/gen/freebase1-cli/Cargo.toml index a0cdb38b32..56b23b42cb 100644 --- a/gen/freebase1-cli/Cargo.toml +++ b/gen/freebase1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-freebase1-cli" -version = "0.0.1+20150330" +version = "0.1.0+20150330" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with freebase (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/freebase1-cli" diff --git a/gen/freebase1-cli/README.md b/gen/freebase1-cli/README.md index afecab3fbe..c62bbc4c41 100644 --- a/gen/freebase1-cli/README.md +++ b/gen/freebase1-cli/README.md @@ -1,4 +1,99 @@ -# HELLO FREEBASE:V1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `freebase1` command-line interface *(CLI)* allows to use most features of the *Google freebase* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *freebase* API at revision *20150330*. The CLI is at version *0.1.0*. + +```bash + freebase1 [options] methods reconcile [-p <v>...] [-o <out>] + freebase1 [options] methods search [-p <v>...] [-o <out>] + freebase1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_freebase1_cli/index.html + +Configuration: + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `freebase1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/freebase1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/freebase1-secret.json`, assuming that the required *freebase* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `freebase1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/freebase1-cli/mkdocs.yml b/gen/freebase1-cli/mkdocs.yml index 00a94f7bf6..6fe8675c47 100644 --- a/gen/freebase1-cli/mkdocs.yml +++ b/gen/freebase1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: freebase v0.0.1+20150330 +site_name: freebase v0.1.0+20150330 site_url: http://byron.github.io/google-apis-rs/google-freebase1-cli site_description: Write integrating applications with bcore diff --git a/gen/freebase1-cli/src/cmn.rs b/gen/freebase1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/freebase1-cli/src/cmn.rs +++ b/gen/freebase1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/freebase1-cli/src/main.rs b/gen/freebase1-cli/src/main.rs index 45b2b97349..3d422da62b 100644 --- a/gen/freebase1-cli/src/main.rs +++ b/gen/freebase1-cli/src/main.rs @@ -19,23 +19,24 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - freebase1 [options] methods reconcile [-p <v>]... [-o <out>] - freebase1 [options] methods search [-p <v>]... [-o <out>] + freebase1 [options] methods reconcile [-p <v>...] [-o <out>] + freebase1 [options] methods search [-p <v>...] [-o <out>] freebase1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_freebase1_cli/index.html Configuration: --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -316,6 +317,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -323,8 +325,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/freebase1/Cargo.toml b/gen/freebase1/Cargo.toml index 3e2ba4cc84..3ac5e1ce6c 100644 --- a/gen/freebase1/Cargo.toml +++ b/gen/freebase1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-freebase1" -version = "0.1.5+20150330" +version = "0.1.6+20150330" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with freebase (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/freebase1" diff --git a/gen/freebase1/README.md b/gen/freebase1/README.md index bfa7110902..03e190d8c3 100644 --- a/gen/freebase1/README.md +++ b/gen/freebase1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-freebase1` library allows access to all features of the *Google freebase* service. -This documentation was generated from *freebase* crate version *0.1.5+20150330*, where *20150330* is the exact revision of the *freebase:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *freebase* crate version *0.1.6+20150330*, where *20150330* is the exact revision of the *freebase:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *freebase* *v1* API can be found at the [official documentation site](https://developers.google.com/freebase/). @@ -109,14 +109,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/freebase1/src/cmn.rs b/gen/freebase1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/freebase1/src/cmn.rs +++ b/gen/freebase1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/freebase1/src/lib.rs b/gen/freebase1/src/lib.rs index 157966f80b..06a0342cad 100644 --- a/gen/freebase1/src/lib.rs +++ b/gen/freebase1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *freebase* crate version *0.1.5+20150330*, where *20150330* is the exact revision of the *freebase:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *freebase* crate version *0.1.6+20150330*, where *20150330* is the exact revision of the *freebase:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *freebase* *v1* API can be found at the //! [official documentation site](https://developers.google.com/freebase/). @@ -110,14 +110,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -205,7 +206,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -263,14 +264,15 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -291,7 +293,7 @@ impl<'a, C, A> Freebase<C, A> Freebase { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -300,7 +302,7 @@ impl<'a, C, A> Freebase<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -667,12 +669,17 @@ impl<'a, C, A> MethodReconcileCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -681,7 +688,7 @@ impl<'a, C, A> MethodReconcileCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1033,12 +1040,17 @@ impl<'a, C, A> MethodSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; diff --git a/gen/freebase1_sandbox-cli/Cargo.toml b/gen/freebase1_sandbox-cli/Cargo.toml index 667b3e0b02..07e768e8d9 100644 --- a/gen/freebase1_sandbox-cli/Cargo.toml +++ b/gen/freebase1_sandbox-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-freebase1_sandbox-cli" -version = "0.0.1+20150330" +version = "0.1.0+20150330" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with freebase (protocol v1sandbox)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/freebase1_sandbox-cli" diff --git a/gen/freebase1_sandbox-cli/README.md b/gen/freebase1_sandbox-cli/README.md index 499c4122a9..795a389cca 100644 --- a/gen/freebase1_sandbox-cli/README.md +++ b/gen/freebase1_sandbox-cli/README.md @@ -1,4 +1,99 @@ -# HELLO FREEBASE:V1SANDBOX +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `freebase1-sandbox` command-line interface *(CLI)* allows to use most features of the *Google freebase* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *freebase* API at revision *20150330*. The CLI is at version *0.1.0*. + +```bash + freebase1-sandbox [options] methods reconcile [-p <v>...] [-o <out>] + freebase1-sandbox [options] methods search [-p <v>...] [-o <out>] + freebase1-sandbox --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_freebase1_sandbox_cli/index.html + +Configuration: + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `freebase1-sandbox-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/freebase1-sandbox-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/freebase1-sandbox-secret.json`, assuming that the required *freebase* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `freebase1-sandbox --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/freebase1_sandbox-cli/mkdocs.yml b/gen/freebase1_sandbox-cli/mkdocs.yml index a1532ed7e0..f5c171c990 100644 --- a/gen/freebase1_sandbox-cli/mkdocs.yml +++ b/gen/freebase1_sandbox-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: freebase v0.0.1+20150330 +site_name: freebase v0.1.0+20150330 site_url: http://byron.github.io/google-apis-rs/google-freebase1_sandbox-cli site_description: Write integrating applications with bcore diff --git a/gen/freebase1_sandbox-cli/src/cmn.rs b/gen/freebase1_sandbox-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/freebase1_sandbox-cli/src/cmn.rs +++ b/gen/freebase1_sandbox-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/freebase1_sandbox-cli/src/main.rs b/gen/freebase1_sandbox-cli/src/main.rs index 8b8138c67d..5ae200e1eb 100644 --- a/gen/freebase1_sandbox-cli/src/main.rs +++ b/gen/freebase1_sandbox-cli/src/main.rs @@ -19,23 +19,24 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - freebase1-sandbox [options] methods reconcile [-p <v>]... [-o <out>] - freebase1-sandbox [options] methods search [-p <v>]... [-o <out>] + freebase1-sandbox [options] methods reconcile [-p <v>...] [-o <out>] + freebase1-sandbox [options] methods search [-p <v>...] [-o <out>] freebase1-sandbox --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_freebase1_sandbox_cli/index.html Configuration: --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -316,6 +317,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -323,8 +325,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/freebase1_sandbox/Cargo.toml b/gen/freebase1_sandbox/Cargo.toml index ca67e181f5..f17faa8d5b 100644 --- a/gen/freebase1_sandbox/Cargo.toml +++ b/gen/freebase1_sandbox/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-freebase1_sandbox" -version = "0.1.5+20150330" +version = "0.1.6+20150330" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with freebase (protocol v1sandbox)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/freebase1_sandbox" diff --git a/gen/freebase1_sandbox/README.md b/gen/freebase1_sandbox/README.md index ab694bf09b..602c78509b 100644 --- a/gen/freebase1_sandbox/README.md +++ b/gen/freebase1_sandbox/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-freebase1_sandbox` library allows access to all features of the *Google freebase* service. -This documentation was generated from *freebase* crate version *0.1.5+20150330*, where *20150330* is the exact revision of the *freebase:v1sandbox* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *freebase* crate version *0.1.6+20150330*, where *20150330* is the exact revision of the *freebase:v1sandbox* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *freebase* *v1_sandbox* API can be found at the [official documentation site](https://developers.google.com/freebase/). @@ -109,14 +109,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/freebase1_sandbox/src/cmn.rs b/gen/freebase1_sandbox/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/freebase1_sandbox/src/cmn.rs +++ b/gen/freebase1_sandbox/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/freebase1_sandbox/src/lib.rs b/gen/freebase1_sandbox/src/lib.rs index d385457ccc..9026025553 100644 --- a/gen/freebase1_sandbox/src/lib.rs +++ b/gen/freebase1_sandbox/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *freebase* crate version *0.1.5+20150330*, where *20150330* is the exact revision of the *freebase:v1sandbox* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *freebase* crate version *0.1.6+20150330*, where *20150330* is the exact revision of the *freebase:v1sandbox* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *freebase* *v1_sandbox* API can be found at the //! [official documentation site](https://developers.google.com/freebase/). @@ -110,14 +110,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -205,7 +206,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -263,14 +264,15 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -291,7 +293,7 @@ impl<'a, C, A> Freebase<C, A> Freebase { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -300,7 +302,7 @@ impl<'a, C, A> Freebase<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -667,12 +669,17 @@ impl<'a, C, A> MethodReconcileCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -681,7 +688,7 @@ impl<'a, C, A> MethodReconcileCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1033,12 +1040,17 @@ impl<'a, C, A> MethodSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; diff --git a/gen/fusiontables2-cli/Cargo.toml b/gen/fusiontables2-cli/Cargo.toml index 0f347f2321..030115d1c7 100644 --- a/gen/fusiontables2-cli/Cargo.toml +++ b/gen/fusiontables2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-fusiontables2-cli" -version = "0.0.1+20150326" +version = "0.1.0+20150326" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with fusiontables (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/fusiontables2-cli" diff --git a/gen/fusiontables2-cli/README.md b/gen/fusiontables2-cli/README.md index c878747849..2405e74891 100644 --- a/gen/fusiontables2-cli/README.md +++ b/gen/fusiontables2-cli/README.md @@ -1,4 +1,134 @@ -# HELLO FUSIONTABLES:V2 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `fusiontables2` command-line interface *(CLI)* allows to use most features of the *Google fusiontables* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *fusiontables* API at revision *20150326*. The CLI is at version *0.1.0*. + +```bash + fusiontables2 [options] column delete <table-id> <column-id> [-p <v>...] + fusiontables2 [options] column get <table-id> <column-id> [-p <v>...] [-o <out>] + fusiontables2 [options] column insert <table-id> -r <kv>... [-p <v>...] [-o <out>] + fusiontables2 [options] column list <table-id> [-p <v>...] [-o <out>] + fusiontables2 [options] column patch <table-id> <column-id> -r <kv>... [-p <v>...] [-o <out>] + fusiontables2 [options] column update <table-id> <column-id> -r <kv>... [-p <v>...] [-o <out>] + fusiontables2 [options] query sql <sql> [-p <v>...] [-o <out>] + fusiontables2 [options] query sql-get <sql> [-p <v>...] [-o <out>] + fusiontables2 [options] style delete <table-id> <style-id> [-p <v>...] + fusiontables2 [options] style get <table-id> <style-id> [-p <v>...] [-o <out>] + fusiontables2 [options] style insert <table-id> -r <kv>... [-p <v>...] [-o <out>] + fusiontables2 [options] style list <table-id> [-p <v>...] [-o <out>] + fusiontables2 [options] style patch <table-id> <style-id> -r <kv>... [-p <v>...] [-o <out>] + fusiontables2 [options] style update <table-id> <style-id> -r <kv>... [-p <v>...] [-o <out>] + fusiontables2 [options] table copy <table-id> [-p <v>...] [-o <out>] + fusiontables2 [options] table delete <table-id> [-p <v>...] + fusiontables2 [options] table get <table-id> [-p <v>...] [-o <out>] + fusiontables2 [options] table import-rows <table-id> -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + fusiontables2 [options] table import-table <name> -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + fusiontables2 [options] table insert -r <kv>... [-p <v>...] [-o <out>] + fusiontables2 [options] table list [-p <v>...] [-o <out>] + fusiontables2 [options] table patch <table-id> -r <kv>... [-p <v>...] [-o <out>] + fusiontables2 [options] table replace-rows <table-id> -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + fusiontables2 [options] table update <table-id> -r <kv>... [-p <v>...] [-o <out>] + fusiontables2 [options] task delete <table-id> <task-id> [-p <v>...] + fusiontables2 [options] task get <table-id> <task-id> [-p <v>...] [-o <out>] + fusiontables2 [options] task list <table-id> [-p <v>...] [-o <out>] + fusiontables2 [options] template delete <table-id> <template-id> [-p <v>...] + fusiontables2 [options] template get <table-id> <template-id> [-p <v>...] [-o <out>] + fusiontables2 [options] template insert <table-id> -r <kv>... [-p <v>...] [-o <out>] + fusiontables2 [options] template list <table-id> [-p <v>...] [-o <out>] + fusiontables2 [options] template patch <table-id> <template-id> -r <kv>... [-p <v>...] [-o <out>] + fusiontables2 [options] template update <table-id> <template-id> -r <kv>... [-p <v>...] [-o <out>] + fusiontables2 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_fusiontables2_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `fusiontables2-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/fusiontables2-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/fusiontables2-secret.json`, assuming that the required *fusiontables* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `fusiontables2 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/fusiontables2-cli/mkdocs.yml b/gen/fusiontables2-cli/mkdocs.yml index e54d5b7500..cdbbbe41f8 100644 --- a/gen/fusiontables2-cli/mkdocs.yml +++ b/gen/fusiontables2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: fusiontables v0.0.1+20150326 +site_name: fusiontables v0.1.0+20150326 site_url: http://byron.github.io/google-apis-rs/google-fusiontables2-cli site_description: Write integrating applications with bcore diff --git a/gen/fusiontables2-cli/src/cmn.rs b/gen/fusiontables2-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/fusiontables2-cli/src/cmn.rs +++ b/gen/fusiontables2-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/fusiontables2-cli/src/main.rs b/gen/fusiontables2-cli/src/main.rs index ecd401a700..1241920fda 100644 --- a/gen/fusiontables2-cli/src/main.rs +++ b/gen/fusiontables2-cli/src/main.rs @@ -19,58 +19,59 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - fusiontables2 [options] column delete <table-id> <column-id> [-p <v>]... - fusiontables2 [options] column get <table-id> <column-id> [-p <v>]... [-o <out>] - fusiontables2 [options] column insert <table-id> -r <kv>... [-p <v>]... [-o <out>] - fusiontables2 [options] column list <table-id> [-p <v>]... [-o <out>] - fusiontables2 [options] column patch <table-id> <column-id> -r <kv>... [-p <v>]... [-o <out>] - fusiontables2 [options] column update <table-id> <column-id> -r <kv>... [-p <v>]... [-o <out>] - fusiontables2 [options] query sql <sql> [-p <v>]... [-o <out>] - fusiontables2 [options] query sql-get <sql> [-p <v>]... [-o <out>] - fusiontables2 [options] style delete <table-id> <style-id> [-p <v>]... - fusiontables2 [options] style get <table-id> <style-id> [-p <v>]... [-o <out>] - fusiontables2 [options] style insert <table-id> -r <kv>... [-p <v>]... [-o <out>] - fusiontables2 [options] style list <table-id> [-p <v>]... [-o <out>] - fusiontables2 [options] style patch <table-id> <style-id> -r <kv>... [-p <v>]... [-o <out>] - fusiontables2 [options] style update <table-id> <style-id> -r <kv>... [-p <v>]... [-o <out>] - fusiontables2 [options] table copy <table-id> [-p <v>]... [-o <out>] - fusiontables2 [options] table delete <table-id> [-p <v>]... - fusiontables2 [options] table get <table-id> [-p <v>]... [-o <out>] - fusiontables2 [options] table import-rows <table-id> -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] - fusiontables2 [options] table import-table <name> -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] - fusiontables2 [options] table insert -r <kv>... [-p <v>]... [-o <out>] - fusiontables2 [options] table list [-p <v>]... [-o <out>] - fusiontables2 [options] table patch <table-id> -r <kv>... [-p <v>]... [-o <out>] - fusiontables2 [options] table replace-rows <table-id> -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] - fusiontables2 [options] table update <table-id> -r <kv>... [-p <v>]... [-o <out>] - fusiontables2 [options] task delete <table-id> <task-id> [-p <v>]... - fusiontables2 [options] task get <table-id> <task-id> [-p <v>]... [-o <out>] - fusiontables2 [options] task list <table-id> [-p <v>]... [-o <out>] - fusiontables2 [options] template delete <table-id> <template-id> [-p <v>]... - fusiontables2 [options] template get <table-id> <template-id> [-p <v>]... [-o <out>] - fusiontables2 [options] template insert <table-id> -r <kv>... [-p <v>]... [-o <out>] - fusiontables2 [options] template list <table-id> [-p <v>]... [-o <out>] - fusiontables2 [options] template patch <table-id> <template-id> -r <kv>... [-p <v>]... [-o <out>] - fusiontables2 [options] template update <table-id> <template-id> -r <kv>... [-p <v>]... [-o <out>] + fusiontables2 [options] column delete <table-id> <column-id> [-p <v>...] + fusiontables2 [options] column get <table-id> <column-id> [-p <v>...] [-o <out>] + fusiontables2 [options] column insert <table-id> -r <kv>... [-p <v>...] [-o <out>] + fusiontables2 [options] column list <table-id> [-p <v>...] [-o <out>] + fusiontables2 [options] column patch <table-id> <column-id> -r <kv>... [-p <v>...] [-o <out>] + fusiontables2 [options] column update <table-id> <column-id> -r <kv>... [-p <v>...] [-o <out>] + fusiontables2 [options] query sql <sql> [-p <v>...] [-o <out>] + fusiontables2 [options] query sql-get <sql> [-p <v>...] [-o <out>] + fusiontables2 [options] style delete <table-id> <style-id> [-p <v>...] + fusiontables2 [options] style get <table-id> <style-id> [-p <v>...] [-o <out>] + fusiontables2 [options] style insert <table-id> -r <kv>... [-p <v>...] [-o <out>] + fusiontables2 [options] style list <table-id> [-p <v>...] [-o <out>] + fusiontables2 [options] style patch <table-id> <style-id> -r <kv>... [-p <v>...] [-o <out>] + fusiontables2 [options] style update <table-id> <style-id> -r <kv>... [-p <v>...] [-o <out>] + fusiontables2 [options] table copy <table-id> [-p <v>...] [-o <out>] + fusiontables2 [options] table delete <table-id> [-p <v>...] + fusiontables2 [options] table get <table-id> [-p <v>...] [-o <out>] + fusiontables2 [options] table import-rows <table-id> -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + fusiontables2 [options] table import-table <name> -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + fusiontables2 [options] table insert -r <kv>... [-p <v>...] [-o <out>] + fusiontables2 [options] table list [-p <v>...] [-o <out>] + fusiontables2 [options] table patch <table-id> -r <kv>... [-p <v>...] [-o <out>] + fusiontables2 [options] table replace-rows <table-id> -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + fusiontables2 [options] table update <table-id> -r <kv>... [-p <v>...] [-o <out>] + fusiontables2 [options] task delete <table-id> <task-id> [-p <v>...] + fusiontables2 [options] task get <table-id> <task-id> [-p <v>...] [-o <out>] + fusiontables2 [options] task list <table-id> [-p <v>...] [-o <out>] + fusiontables2 [options] template delete <table-id> <template-id> [-p <v>...] + fusiontables2 [options] template get <table-id> <template-id> [-p <v>...] [-o <out>] + fusiontables2 [options] template insert <table-id> -r <kv>... [-p <v>...] [-o <out>] + fusiontables2 [options] template list <table-id> [-p <v>...] [-o <out>] + fusiontables2 [options] template patch <table-id> <template-id> -r <kv>... [-p <v>...] [-o <out>] + fusiontables2 [options] template update <table-id> <template-id> -r <kv>... [-p <v>...] [-o <out>] fusiontables2 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_fusiontables2_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -119,6 +120,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -160,6 +164,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -176,43 +183,30 @@ impl Engine { fn _column_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Column::default(); - let mut call = self.hub.column().insert(&request, &self.opt.arg_table_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Column::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_base_column_init(request: &mut api::Column) { if request.base_column.is_none() { request.base_column = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "graph-predicate" => { request.graph_predicate = Some(value.unwrap_or("").to_string()); }, @@ -265,15 +259,40 @@ impl Engine { request.column_id = Some(arg_from_str(value.unwrap_or("-0"), err, "column-id", "integer")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.column().insert(request, &self.opt.arg_table_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -323,6 +342,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -339,43 +361,30 @@ impl Engine { fn _column_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Column::default(); - let mut call = self.hub.column().patch(&request, &self.opt.arg_table_id, &self.opt.arg_column_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Column::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_base_column_init(request: &mut api::Column) { if request.base_column.is_none() { request.base_column = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "graph-predicate" => { request.graph_predicate = Some(value.unwrap_or("").to_string()); }, @@ -428,15 +437,40 @@ impl Engine { request.column_id = Some(arg_from_str(value.unwrap_or("-0"), err, "column-id", "integer")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.column().patch(request, &self.opt.arg_table_id, &self.opt.arg_column_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -453,43 +487,30 @@ impl Engine { fn _column_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Column::default(); - let mut call = self.hub.column().update(&request, &self.opt.arg_table_id, &self.opt.arg_column_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Column::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_base_column_init(request: &mut api::Column) { if request.base_column.is_none() { request.base_column = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "graph-predicate" => { request.graph_predicate = Some(value.unwrap_or("").to_string()); }, @@ -542,15 +563,40 @@ impl Engine { request.column_id = Some(arg_from_str(value.unwrap_or("-0"), err, "column-id", "integer")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.column().update(request, &self.opt.arg_table_id, &self.opt.arg_column_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -604,6 +650,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -661,6 +710,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -709,6 +761,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -751,6 +806,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -767,36 +825,23 @@ impl Engine { fn _style_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::StyleSetting::default(); - let mut call = self.hub.style().insert(&request, &self.opt.arg_table_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::StyleSetting::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_marker_options_icon_styler_gradient_init(request: &mut api::StyleSetting) { request_marker_options_icon_styler_init(request); if request.marker_options.as_mut().unwrap().icon_styler.as_mut().unwrap().gradient.is_none() { @@ -899,7 +944,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "marker-options.icon-styler.gradient.max" => { request_marker_options_icon_styler_gradient_init(&mut request); request.marker_options.as_mut().unwrap().icon_styler.as_mut().unwrap().gradient.as_mut().unwrap().max = Some(arg_from_str(value.unwrap_or("0.0"), err, "marker-options.icon-styler.gradient.max", "number")); @@ -1049,15 +1094,40 @@ impl Engine { request.style_id = Some(arg_from_str(value.unwrap_or("-0"), err, "style-id", "integer")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.style().insert(request, &self.opt.arg_table_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1107,6 +1177,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1123,37 +1196,23 @@ impl Engine { fn _style_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::StyleSetting::default(); - let style_id: i32 = arg_from_str(&self.opt.arg_style_id, err, "<style-id>", "integer"); - let mut call = self.hub.style().patch(&request, &self.opt.arg_table_id, style_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::StyleSetting::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_marker_options_icon_styler_gradient_init(request: &mut api::StyleSetting) { request_marker_options_icon_styler_init(request); if request.marker_options.as_mut().unwrap().icon_styler.as_mut().unwrap().gradient.is_none() { @@ -1256,7 +1315,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "marker-options.icon-styler.gradient.max" => { request_marker_options_icon_styler_gradient_init(&mut request); request.marker_options.as_mut().unwrap().icon_styler.as_mut().unwrap().gradient.as_mut().unwrap().max = Some(arg_from_str(value.unwrap_or("0.0"), err, "marker-options.icon-styler.gradient.max", "number")); @@ -1406,15 +1465,41 @@ impl Engine { request.style_id = Some(arg_from_str(value.unwrap_or("-0"), err, "style-id", "integer")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let style_id: i32 = arg_from_str(&self.opt.arg_style_id, err, "<style-id>", "integer"); + let mut call = self.hub.style().patch(request, &self.opt.arg_table_id, style_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1431,37 +1516,23 @@ impl Engine { fn _style_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::StyleSetting::default(); - let style_id: i32 = arg_from_str(&self.opt.arg_style_id, err, "<style-id>", "integer"); - let mut call = self.hub.style().update(&request, &self.opt.arg_table_id, style_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::StyleSetting::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_marker_options_icon_styler_gradient_init(request: &mut api::StyleSetting) { request_marker_options_icon_styler_init(request); if request.marker_options.as_mut().unwrap().icon_styler.as_mut().unwrap().gradient.is_none() { @@ -1564,7 +1635,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "marker-options.icon-styler.gradient.max" => { request_marker_options_icon_styler_gradient_init(&mut request); request.marker_options.as_mut().unwrap().icon_styler.as_mut().unwrap().gradient.as_mut().unwrap().max = Some(arg_from_str(value.unwrap_or("0.0"), err, "marker-options.icon-styler.gradient.max", "number")); @@ -1714,15 +1785,41 @@ impl Engine { request.style_id = Some(arg_from_str(value.unwrap_or("-0"), err, "style-id", "integer")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let style_id: i32 = arg_from_str(&self.opt.arg_style_id, err, "<style-id>", "integer"); + let mut call = self.hub.style().update(request, &self.opt.arg_table_id, style_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1769,6 +1866,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1812,6 +1912,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1853,6 +1956,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1920,6 +2026,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -1979,6 +2088,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -1996,37 +2108,24 @@ impl Engine { fn _table_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Table::default(); - let mut call = self.hub.table().insert(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Table::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "table-properties-json-schema" => { request.table_properties_json_schema = Some(value.unwrap_or("").to_string()); }, @@ -2067,15 +2166,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.table().insert(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2125,6 +2249,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2141,40 +2268,24 @@ impl Engine { fn _table_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Table::default(); - let mut call = self.hub.table().patch(&request, &self.opt.arg_table_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "replace-view-definition" => { - call = call.replace_view_definition(arg_from_str(value.unwrap_or("false"), err, "replace-view-definition", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Table::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "table-properties-json-schema" => { request.table_properties_json_schema = Some(value.unwrap_or("").to_string()); }, @@ -2215,15 +2326,43 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.table().patch(request, &self.opt.arg_table_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "replace-view-definition" => { + call = call.replace_view_definition(arg_from_str(value.unwrap_or("false"), err, "replace-view-definition", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2291,6 +2430,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -2308,40 +2450,24 @@ impl Engine { fn _table_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Table::default(); - let mut call = self.hub.table().update(&request, &self.opt.arg_table_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "replace-view-definition" => { - call = call.replace_view_definition(arg_from_str(value.unwrap_or("false"), err, "replace-view-definition", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Table::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "table-properties-json-schema" => { request.table_properties_json_schema = Some(value.unwrap_or("").to_string()); }, @@ -2382,15 +2508,43 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.table().update(request, &self.opt.arg_table_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "replace-view-definition" => { + call = call.replace_view_definition(arg_from_str(value.unwrap_or("false"), err, "replace-view-definition", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2434,6 +2588,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2475,6 +2632,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2527,6 +2687,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2571,6 +2734,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2613,6 +2779,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2629,37 +2798,24 @@ impl Engine { fn _template_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Template::default(); - let mut call = self.hub.template().insert(&request, &self.opt.arg_table_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Template::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "body" => { request.body = Some(value.unwrap_or("").to_string()); }, @@ -2682,15 +2838,40 @@ impl Engine { request.template_id = Some(arg_from_str(value.unwrap_or("-0"), err, "template-id", "integer")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.template().insert(request, &self.opt.arg_table_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2740,6 +2921,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2756,38 +2940,24 @@ impl Engine { fn _template_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Template::default(); - let template_id: i32 = arg_from_str(&self.opt.arg_template_id, err, "<template-id>", "integer"); - let mut call = self.hub.template().patch(&request, &self.opt.arg_table_id, template_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Template::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "body" => { request.body = Some(value.unwrap_or("").to_string()); }, @@ -2810,15 +2980,41 @@ impl Engine { request.template_id = Some(arg_from_str(value.unwrap_or("-0"), err, "template-id", "integer")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let template_id: i32 = arg_from_str(&self.opt.arg_template_id, err, "<template-id>", "integer"); + let mut call = self.hub.template().patch(request, &self.opt.arg_table_id, template_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2835,38 +3031,24 @@ impl Engine { fn _template_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Template::default(); - let template_id: i32 = arg_from_str(&self.opt.arg_template_id, err, "<template-id>", "integer"); - let mut call = self.hub.template().update(&request, &self.opt.arg_table_id, template_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Template::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "body" => { request.body = Some(value.unwrap_or("").to_string()); }, @@ -2889,15 +3071,41 @@ impl Engine { request.template_id = Some(arg_from_str(value.unwrap_or("-0"), err, "template-id", "integer")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let template_id: i32 = arg_from_str(&self.opt.arg_template_id, err, "<template-id>", "integer"); + let mut call = self.hub.template().update(request, &self.opt.arg_table_id, template_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3080,6 +3288,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -3087,8 +3296,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/fusiontables2/Cargo.toml b/gen/fusiontables2/Cargo.toml index 6e64b99896..751e2a0e62 100644 --- a/gen/fusiontables2/Cargo.toml +++ b/gen/fusiontables2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-fusiontables2" -version = "0.1.5+20150326" +version = "0.1.6+20150326" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with fusiontables (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/fusiontables2" diff --git a/gen/fusiontables2/README.md b/gen/fusiontables2/README.md index 0f664a1cdf..2f8e6de42a 100644 --- a/gen/fusiontables2/README.md +++ b/gen/fusiontables2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-fusiontables2` library allows access to all features of the *Google fusiontables* service. -This documentation was generated from *fusiontables* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *fusiontables:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *fusiontables* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *fusiontables:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *fusiontables* *v2* API can be found at the [official documentation site](https://developers.google.com/fusiontables). @@ -128,14 +128,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/fusiontables2/src/cmn.rs b/gen/fusiontables2/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/fusiontables2/src/cmn.rs +++ b/gen/fusiontables2/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/fusiontables2/src/lib.rs b/gen/fusiontables2/src/lib.rs index fccc60786d..4c42e7efbe 100644 --- a/gen/fusiontables2/src/lib.rs +++ b/gen/fusiontables2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *fusiontables* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *fusiontables:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *fusiontables* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *fusiontables:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *fusiontables* *v2* API can be found at the //! [official documentation site](https://developers.google.com/fusiontables). @@ -129,14 +129,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -224,7 +225,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -305,14 +306,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -333,7 +335,7 @@ impl<'a, C, A> Fusiontables<C, A> Fusiontables { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -357,7 +359,7 @@ impl<'a, C, A> Fusiontables<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -1000,10 +1002,10 @@ impl<'a, C, A> StyleMethods<'a, C, A> { /// * `request` - No description provided. /// * `tableId` - Table whose style is being updated. /// * `styleId` - Identifier (within a table) for the style being updated. - pub fn update(&self, request: &StyleSetting, table_id: &str, style_id: i32) -> StyleUpdateCall<'a, C, A> { + pub fn update(&self, request: StyleSetting, table_id: &str, style_id: i32) -> StyleUpdateCall<'a, C, A> { StyleUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _table_id: table_id.to_string(), _style_id: style_id, _delegate: Default::default(), @@ -1020,10 +1022,10 @@ impl<'a, C, A> StyleMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `tableId` - Table for which a new style is being added - pub fn insert(&self, request: &StyleSetting, table_id: &str) -> StyleInsertCall<'a, C, A> { + pub fn insert(&self, request: StyleSetting, table_id: &str) -> StyleInsertCall<'a, C, A> { StyleInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _table_id: table_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1078,10 +1080,10 @@ impl<'a, C, A> StyleMethods<'a, C, A> { /// * `request` - No description provided. /// * `tableId` - Table whose style is being updated. /// * `styleId` - Identifier (within a table) for the style being updated. - pub fn patch(&self, request: &StyleSetting, table_id: &str, style_id: i32) -> StylePatchCall<'a, C, A> { + pub fn patch(&self, request: StyleSetting, table_id: &str, style_id: i32) -> StylePatchCall<'a, C, A> { StylePatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _table_id: table_id.to_string(), _style_id: style_id, _delegate: Default::default(), @@ -1238,10 +1240,10 @@ impl<'a, C, A> ColumnMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `tableId` - Table for which a new column is being added. - pub fn insert(&self, request: &Column, table_id: &str) -> ColumnInsertCall<'a, C, A> { + pub fn insert(&self, request: Column, table_id: &str) -> ColumnInsertCall<'a, C, A> { ColumnInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _table_id: table_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1258,10 +1260,10 @@ impl<'a, C, A> ColumnMethods<'a, C, A> { /// * `request` - No description provided. /// * `tableId` - Table for which the column is being updated. /// * `columnId` - Name or identifier for the column that is being updated. - pub fn update(&self, request: &Column, table_id: &str, column_id: &str) -> ColumnUpdateCall<'a, C, A> { + pub fn update(&self, request: Column, table_id: &str, column_id: &str) -> ColumnUpdateCall<'a, C, A> { ColumnUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _table_id: table_id.to_string(), _column_id: column_id.to_string(), _delegate: Default::default(), @@ -1298,10 +1300,10 @@ impl<'a, C, A> ColumnMethods<'a, C, A> { /// * `request` - No description provided. /// * `tableId` - Table for which the column is being updated. /// * `columnId` - Name or identifier for the column that is being updated. - pub fn patch(&self, request: &Column, table_id: &str, column_id: &str) -> ColumnPatchCall<'a, C, A> { + pub fn patch(&self, request: Column, table_id: &str, column_id: &str) -> ColumnPatchCall<'a, C, A> { ColumnPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _table_id: table_id.to_string(), _column_id: column_id.to_string(), _delegate: Default::default(), @@ -1398,10 +1400,10 @@ impl<'a, C, A> TemplateMethods<'a, C, A> { /// * `request` - No description provided. /// * `tableId` - Table to which the updated template belongs /// * `templateId` - Identifier for the template that is being updated - pub fn update(&self, request: &Template, table_id: &str, template_id: i32) -> TemplateUpdateCall<'a, C, A> { + pub fn update(&self, request: Template, table_id: &str, template_id: i32) -> TemplateUpdateCall<'a, C, A> { TemplateUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _table_id: table_id.to_string(), _template_id: template_id, _delegate: Default::default(), @@ -1456,10 +1458,10 @@ impl<'a, C, A> TemplateMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `tableId` - Table for which a new template is being created - pub fn insert(&self, request: &Template, table_id: &str) -> TemplateInsertCall<'a, C, A> { + pub fn insert(&self, request: Template, table_id: &str) -> TemplateInsertCall<'a, C, A> { TemplateInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _table_id: table_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1476,10 +1478,10 @@ impl<'a, C, A> TemplateMethods<'a, C, A> { /// * `request` - No description provided. /// * `tableId` - Table to which the updated template belongs /// * `templateId` - Identifier for the template that is being updated - pub fn patch(&self, request: &Template, table_id: &str, template_id: i32) -> TemplatePatchCall<'a, C, A> { + pub fn patch(&self, request: Template, table_id: &str, template_id: i32) -> TemplatePatchCall<'a, C, A> { TemplatePatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _table_id: table_id.to_string(), _template_id: template_id, _delegate: Default::default(), @@ -1655,10 +1657,10 @@ impl<'a, C, A> TableMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `tableId` - ID of the table that is being updated. - pub fn patch(&self, request: &Table, table_id: &str) -> TablePatchCall<'a, C, A> { + pub fn patch(&self, request: Table, table_id: &str) -> TablePatchCall<'a, C, A> { TablePatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _table_id: table_id.to_string(), _replace_view_definition: Default::default(), _delegate: Default::default(), @@ -1697,10 +1699,10 @@ impl<'a, C, A> TableMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `tableId` - ID of the table that is being updated. - pub fn update(&self, request: &Table, table_id: &str) -> TableUpdateCall<'a, C, A> { + pub fn update(&self, request: Table, table_id: &str) -> TableUpdateCall<'a, C, A> { TableUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _table_id: table_id.to_string(), _replace_view_definition: Default::default(), _delegate: Default::default(), @@ -1733,10 +1735,10 @@ impl<'a, C, A> TableMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &Table) -> TableInsertCall<'a, C, A> { + pub fn insert(&self, request: Table) -> TableInsertCall<'a, C, A> { TableInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1997,12 +1999,17 @@ impl<'a, C, A> StyleListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2011,7 +2018,7 @@ impl<'a, C, A> StyleListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2132,7 +2139,7 @@ impl<'a, C, A> StyleListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.style().update(&req, "tableId", -9) +/// let result = hub.style().update(req, "tableId", -9) /// .doit(); /// # } /// ``` @@ -2262,12 +2269,17 @@ impl<'a, C, A> StyleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2276,7 +2288,7 @@ impl<'a, C, A> StyleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2294,8 +2306,8 @@ impl<'a, C, A> StyleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &StyleSetting) -> StyleUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: StyleSetting) -> StyleUpdateCall<'a, C, A> { + self._request = new_value; self } /// Table whose style is being updated. @@ -2402,7 +2414,7 @@ impl<'a, C, A> StyleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.style().insert(&req, "tableId") +/// let result = hub.style().insert(req, "tableId") /// .doit(); /// # } /// ``` @@ -2530,12 +2542,17 @@ impl<'a, C, A> StyleInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2544,7 +2561,7 @@ impl<'a, C, A> StyleInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2562,8 +2579,8 @@ impl<'a, C, A> StyleInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &StyleSetting) -> StyleInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: StyleSetting) -> StyleInsertCall<'a, C, A> { + self._request = new_value; self } /// Table for which a new style is being added @@ -2775,12 +2792,17 @@ impl<'a, C, A> StyleGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2789,7 +2811,7 @@ impl<'a, C, A> StyleGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3020,12 +3042,17 @@ impl<'a, C, A> StyleDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -3141,7 +3168,7 @@ impl<'a, C, A> StyleDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.style().patch(&req, "tableId", -61) +/// let result = hub.style().patch(req, "tableId", -61) /// .doit(); /// # } /// ``` @@ -3271,12 +3298,17 @@ impl<'a, C, A> StylePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3285,7 +3317,7 @@ impl<'a, C, A> StylePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3303,8 +3335,8 @@ impl<'a, C, A> StylePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &StyleSetting) -> StylePatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: StyleSetting) -> StylePatchCall<'a, C, A> { + self._request = new_value; self } /// Table whose style is being updated. @@ -3539,12 +3571,17 @@ impl<'a, C, A> TaskListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3553,7 +3590,7 @@ impl<'a, C, A> TaskListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3795,12 +3832,17 @@ impl<'a, C, A> TaskDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -4031,12 +4073,17 @@ impl<'a, C, A> TaskGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4045,7 +4092,7 @@ impl<'a, C, A> TaskGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4162,7 +4209,7 @@ impl<'a, C, A> TaskGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.column().insert(&req, "tableId") +/// let result = hub.column().insert(req, "tableId") /// .doit(); /// # } /// ``` @@ -4290,12 +4337,17 @@ impl<'a, C, A> ColumnInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4304,7 +4356,7 @@ impl<'a, C, A> ColumnInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4322,8 +4374,8 @@ impl<'a, C, A> ColumnInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Column) -> ColumnInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Column) -> ColumnInsertCall<'a, C, A> { + self._request = new_value; self } /// Table for which a new column is being added. @@ -4420,7 +4472,7 @@ impl<'a, C, A> ColumnInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.column().update(&req, "tableId", "columnId") +/// let result = hub.column().update(req, "tableId", "columnId") /// .doit(); /// # } /// ``` @@ -4550,12 +4602,17 @@ impl<'a, C, A> ColumnUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4564,7 +4621,7 @@ impl<'a, C, A> ColumnUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4582,8 +4639,8 @@ impl<'a, C, A> ColumnUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Column) -> ColumnUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Column) -> ColumnUpdateCall<'a, C, A> { + self._request = new_value; self } /// Table for which the column is being updated. @@ -4813,12 +4870,17 @@ impl<'a, C, A> ColumnListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4827,7 +4889,7 @@ impl<'a, C, A> ColumnListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4948,7 +5010,7 @@ impl<'a, C, A> ColumnListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.column().patch(&req, "tableId", "columnId") +/// let result = hub.column().patch(req, "tableId", "columnId") /// .doit(); /// # } /// ``` @@ -5078,12 +5140,17 @@ impl<'a, C, A> ColumnPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5092,7 +5159,7 @@ impl<'a, C, A> ColumnPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5110,8 +5177,8 @@ impl<'a, C, A> ColumnPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Column) -> ColumnPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Column) -> ColumnPatchCall<'a, C, A> { + self._request = new_value; self } /// Table for which the column is being updated. @@ -5332,12 +5399,17 @@ impl<'a, C, A> ColumnDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -5568,12 +5640,17 @@ impl<'a, C, A> ColumnGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5582,7 +5659,7 @@ impl<'a, C, A> ColumnGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5699,7 +5776,7 @@ impl<'a, C, A> ColumnGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.template().update(&req, "tableId", -39) +/// let result = hub.template().update(req, "tableId", -39) /// .doit(); /// # } /// ``` @@ -5829,12 +5906,17 @@ impl<'a, C, A> TemplateUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5843,7 +5925,7 @@ impl<'a, C, A> TemplateUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5861,8 +5943,8 @@ impl<'a, C, A> TemplateUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Template) -> TemplateUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Template) -> TemplateUpdateCall<'a, C, A> { + self._request = new_value; self } /// Table to which the updated template belongs @@ -6092,12 +6174,17 @@ impl<'a, C, A> TemplateListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6106,7 +6193,7 @@ impl<'a, C, A> TemplateListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6341,12 +6428,17 @@ impl<'a, C, A> TemplateDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -6462,7 +6554,7 @@ impl<'a, C, A> TemplateDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.template().insert(&req, "tableId") +/// let result = hub.template().insert(req, "tableId") /// .doit(); /// # } /// ``` @@ -6590,12 +6682,17 @@ impl<'a, C, A> TemplateInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6604,7 +6701,7 @@ impl<'a, C, A> TemplateInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6622,8 +6719,8 @@ impl<'a, C, A> TemplateInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Template) -> TemplateInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Template) -> TemplateInsertCall<'a, C, A> { + self._request = new_value; self } /// Table for which a new template is being created @@ -6720,7 +6817,7 @@ impl<'a, C, A> TemplateInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.template().patch(&req, "tableId", -70) +/// let result = hub.template().patch(req, "tableId", -70) /// .doit(); /// # } /// ``` @@ -6850,12 +6947,17 @@ impl<'a, C, A> TemplatePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6864,7 +6966,7 @@ impl<'a, C, A> TemplatePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6882,8 +6984,8 @@ impl<'a, C, A> TemplatePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Template) -> TemplatePatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Template) -> TemplatePatchCall<'a, C, A> { + self._request = new_value; self } /// Table to which the updated template belongs @@ -7105,12 +7207,17 @@ impl<'a, C, A> TemplateGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7119,7 +7226,7 @@ impl<'a, C, A> TemplateGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7359,12 +7466,17 @@ impl<'a, C, A> QuerySqlGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = if enable_resource_parsing { let mut json_response = String::new(); @@ -7373,7 +7485,7 @@ impl<'a, C, A> QuerySqlGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } } else { (res, Default::default()) }; @@ -7624,12 +7736,17 @@ impl<'a, C, A> QuerySqlCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = if enable_resource_parsing { let mut json_response = String::new(); @@ -7638,7 +7755,7 @@ impl<'a, C, A> QuerySqlCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } } else { (res, Default::default()) }; @@ -7766,7 +7883,7 @@ impl<'a, C, A> QuerySqlCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.table().patch(&req, "tableId") +/// let result = hub.table().patch(req, "tableId") /// .replace_view_definition(false) /// .doit(); /// # } @@ -7899,12 +8016,17 @@ impl<'a, C, A> TablePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7913,7 +8035,7 @@ impl<'a, C, A> TablePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7931,8 +8053,8 @@ impl<'a, C, A> TablePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Table) -> TablePatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Table) -> TablePatchCall<'a, C, A> { + self._request = new_value; self } /// ID of the table that is being updated. @@ -8101,14 +8223,15 @@ impl<'a, C, A> TableReplaceRowCall<'a, C, A> where C: BorrowMut<hyper::Client>, params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/fusiontables/v2/tables/{tableId}/replace".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/fusiontables/v2/tables/{tableId}/replace".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/fusiontables/v2/tables/{tableId}/replace".to_string() + ("https://www.googleapis.com/resumable/upload/fusiontables/v2/tables/{tableId}/replace".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } @@ -8214,12 +8337,17 @@ impl<'a, C, A> TableReplaceRowCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -8229,9 +8357,9 @@ impl<'a, C, A> TableReplaceRowCall<'a, C, A> where C: BorrowMut<hyper::Client>, } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -8241,7 +8369,7 @@ impl<'a, C, A> TableReplaceRowCall<'a, C, A> where C: BorrowMut<hyper::Client>, auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -8272,7 +8400,7 @@ impl<'a, C, A> TableReplaceRowCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8440,7 +8568,7 @@ impl<'a, C, A> TableReplaceRowCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.table().update(&req, "tableId") +/// let result = hub.table().update(req, "tableId") /// .replace_view_definition(false) /// .doit(); /// # } @@ -8573,12 +8701,17 @@ impl<'a, C, A> TableUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8587,7 +8720,7 @@ impl<'a, C, A> TableUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8605,8 +8738,8 @@ impl<'a, C, A> TableUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Table) -> TableUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Table) -> TableUpdateCall<'a, C, A> { + self._request = new_value; self } /// ID of the table that is being updated. @@ -8822,12 +8955,17 @@ impl<'a, C, A> TableDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -8933,7 +9071,7 @@ impl<'a, C, A> TableDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.table().insert(&req) +/// let result = hub.table().insert(req) /// .doit(); /// # } /// ``` @@ -9035,12 +9173,17 @@ impl<'a, C, A> TableInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9049,7 +9192,7 @@ impl<'a, C, A> TableInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9067,8 +9210,8 @@ impl<'a, C, A> TableInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Table) -> TableInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Table) -> TableInsertCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -9268,12 +9411,17 @@ impl<'a, C, A> TableGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9282,7 +9430,7 @@ impl<'a, C, A> TableGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9486,12 +9634,17 @@ impl<'a, C, A> TableListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9500,7 +9653,7 @@ impl<'a, C, A> TableListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9676,14 +9829,15 @@ impl<'a, C, A> TableImportRowCall<'a, C, A> where C: BorrowMut<hyper::Client>, A params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/fusiontables/v2/tables/{tableId}/import".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/fusiontables/v2/tables/{tableId}/import".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/fusiontables/v2/tables/{tableId}/import".to_string() + ("https://www.googleapis.com/resumable/upload/fusiontables/v2/tables/{tableId}/import".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } @@ -9789,12 +9943,17 @@ impl<'a, C, A> TableImportRowCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -9804,9 +9963,9 @@ impl<'a, C, A> TableImportRowCall<'a, C, A> where C: BorrowMut<hyper::Client>, A } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -9816,7 +9975,7 @@ impl<'a, C, A> TableImportRowCall<'a, C, A> where C: BorrowMut<hyper::Client>, A auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -9847,7 +10006,7 @@ impl<'a, C, A> TableImportRowCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10065,14 +10224,15 @@ impl<'a, C, A> TableImportTableCall<'a, C, A> where C: BorrowMut<hyper::Client>, params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/fusiontables/v2/tables/import".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/fusiontables/v2/tables/import".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/fusiontables/v2/tables/import".to_string() + ("https://www.googleapis.com/resumable/upload/fusiontables/v2/tables/import".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } @@ -10154,12 +10314,17 @@ impl<'a, C, A> TableImportTableCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -10169,9 +10334,9 @@ impl<'a, C, A> TableImportTableCall<'a, C, A> where C: BorrowMut<hyper::Client>, } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -10181,7 +10346,7 @@ impl<'a, C, A> TableImportTableCall<'a, C, A> where C: BorrowMut<hyper::Client>, auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -10212,7 +10377,7 @@ impl<'a, C, A> TableImportTableCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10477,12 +10642,17 @@ impl<'a, C, A> TableCopyCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10491,7 +10661,7 @@ impl<'a, C, A> TableCopyCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/games1-cli/Cargo.toml b/gen/games1-cli/Cargo.toml index 93fce522a9..100ec148b2 100644 --- a/gen/games1-cli/Cargo.toml +++ b/gen/games1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-games1-cli" -version = "0.0.1+20150413" +version = "0.1.0+20150413" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with Games (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/games1-cli" diff --git a/gen/games1-cli/README.md b/gen/games1-cli/README.md index f03dc20a84..f0bfc02298 100644 --- a/gen/games1-cli/README.md +++ b/gen/games1-cli/README.md @@ -1,4 +1,153 @@ -# HELLO GAMES:V1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `games1` command-line interface *(CLI)* allows to use most features of the *Google Games* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *Games* API at revision *20150413*. The CLI is at version *0.1.0*. + +```bash + games1 [options] achievement-definitions list [-p <v>...] [-o <out>] + games1 [options] achievements increment <achievement-id> <steps-to-increment> [-p <v>...] [-o <out>] + games1 [options] achievements list <player-id> [-p <v>...] [-o <out>] + games1 [options] achievements reveal <achievement-id> [-p <v>...] [-o <out>] + games1 [options] achievements set-steps-at-least <achievement-id> <steps> [-p <v>...] [-o <out>] + games1 [options] achievements unlock <achievement-id> [-p <v>...] [-o <out>] + games1 [options] achievements update-multiple -r <kv>... [-p <v>...] [-o <out>] + games1 [options] applications get <application-id> [-p <v>...] [-o <out>] + games1 [options] applications played [-p <v>...] + games1 [options] events list-by-player [-p <v>...] [-o <out>] + games1 [options] events list-definitions [-p <v>...] [-o <out>] + games1 [options] events record -r <kv>... [-p <v>...] [-o <out>] + games1 [options] leaderboards get <leaderboard-id> [-p <v>...] [-o <out>] + games1 [options] leaderboards list [-p <v>...] [-o <out>] + games1 [options] metagame get-metagame-config [-p <v>...] [-o <out>] + games1 [options] metagame list-categories-by-player <player-id> <collection> [-p <v>...] [-o <out>] + games1 [options] players get <player-id> [-p <v>...] [-o <out>] + games1 [options] players list <collection> [-p <v>...] [-o <out>] + games1 [options] pushtokens remove -r <kv>... [-p <v>...] + games1 [options] pushtokens update -r <kv>... [-p <v>...] + games1 [options] quest-milestones claim <quest-id> <milestone-id> <request-id> [-p <v>...] + games1 [options] quests accept <quest-id> [-p <v>...] [-o <out>] + games1 [options] quests list <player-id> [-p <v>...] [-o <out>] + games1 [options] revisions check <client-revision> [-p <v>...] [-o <out>] + games1 [options] rooms create -r <kv>... [-p <v>...] [-o <out>] + games1 [options] rooms decline <room-id> [-p <v>...] [-o <out>] + games1 [options] rooms dismiss <room-id> [-p <v>...] + games1 [options] rooms get <room-id> [-p <v>...] [-o <out>] + games1 [options] rooms join <room-id> -r <kv>... [-p <v>...] [-o <out>] + games1 [options] rooms leave <room-id> -r <kv>... [-p <v>...] [-o <out>] + games1 [options] rooms list [-p <v>...] [-o <out>] + games1 [options] rooms report-status <room-id> -r <kv>... [-p <v>...] [-o <out>] + games1 [options] scores get <player-id> <leaderboard-id> <time-span> [-p <v>...] [-o <out>] + games1 [options] scores list <leaderboard-id> <collection> <time-span> [-p <v>...] [-o <out>] + games1 [options] scores list-window <leaderboard-id> <collection> <time-span> [-p <v>...] [-o <out>] + games1 [options] scores submit <leaderboard-id> <score> [-p <v>...] [-o <out>] + games1 [options] scores submit-multiple -r <kv>... [-p <v>...] [-o <out>] + games1 [options] snapshots get <snapshot-id> [-p <v>...] [-o <out>] + games1 [options] snapshots list <player-id> [-p <v>...] [-o <out>] + games1 [options] turn-based-matches cancel <match-id> [-p <v>...] + games1 [options] turn-based-matches create -r <kv>... [-p <v>...] [-o <out>] + games1 [options] turn-based-matches decline <match-id> [-p <v>...] [-o <out>] + games1 [options] turn-based-matches dismiss <match-id> [-p <v>...] + games1 [options] turn-based-matches finish <match-id> -r <kv>... [-p <v>...] [-o <out>] + games1 [options] turn-based-matches get <match-id> [-p <v>...] [-o <out>] + games1 [options] turn-based-matches join <match-id> [-p <v>...] [-o <out>] + games1 [options] turn-based-matches leave <match-id> [-p <v>...] [-o <out>] + games1 [options] turn-based-matches leave-turn <match-id> <match-version> [-p <v>...] [-o <out>] + games1 [options] turn-based-matches list [-p <v>...] [-o <out>] + games1 [options] turn-based-matches rematch <match-id> [-p <v>...] [-o <out>] + games1 [options] turn-based-matches sync [-p <v>...] [-o <out>] + games1 [options] turn-based-matches take-turn <match-id> -r <kv>... [-p <v>...] [-o <out>] + games1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_games1_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `games1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/games1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/games1-secret.json`, assuming that the required *games* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `games1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/games1-cli/mkdocs.yml b/gen/games1-cli/mkdocs.yml index 8d5650e179..4892f18a93 100644 --- a/gen/games1-cli/mkdocs.yml +++ b/gen/games1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Games v0.0.1+20150413 +site_name: Games v0.1.0+20150413 site_url: http://byron.github.io/google-apis-rs/google-games1-cli site_description: Write integrating applications with bcore diff --git a/gen/games1-cli/src/cmn.rs b/gen/games1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/games1-cli/src/cmn.rs +++ b/gen/games1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/games1-cli/src/main.rs b/gen/games1-cli/src/main.rs index 7a81b47593..1162501e49 100644 --- a/gen/games1-cli/src/main.rs +++ b/gen/games1-cli/src/main.rs @@ -19,77 +19,78 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - games1 [options] achievement-definitions list [-p <v>]... [-o <out>] - games1 [options] achievements increment <achievement-id> <steps-to-increment> [-p <v>]... [-o <out>] - games1 [options] achievements list <player-id> [-p <v>]... [-o <out>] - games1 [options] achievements reveal <achievement-id> [-p <v>]... [-o <out>] - games1 [options] achievements set-steps-at-least <achievement-id> <steps> [-p <v>]... [-o <out>] - games1 [options] achievements unlock <achievement-id> [-p <v>]... [-o <out>] - games1 [options] achievements update-multiple -r <kv>... [-p <v>]... [-o <out>] - games1 [options] applications get <application-id> [-p <v>]... [-o <out>] - games1 [options] applications played [-p <v>]... - games1 [options] events list-by-player [-p <v>]... [-o <out>] - games1 [options] events list-definitions [-p <v>]... [-o <out>] - games1 [options] events record -r <kv>... [-p <v>]... [-o <out>] - games1 [options] leaderboards get <leaderboard-id> [-p <v>]... [-o <out>] - games1 [options] leaderboards list [-p <v>]... [-o <out>] - games1 [options] metagame get-metagame-config [-p <v>]... [-o <out>] - games1 [options] metagame list-categories-by-player <player-id> <collection> [-p <v>]... [-o <out>] - games1 [options] players get <player-id> [-p <v>]... [-o <out>] - games1 [options] players list <collection> [-p <v>]... [-o <out>] - games1 [options] pushtokens remove -r <kv>... [-p <v>]... - games1 [options] pushtokens update -r <kv>... [-p <v>]... - games1 [options] quest-milestones claim <quest-id> <milestone-id> <request-id> [-p <v>]... - games1 [options] quests accept <quest-id> [-p <v>]... [-o <out>] - games1 [options] quests list <player-id> [-p <v>]... [-o <out>] - games1 [options] revisions check <client-revision> [-p <v>]... [-o <out>] - games1 [options] rooms create -r <kv>... [-p <v>]... [-o <out>] - games1 [options] rooms decline <room-id> [-p <v>]... [-o <out>] - games1 [options] rooms dismiss <room-id> [-p <v>]... - games1 [options] rooms get <room-id> [-p <v>]... [-o <out>] - games1 [options] rooms join <room-id> -r <kv>... [-p <v>]... [-o <out>] - games1 [options] rooms leave <room-id> -r <kv>... [-p <v>]... [-o <out>] - games1 [options] rooms list [-p <v>]... [-o <out>] - games1 [options] rooms report-status <room-id> -r <kv>... [-p <v>]... [-o <out>] - games1 [options] scores get <player-id> <leaderboard-id> <time-span> [-p <v>]... [-o <out>] - games1 [options] scores list <leaderboard-id> <collection> <time-span> [-p <v>]... [-o <out>] - games1 [options] scores list-window <leaderboard-id> <collection> <time-span> [-p <v>]... [-o <out>] - games1 [options] scores submit <leaderboard-id> <score> [-p <v>]... [-o <out>] - games1 [options] scores submit-multiple -r <kv>... [-p <v>]... [-o <out>] - games1 [options] snapshots get <snapshot-id> [-p <v>]... [-o <out>] - games1 [options] snapshots list <player-id> [-p <v>]... [-o <out>] - games1 [options] turn-based-matches cancel <match-id> [-p <v>]... - games1 [options] turn-based-matches create -r <kv>... [-p <v>]... [-o <out>] - games1 [options] turn-based-matches decline <match-id> [-p <v>]... [-o <out>] - games1 [options] turn-based-matches dismiss <match-id> [-p <v>]... - games1 [options] turn-based-matches finish <match-id> -r <kv>... [-p <v>]... [-o <out>] - games1 [options] turn-based-matches get <match-id> [-p <v>]... [-o <out>] - games1 [options] turn-based-matches join <match-id> [-p <v>]... [-o <out>] - games1 [options] turn-based-matches leave <match-id> [-p <v>]... [-o <out>] - games1 [options] turn-based-matches leave-turn <match-id> <match-version> [-p <v>]... [-o <out>] - games1 [options] turn-based-matches list [-p <v>]... [-o <out>] - games1 [options] turn-based-matches rematch <match-id> [-p <v>]... [-o <out>] - games1 [options] turn-based-matches sync [-p <v>]... [-o <out>] - games1 [options] turn-based-matches take-turn <match-id> -r <kv>... [-p <v>]... [-o <out>] + games1 [options] achievement-definitions list [-p <v>...] [-o <out>] + games1 [options] achievements increment <achievement-id> <steps-to-increment> [-p <v>...] [-o <out>] + games1 [options] achievements list <player-id> [-p <v>...] [-o <out>] + games1 [options] achievements reveal <achievement-id> [-p <v>...] [-o <out>] + games1 [options] achievements set-steps-at-least <achievement-id> <steps> [-p <v>...] [-o <out>] + games1 [options] achievements unlock <achievement-id> [-p <v>...] [-o <out>] + games1 [options] achievements update-multiple -r <kv>... [-p <v>...] [-o <out>] + games1 [options] applications get <application-id> [-p <v>...] [-o <out>] + games1 [options] applications played [-p <v>...] + games1 [options] events list-by-player [-p <v>...] [-o <out>] + games1 [options] events list-definitions [-p <v>...] [-o <out>] + games1 [options] events record -r <kv>... [-p <v>...] [-o <out>] + games1 [options] leaderboards get <leaderboard-id> [-p <v>...] [-o <out>] + games1 [options] leaderboards list [-p <v>...] [-o <out>] + games1 [options] metagame get-metagame-config [-p <v>...] [-o <out>] + games1 [options] metagame list-categories-by-player <player-id> <collection> [-p <v>...] [-o <out>] + games1 [options] players get <player-id> [-p <v>...] [-o <out>] + games1 [options] players list <collection> [-p <v>...] [-o <out>] + games1 [options] pushtokens remove -r <kv>... [-p <v>...] + games1 [options] pushtokens update -r <kv>... [-p <v>...] + games1 [options] quest-milestones claim <quest-id> <milestone-id> <request-id> [-p <v>...] + games1 [options] quests accept <quest-id> [-p <v>...] [-o <out>] + games1 [options] quests list <player-id> [-p <v>...] [-o <out>] + games1 [options] revisions check <client-revision> [-p <v>...] [-o <out>] + games1 [options] rooms create -r <kv>... [-p <v>...] [-o <out>] + games1 [options] rooms decline <room-id> [-p <v>...] [-o <out>] + games1 [options] rooms dismiss <room-id> [-p <v>...] + games1 [options] rooms get <room-id> [-p <v>...] [-o <out>] + games1 [options] rooms join <room-id> -r <kv>... [-p <v>...] [-o <out>] + games1 [options] rooms leave <room-id> -r <kv>... [-p <v>...] [-o <out>] + games1 [options] rooms list [-p <v>...] [-o <out>] + games1 [options] rooms report-status <room-id> -r <kv>... [-p <v>...] [-o <out>] + games1 [options] scores get <player-id> <leaderboard-id> <time-span> [-p <v>...] [-o <out>] + games1 [options] scores list <leaderboard-id> <collection> <time-span> [-p <v>...] [-o <out>] + games1 [options] scores list-window <leaderboard-id> <collection> <time-span> [-p <v>...] [-o <out>] + games1 [options] scores submit <leaderboard-id> <score> [-p <v>...] [-o <out>] + games1 [options] scores submit-multiple -r <kv>... [-p <v>...] [-o <out>] + games1 [options] snapshots get <snapshot-id> [-p <v>...] [-o <out>] + games1 [options] snapshots list <player-id> [-p <v>...] [-o <out>] + games1 [options] turn-based-matches cancel <match-id> [-p <v>...] + games1 [options] turn-based-matches create -r <kv>... [-p <v>...] [-o <out>] + games1 [options] turn-based-matches decline <match-id> [-p <v>...] [-o <out>] + games1 [options] turn-based-matches dismiss <match-id> [-p <v>...] + games1 [options] turn-based-matches finish <match-id> -r <kv>... [-p <v>...] [-o <out>] + games1 [options] turn-based-matches get <match-id> [-p <v>...] [-o <out>] + games1 [options] turn-based-matches join <match-id> [-p <v>...] [-o <out>] + games1 [options] turn-based-matches leave <match-id> [-p <v>...] [-o <out>] + games1 [options] turn-based-matches leave-turn <match-id> <match-version> [-p <v>...] [-o <out>] + games1 [options] turn-based-matches list [-p <v>...] [-o <out>] + games1 [options] turn-based-matches rematch <match-id> [-p <v>...] [-o <out>] + games1 [options] turn-based-matches sync [-p <v>...] [-o <out>] + games1 [options] turn-based-matches take-turn <match-id> -r <kv>... [-p <v>...] [-o <out>] games1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_games1_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -147,6 +148,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -194,6 +198,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -249,6 +256,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -292,6 +302,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -336,6 +349,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -379,6 +395,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -395,8 +414,33 @@ impl Engine { fn _achievements_update_multiple(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::AchievementUpdateMultipleRequest::default(); - let mut call = self.hub.achievements().update_multiple(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.achievements().update_multiple(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -418,27 +462,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -488,6 +519,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -531,6 +565,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -581,6 +618,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -633,6 +673,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -649,8 +692,39 @@ impl Engine { fn _events_record(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::EventRecordRequest::default(); - let mut call = self.hub.events().record(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "request-id" => { + request.request_id = Some(value.unwrap_or("").to_string()); + }, + "current-time-millis" => { + request.current_time_millis = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.events().record(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -675,33 +749,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "request-id" => { - request.request_id = Some(value.unwrap_or("").to_string()); - }, - "current-time-millis" => { - request.current_time_millis = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -748,6 +803,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -800,6 +858,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -843,6 +904,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -895,6 +959,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -941,6 +1008,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -993,6 +1063,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1009,8 +1082,47 @@ impl Engine { fn _pushtokens_remove(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::PushTokenId::default(); - let mut call = self.hub.pushtokens().remove(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + fn request_ios_init(request: &mut api::PushTokenId) { + if request.ios.is_none() { + request.ios = Some(Default::default()); + } + } + + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "ios.apns-device-token" => { + request_ios_init(&mut request); + request.ios.as_mut().unwrap().apns_device_token = Some(value.unwrap_or("").to_string()); + }, + "ios.apns-environment" => { + request_ios_init(&mut request); + request.ios.as_mut().unwrap().apns_environment = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.pushtokens().remove(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1032,41 +1144,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_ios_init(request: &mut api::PushTokenId) { - if request.ios.is_none() { - request.ios = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "ios.apns-device-token" => { - request_ios_init(&mut request); - request.ios.as_mut().unwrap().apns_device_token = Some(value.unwrap_or("").to_string()); - }, - "ios.apns-environment" => { - request_ios_init(&mut request); - request.ios.as_mut().unwrap().apns_environment = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1081,36 +1166,23 @@ impl Engine { fn _pushtokens_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::PushToken::default(); - let mut call = self.hub.pushtokens().update(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::PushToken::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_id_init(request: &mut api::PushToken) { if request.id.is_none() { request.id = Some(Default::default()); @@ -1124,7 +1196,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1148,15 +1220,40 @@ impl Engine { request.language = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.pushtokens().update(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1198,6 +1295,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1242,6 +1342,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1294,6 +1397,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1337,6 +1443,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1353,39 +1462,23 @@ impl Engine { fn _rooms_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::RoomCreateRequest::default(); - let mut call = self.hub.rooms().create(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "language" => { - call = call.language(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::RoomCreateRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_auto_matching_criteria_init(request: &mut api::RoomCreateRequest) { if request.auto_matching_criteria.is_none() { request.auto_matching_criteria = Some(Default::default()); @@ -1404,7 +1497,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1483,15 +1576,43 @@ impl Engine { request.request_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.rooms().create(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "language" => { + call = call.language(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1538,6 +1659,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1581,6 +1705,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1625,6 +1752,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1641,39 +1771,23 @@ impl Engine { fn _rooms_join(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::RoomJoinRequest::default(); - let mut call = self.hub.rooms().join(&request, &self.opt.arg_room_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "language" => { - call = call.language(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::RoomJoinRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_client_address_init(request: &mut api::RoomJoinRequest) { if request.client_address.is_none() { request.client_address = Some(Default::default()); @@ -1686,7 +1800,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "network-diagnostics.kind" => { request_network_diagnostics_init(&mut request); request.network_diagnostics.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); @@ -1735,33 +1849,11 @@ impl Engine { request.capabilities.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _rooms_leave(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::RoomLeaveRequest::default(); - let mut call = self.hub.rooms().leave(&request, &self.opt.arg_room_id); + let mut call = self.hub.rooms().join(request, &self.opt.arg_room_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1786,20 +1878,54 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _rooms_leave(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::RoomLeaveRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_leave_diagnostics_init(request: &mut api::RoomLeaveRequest) { if request.leave_diagnostics.is_none() { request.leave_diagnostics = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1835,15 +1961,43 @@ impl Engine { request.leave_diagnostics.as_mut().unwrap().android_network_type = Some(arg_from_str(value.unwrap_or("-0"), err, "leave-diagnostics.android-network-type", "integer")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.rooms().leave(request, &self.opt.arg_room_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "language" => { + call = call.language(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1896,6 +2050,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1912,8 +2069,33 @@ impl Engine { fn _rooms_report_status(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::RoomP2PStatuses::default(); - let mut call = self.hub.rooms().report_status(&request, &self.opt.arg_room_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.rooms().report_status(request, &self.opt.arg_room_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1938,27 +2120,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2014,6 +2183,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2066,6 +2238,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2124,6 +2299,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2173,6 +2351,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2189,8 +2370,33 @@ impl Engine { fn _scores_submit_multiple(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::PlayerScoreSubmissionList::default(); - let mut call = self.hub.scores().submit_multiple(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.scores().submit_multiple(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2215,27 +2421,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2282,6 +2475,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2334,6 +2530,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2377,6 +2576,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2391,46 +2593,30 @@ impl Engine { fn _turn_based_matches_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::TurnBasedMatchCreateRequest::default(); - let mut call = self.hub.turn_based_matches().create(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "language" => { - call = call.language(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::TurnBasedMatchCreateRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_auto_matching_criteria_init(request: &mut api::TurnBasedMatchCreateRequest) { if request.auto_matching_criteria.is_none() { request.auto_matching_criteria = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "invited-player-ids" => { if request.invited_player_ids.is_none() { request.invited_player_ids = Some(Default::default()); @@ -2465,15 +2651,43 @@ impl Engine { request.request_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.turn_based_matches().create(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "language" => { + call = call.language(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2520,6 +2734,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2563,6 +2780,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2577,8 +2797,51 @@ impl Engine { fn _turn_based_matches_finish(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::TurnBasedMatchResults::default(); - let mut call = self.hub.turn_based_matches().finish(&request, &self.opt.arg_match_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + fn request_data_init(request: &mut api::TurnBasedMatchResults) { + if request.data.is_none() { + request.data = Some(Default::default()); + } + } + + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "data.kind" => { + request_data_init(&mut request); + request.data.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); + }, + "data.data" => { + request_data_init(&mut request); + request.data.as_mut().unwrap().data = Some(value.unwrap_or("").to_string()); + }, + "match-version" => { + request_data_init(&mut request); + request.match_version = Some(arg_from_str(value.unwrap_or("-0"), err, "match-version", "integer")); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.turn_based_matches().finish(request, &self.opt.arg_match_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2603,45 +2866,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_data_init(request: &mut api::TurnBasedMatchResults) { - if request.data.is_none() { - request.data = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "data.kind" => { - request_data_init(&mut request); - request.data.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); - }, - "data.data" => { - request_data_init(&mut request); - request.data.as_mut().unwrap().data = Some(value.unwrap_or("").to_string()); - }, - "match-version" => { - request_data_init(&mut request); - request.match_version = Some(arg_from_str(value.unwrap_or("-0"), err, "match-version", "integer")); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2691,6 +2923,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2737,6 +2972,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2783,6 +3021,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2833,6 +3074,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2891,6 +3135,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2940,6 +3187,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2998,6 +3248,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3014,8 +3267,55 @@ impl Engine { fn _turn_based_matches_take_turn(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::TurnBasedMatchTurn::default(); - let mut call = self.hub.turn_based_matches().take_turn(&request, &self.opt.arg_match_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + fn request_data_init(request: &mut api::TurnBasedMatchTurn) { + if request.data.is_none() { + request.data = Some(Default::default()); + } + } + + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "data.kind" => { + request_data_init(&mut request); + request.data.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); + }, + "data.data" => { + request_data_init(&mut request); + request.data.as_mut().unwrap().data = Some(value.unwrap_or("").to_string()); + }, + "match-version" => { + request_data_init(&mut request); + request.match_version = Some(arg_from_str(value.unwrap_or("-0"), err, "match-version", "integer")); + }, + "pending-participant-id" => { + request_data_init(&mut request); + request.pending_participant_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.turn_based_matches().take_turn(request, &self.opt.arg_match_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -3040,49 +3340,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_data_init(request: &mut api::TurnBasedMatchTurn) { - if request.data.is_none() { - request.data = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "data.kind" => { - request_data_init(&mut request); - request.data.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); - }, - "data.data" => { - request_data_init(&mut request); - request.data.as_mut().unwrap().data = Some(value.unwrap_or("").to_string()); - }, - "match-version" => { - request_data_init(&mut request); - request.match_version = Some(arg_from_str(value.unwrap_or("-0"), err, "match-version", "integer")); - }, - "pending-participant-id" => { - request_data_init(&mut request); - request.pending_participant_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3348,6 +3613,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -3355,8 +3621,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/games1/Cargo.toml b/gen/games1/Cargo.toml index 9909ccecab..1aae533bbf 100644 --- a/gen/games1/Cargo.toml +++ b/gen/games1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-games1" -version = "0.1.5+20150413" +version = "0.1.6+20150413" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with Games (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/games1" diff --git a/gen/games1/README.md b/gen/games1/README.md index 2a17bc66d0..1953fd1c34 100644 --- a/gen/games1/README.md +++ b/gen/games1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-games1` library allows access to all features of the *Google Games* service. -This documentation was generated from *Games* crate version *0.1.5+20150413*, where *20150413* is the exact revision of the *games:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *Games* crate version *0.1.6+20150413*, where *20150413* is the exact revision of the *games:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *Games* *v1* API can be found at the [official documentation site](https://developers.google.com/games/services/). @@ -136,14 +136,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/games1/src/cmn.rs b/gen/games1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/games1/src/cmn.rs +++ b/gen/games1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/games1/src/lib.rs b/gen/games1/src/lib.rs index 90d7567422..c7f320b401 100644 --- a/gen/games1/src/lib.rs +++ b/gen/games1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Games* crate version *0.1.5+20150413*, where *20150413* is the exact revision of the *games:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *Games* crate version *0.1.6+20150413*, where *20150413* is the exact revision of the *games:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *Games* *v1* API can be found at the //! [official documentation site](https://developers.google.com/games/services/). @@ -137,14 +137,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -232,7 +233,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -316,14 +317,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -344,7 +346,7 @@ impl<'a, C, A> Games<C, A> Games { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -395,7 +397,7 @@ impl<'a, C, A> Games<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -3212,10 +3214,10 @@ impl<'a, C, A> AchievementMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn update_multiple(&self, request: &AchievementUpdateMultipleRequest) -> AchievementUpdateMultipleCall<'a, C, A> { + pub fn update_multiple(&self, request: AchievementUpdateMultipleRequest) -> AchievementUpdateMultipleCall<'a, C, A> { AchievementUpdateMultipleCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3761,10 +3763,10 @@ impl<'a, C, A> TurnBasedMatcheMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn create(&self, request: &TurnBasedMatchCreateRequest) -> TurnBasedMatcheCreateCall<'a, C, A> { + pub fn create(&self, request: TurnBasedMatchCreateRequest) -> TurnBasedMatcheCreateCall<'a, C, A> { TurnBasedMatcheCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _language: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -3836,10 +3838,10 @@ impl<'a, C, A> TurnBasedMatcheMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `matchId` - The ID of the match. - pub fn finish(&self, request: &TurnBasedMatchResults, match_id: &str) -> TurnBasedMatcheFinishCall<'a, C, A> { + pub fn finish(&self, request: TurnBasedMatchResults, match_id: &str) -> TurnBasedMatcheFinishCall<'a, C, A> { TurnBasedMatcheFinishCall { hub: self.hub, - _request: request.clone(), + _request: request, _match_id: match_id.to_string(), _language: Default::default(), _delegate: Default::default(), @@ -3891,10 +3893,10 @@ impl<'a, C, A> TurnBasedMatcheMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `matchId` - The ID of the match. - pub fn take_turn(&self, request: &TurnBasedMatchTurn, match_id: &str) -> TurnBasedMatcheTakeTurnCall<'a, C, A> { + pub fn take_turn(&self, request: TurnBasedMatchTurn, match_id: &str) -> TurnBasedMatcheTakeTurnCall<'a, C, A> { TurnBasedMatcheTakeTurnCall { hub: self.hub, - _request: request.clone(), + _request: request, _match_id: match_id.to_string(), _language: Default::default(), _delegate: Default::default(), @@ -4061,10 +4063,10 @@ impl<'a, C, A> RoomMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `roomId` - The ID of the room. - pub fn leave(&self, request: &RoomLeaveRequest, room_id: &str) -> RoomLeaveCall<'a, C, A> { + pub fn leave(&self, request: RoomLeaveRequest, room_id: &str) -> RoomLeaveCall<'a, C, A> { RoomLeaveCall { hub: self.hub, - _request: request.clone(), + _request: request, _room_id: room_id.to_string(), _language: Default::default(), _delegate: Default::default(), @@ -4096,10 +4098,10 @@ impl<'a, C, A> RoomMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `roomId` - The ID of the room. - pub fn report_status(&self, request: &RoomP2PStatuses, room_id: &str) -> RoomReportStatuCall<'a, C, A> { + pub fn report_status(&self, request: RoomP2PStatuses, room_id: &str) -> RoomReportStatuCall<'a, C, A> { RoomReportStatuCall { hub: self.hub, - _request: request.clone(), + _request: request, _room_id: room_id.to_string(), _language: Default::default(), _delegate: Default::default(), @@ -4115,10 +4117,10 @@ impl<'a, C, A> RoomMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn create(&self, request: &RoomCreateRequest) -> RoomCreateCall<'a, C, A> { + pub fn create(&self, request: RoomCreateRequest) -> RoomCreateCall<'a, C, A> { RoomCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _language: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -4169,10 +4171,10 @@ impl<'a, C, A> RoomMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `roomId` - The ID of the room. - pub fn join(&self, request: &RoomJoinRequest, room_id: &str) -> RoomJoinCall<'a, C, A> { + pub fn join(&self, request: RoomJoinRequest, room_id: &str) -> RoomJoinCall<'a, C, A> { RoomJoinCall { hub: self.hub, - _request: request.clone(), + _request: request, _room_id: room_id.to_string(), _language: Default::default(), _delegate: Default::default(), @@ -4300,10 +4302,10 @@ impl<'a, C, A> ScoreMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn submit_multiple(&self, request: &PlayerScoreSubmissionList) -> ScoreSubmitMultipleCall<'a, C, A> { + pub fn submit_multiple(&self, request: PlayerScoreSubmissionList) -> ScoreSubmitMultipleCall<'a, C, A> { ScoreSubmitMultipleCall { hub: self.hub, - _request: request.clone(), + _request: request, _language: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -4385,10 +4387,10 @@ impl<'a, C, A> PushtokenMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn remove(&self, request: &PushTokenId) -> PushtokenRemoveCall<'a, C, A> { + pub fn remove(&self, request: PushTokenId) -> PushtokenRemoveCall<'a, C, A> { PushtokenRemoveCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -4402,10 +4404,10 @@ impl<'a, C, A> PushtokenMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn update(&self, request: &PushToken) -> PushtokenUpdateCall<'a, C, A> { + pub fn update(&self, request: PushToken) -> PushtokenUpdateCall<'a, C, A> { PushtokenUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -4538,10 +4540,10 @@ impl<'a, C, A> EventMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn record(&self, request: &EventRecordRequest) -> EventRecordCall<'a, C, A> { + pub fn record(&self, request: EventRecordRequest) -> EventRecordCall<'a, C, A> { EventRecordCall { hub: self.hub, - _request: request.clone(), + _request: request, _language: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -4856,12 +4858,17 @@ impl<'a, C, A> AchievementListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4870,7 +4877,7 @@ impl<'a, C, A> AchievementListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5125,12 +5132,17 @@ impl<'a, C, A> AchievementIncrementCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5139,7 +5151,7 @@ impl<'a, C, A> AchievementIncrementCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5378,12 +5390,17 @@ impl<'a, C, A> AchievementSetStepsAtLeastCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5392,7 +5409,7 @@ impl<'a, C, A> AchievementSetStepsAtLeastCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5509,7 +5526,7 @@ impl<'a, C, A> AchievementSetStepsAtLeastCall<'a, C, A> where C: BorrowMut<hyper /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.achievements().update_multiple(&req) +/// let result = hub.achievements().update_multiple(req) /// .doit(); /// # } /// ``` @@ -5611,12 +5628,17 @@ impl<'a, C, A> AchievementUpdateMultipleCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5625,7 +5647,7 @@ impl<'a, C, A> AchievementUpdateMultipleCall<'a, C, A> where C: BorrowMut<hyper: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5643,8 +5665,8 @@ impl<'a, C, A> AchievementUpdateMultipleCall<'a, C, A> where C: BorrowMut<hyper: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AchievementUpdateMultipleRequest) -> AchievementUpdateMultipleCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AchievementUpdateMultipleRequest) -> AchievementUpdateMultipleCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -5844,12 +5866,17 @@ impl<'a, C, A> AchievementRevealCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5858,7 +5885,7 @@ impl<'a, C, A> AchievementRevealCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6078,12 +6105,17 @@ impl<'a, C, A> AchievementUnlockCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6092,7 +6124,7 @@ impl<'a, C, A> AchievementUnlockCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6317,12 +6349,17 @@ impl<'a, C, A> LeaderboardGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6331,7 +6368,7 @@ impl<'a, C, A> LeaderboardGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6547,12 +6584,17 @@ impl<'a, C, A> LeaderboardListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6561,7 +6603,7 @@ impl<'a, C, A> LeaderboardListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6809,12 +6851,17 @@ impl<'a, C, A> MetagameListCategoriesByPlayerCall<'a, C, A> where C: BorrowMut<h if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6823,7 +6870,7 @@ impl<'a, C, A> MetagameListCategoriesByPlayerCall<'a, C, A> where C: BorrowMut<h Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7048,12 +7095,17 @@ impl<'a, C, A> MetagameGetMetagameConfigCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7062,7 +7114,7 @@ impl<'a, C, A> MetagameGetMetagameConfigCall<'a, C, A> where C: BorrowMut<hyper: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7287,12 +7339,17 @@ impl<'a, C, A> PlayerListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7301,7 +7358,7 @@ impl<'a, C, A> PlayerListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7547,12 +7604,17 @@ impl<'a, C, A> PlayerGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7561,7 +7623,7 @@ impl<'a, C, A> PlayerGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7793,12 +7855,17 @@ impl<'a, C, A> QuestAcceptCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7807,7 +7874,7 @@ impl<'a, C, A> QuestAcceptCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8049,12 +8116,17 @@ impl<'a, C, A> QuestListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8063,7 +8135,7 @@ impl<'a, C, A> QuestListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8309,12 +8381,17 @@ impl<'a, C, A> SnapshotGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8323,7 +8400,7 @@ impl<'a, C, A> SnapshotGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8565,12 +8642,17 @@ impl<'a, C, A> SnapshotListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8579,7 +8661,7 @@ impl<'a, C, A> SnapshotListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8819,12 +8901,17 @@ impl<'a, C, A> TurnBasedMatcheDismisCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -9042,12 +9129,17 @@ impl<'a, C, A> TurnBasedMatcheSyncCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9056,7 +9148,7 @@ impl<'a, C, A> TurnBasedMatcheSyncCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9306,12 +9398,17 @@ impl<'a, C, A> TurnBasedMatcheDeclineCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9320,7 +9417,7 @@ impl<'a, C, A> TurnBasedMatcheDeclineCall<'a, C, A> where C: BorrowMut<hyper::Cl Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9557,12 +9654,17 @@ impl<'a, C, A> TurnBasedMatcheGetCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9571,7 +9673,7 @@ impl<'a, C, A> TurnBasedMatcheGetCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9692,7 +9794,7 @@ impl<'a, C, A> TurnBasedMatcheGetCall<'a, C, A> where C: BorrowMut<hyper::Client /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.turn_based_matches().create(&req) +/// let result = hub.turn_based_matches().create(req) /// .language("dolor") /// .doit(); /// # } @@ -9799,12 +9901,17 @@ impl<'a, C, A> TurnBasedMatcheCreateCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9813,7 +9920,7 @@ impl<'a, C, A> TurnBasedMatcheCreateCall<'a, C, A> where C: BorrowMut<hyper::Cli Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9831,8 +9938,8 @@ impl<'a, C, A> TurnBasedMatcheCreateCall<'a, C, A> where C: BorrowMut<hyper::Cli /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &TurnBasedMatchCreateRequest) -> TurnBasedMatcheCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: TurnBasedMatchCreateRequest) -> TurnBasedMatcheCreateCall<'a, C, A> { + self._request = new_value; self } /// The preferred language to use for strings returned by this method. @@ -10044,12 +10151,17 @@ impl<'a, C, A> TurnBasedMatcheJoinCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10058,7 +10170,7 @@ impl<'a, C, A> TurnBasedMatcheJoinCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10297,12 +10409,17 @@ impl<'a, C, A> TurnBasedMatcheLeaveTurnCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10311,7 +10428,7 @@ impl<'a, C, A> TurnBasedMatcheLeaveTurnCall<'a, C, A> where C: BorrowMut<hyper:: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10554,12 +10671,17 @@ impl<'a, C, A> TurnBasedMatcheCancelCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -10665,7 +10787,7 @@ impl<'a, C, A> TurnBasedMatcheCancelCall<'a, C, A> where C: BorrowMut<hyper::Cli /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.turn_based_matches().finish(&req, "matchId") +/// let result = hub.turn_based_matches().finish(req, "matchId") /// .language("vero") /// .doit(); /// # } @@ -10798,12 +10920,17 @@ impl<'a, C, A> TurnBasedMatcheFinishCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10812,7 +10939,7 @@ impl<'a, C, A> TurnBasedMatcheFinishCall<'a, C, A> where C: BorrowMut<hyper::Cli Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10830,8 +10957,8 @@ impl<'a, C, A> TurnBasedMatcheFinishCall<'a, C, A> where C: BorrowMut<hyper::Cli /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &TurnBasedMatchResults) -> TurnBasedMatcheFinishCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: TurnBasedMatchResults) -> TurnBasedMatcheFinishCall<'a, C, A> { + self._request = new_value; self } /// The ID of the match. @@ -11053,12 +11180,17 @@ impl<'a, C, A> TurnBasedMatcheLeaveCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11067,7 +11199,7 @@ impl<'a, C, A> TurnBasedMatcheLeaveCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11293,12 +11425,17 @@ impl<'a, C, A> TurnBasedMatcheListCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11307,7 +11444,7 @@ impl<'a, C, A> TurnBasedMatcheListCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11439,7 +11576,7 @@ impl<'a, C, A> TurnBasedMatcheListCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.turn_based_matches().take_turn(&req, "matchId") +/// let result = hub.turn_based_matches().take_turn(req, "matchId") /// .language("dolore") /// .doit(); /// # } @@ -11572,12 +11709,17 @@ impl<'a, C, A> TurnBasedMatcheTakeTurnCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11586,7 +11728,7 @@ impl<'a, C, A> TurnBasedMatcheTakeTurnCall<'a, C, A> where C: BorrowMut<hyper::C Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11604,8 +11746,8 @@ impl<'a, C, A> TurnBasedMatcheTakeTurnCall<'a, C, A> where C: BorrowMut<hyper::C /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &TurnBasedMatchTurn) -> TurnBasedMatcheTakeTurnCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: TurnBasedMatchTurn) -> TurnBasedMatcheTakeTurnCall<'a, C, A> { + self._request = new_value; self } /// The ID of the match. @@ -11832,12 +11974,17 @@ impl<'a, C, A> TurnBasedMatcheRematchCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11846,7 +11993,7 @@ impl<'a, C, A> TurnBasedMatcheRematchCall<'a, C, A> where C: BorrowMut<hyper::Cl Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12090,12 +12237,17 @@ impl<'a, C, A> ApplicationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12104,7 +12256,7 @@ impl<'a, C, A> ApplicationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12311,12 +12463,17 @@ impl<'a, C, A> ApplicationPlayedCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -12530,12 +12687,17 @@ impl<'a, C, A> RoomGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12544,7 +12706,7 @@ impl<'a, C, A> RoomGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12658,7 +12820,7 @@ impl<'a, C, A> RoomGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.rooms().leave(&req, "roomId") +/// let result = hub.rooms().leave(req, "roomId") /// .language("sanctus") /// .doit(); /// # } @@ -12791,12 +12953,17 @@ impl<'a, C, A> RoomLeaveCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12805,7 +12972,7 @@ impl<'a, C, A> RoomLeaveCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12823,8 +12990,8 @@ impl<'a, C, A> RoomLeaveCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &RoomLeaveRequest) -> RoomLeaveCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: RoomLeaveRequest) -> RoomLeaveCall<'a, C, A> { + self._request = new_value; self } /// The ID of the room. @@ -13030,12 +13197,17 @@ impl<'a, C, A> RoomListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13044,7 +13216,7 @@ impl<'a, C, A> RoomListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13162,7 +13334,7 @@ impl<'a, C, A> RoomListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.rooms().report_status(&req, "roomId") +/// let result = hub.rooms().report_status(req, "roomId") /// .language("ea") /// .doit(); /// # } @@ -13295,12 +13467,17 @@ impl<'a, C, A> RoomReportStatuCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13309,7 +13486,7 @@ impl<'a, C, A> RoomReportStatuCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13327,8 +13504,8 @@ impl<'a, C, A> RoomReportStatuCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &RoomP2PStatuses) -> RoomReportStatuCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: RoomP2PStatuses) -> RoomReportStatuCall<'a, C, A> { + self._request = new_value; self } /// The ID of the room. @@ -13432,7 +13609,7 @@ impl<'a, C, A> RoomReportStatuCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.rooms().create(&req) +/// let result = hub.rooms().create(req) /// .language("sadipscing") /// .doit(); /// # } @@ -13539,12 +13716,17 @@ impl<'a, C, A> RoomCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13553,7 +13735,7 @@ impl<'a, C, A> RoomCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13571,8 +13753,8 @@ impl<'a, C, A> RoomCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &RoomCreateRequest) -> RoomCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: RoomCreateRequest) -> RoomCreateCall<'a, C, A> { + self._request = new_value; self } /// The preferred language to use for strings returned by this method. @@ -13784,12 +13966,17 @@ impl<'a, C, A> RoomDeclineCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13798,7 +13985,7 @@ impl<'a, C, A> RoomDeclineCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14024,12 +14211,17 @@ impl<'a, C, A> RoomDismisCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -14135,7 +14327,7 @@ impl<'a, C, A> RoomDismisCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.rooms().join(&req, "roomId") +/// let result = hub.rooms().join(req, "roomId") /// .language("aliquyam") /// .doit(); /// # } @@ -14268,12 +14460,17 @@ impl<'a, C, A> RoomJoinCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14282,7 +14479,7 @@ impl<'a, C, A> RoomJoinCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14300,8 +14497,8 @@ impl<'a, C, A> RoomJoinCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &RoomJoinRequest) -> RoomJoinCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: RoomJoinRequest) -> RoomJoinCall<'a, C, A> { + self._request = new_value; self } /// The ID of the room. @@ -14530,12 +14727,17 @@ impl<'a, C, A> ScoreSubmitCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14544,7 +14746,7 @@ impl<'a, C, A> ScoreSubmitCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14807,12 +15009,17 @@ impl<'a, C, A> ScoreListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14821,7 +15028,7 @@ impl<'a, C, A> ScoreListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15107,12 +15314,17 @@ impl<'a, C, A> ScoreGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15121,7 +15333,7 @@ impl<'a, C, A> ScoreGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15276,7 +15488,7 @@ impl<'a, C, A> ScoreGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.scores().submit_multiple(&req) +/// let result = hub.scores().submit_multiple(req) /// .language("ut") /// .doit(); /// # } @@ -15383,12 +15595,17 @@ impl<'a, C, A> ScoreSubmitMultipleCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15397,7 +15614,7 @@ impl<'a, C, A> ScoreSubmitMultipleCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15415,8 +15632,8 @@ impl<'a, C, A> ScoreSubmitMultipleCall<'a, C, A> where C: BorrowMut<hyper::Clien /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PlayerScoreSubmissionList) -> ScoreSubmitMultipleCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PlayerScoreSubmissionList) -> ScoreSubmitMultipleCall<'a, C, A> { + self._request = new_value; self } /// The preferred language to use for strings returned by this method. @@ -15652,12 +15869,17 @@ impl<'a, C, A> ScoreListWindowCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15666,7 +15888,7 @@ impl<'a, C, A> ScoreListWindowCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15828,7 +16050,7 @@ impl<'a, C, A> ScoreListWindowCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.pushtokens().remove(&req) +/// let result = hub.pushtokens().remove(req) /// .doit(); /// # } /// ``` @@ -15929,12 +16151,17 @@ impl<'a, C, A> PushtokenRemoveCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -15951,8 +16178,8 @@ impl<'a, C, A> PushtokenRemoveCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PushTokenId) -> PushtokenRemoveCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PushTokenId) -> PushtokenRemoveCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -16039,7 +16266,7 @@ impl<'a, C, A> PushtokenRemoveCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.pushtokens().update(&req) +/// let result = hub.pushtokens().update(req) /// .doit(); /// # } /// ``` @@ -16140,12 +16367,17 @@ impl<'a, C, A> PushtokenUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -16162,8 +16394,8 @@ impl<'a, C, A> PushtokenUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PushToken) -> PushtokenUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PushToken) -> PushtokenUpdateCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -16339,12 +16571,17 @@ impl<'a, C, A> RevisionCheckCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16353,7 +16590,7 @@ impl<'a, C, A> RevisionCheckCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16567,12 +16804,17 @@ impl<'a, C, A> EventListDefinitionCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16581,7 +16823,7 @@ impl<'a, C, A> EventListDefinitionCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16699,7 +16941,7 @@ impl<'a, C, A> EventListDefinitionCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.events().record(&req) +/// let result = hub.events().record(req) /// .language("eos") /// .doit(); /// # } @@ -16806,12 +17048,17 @@ impl<'a, C, A> EventRecordCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16820,7 +17067,7 @@ impl<'a, C, A> EventRecordCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16838,8 +17085,8 @@ impl<'a, C, A> EventRecordCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &EventRecordRequest) -> EventRecordCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: EventRecordRequest) -> EventRecordCall<'a, C, A> { + self._request = new_value; self } /// The preferred language to use for strings returned by this method. @@ -17035,12 +17282,17 @@ impl<'a, C, A> EventListByPlayerCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -17049,7 +17301,7 @@ impl<'a, C, A> EventListByPlayerCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -17283,12 +17535,17 @@ impl<'a, C, A> QuestMilestoneClaimCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -17516,12 +17773,17 @@ impl<'a, C, A> AchievementDefinitionListCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -17530,7 +17792,7 @@ impl<'a, C, A> AchievementDefinitionListCall<'a, C, A> where C: BorrowMut<hyper: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/gamesconfiguration1_configuration-cli/Cargo.toml b/gen/gamesconfiguration1_configuration-cli/Cargo.toml index a3a7df111d..4dd1e305d7 100644 --- a/gen/gamesconfiguration1_configuration-cli/Cargo.toml +++ b/gen/gamesconfiguration1_configuration-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-gamesconfiguration1_configuration-cli" -version = "0.0.1+20150413" +version = "0.1.0+20150413" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with Games Configuration (protocol v1configuration)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/gamesconfiguration1_configuration-cli" diff --git a/gen/gamesconfiguration1_configuration-cli/README.md b/gen/gamesconfiguration1_configuration-cli/README.md index 70e029245e..2b61bdba9e 100644 --- a/gen/gamesconfiguration1_configuration-cli/README.md +++ b/gen/gamesconfiguration1_configuration-cli/README.md @@ -1,4 +1,114 @@ -# HELLO GAMESCONFIGURATION:V1CONFIGURATION +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `gamesconfiguration1-configuration` command-line interface *(CLI)* allows to use most features of the *Google Games Configuration* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *Games Configuration* API at revision *20150413*. The CLI is at version *0.1.0*. + +```bash + gamesconfiguration1-configuration [options] achievement-configurations delete <achievement-id> [-p <v>...] + gamesconfiguration1-configuration [options] achievement-configurations get <achievement-id> [-p <v>...] [-o <out>] + gamesconfiguration1-configuration [options] achievement-configurations insert <application-id> -r <kv>... [-p <v>...] [-o <out>] + gamesconfiguration1-configuration [options] achievement-configurations list <application-id> [-p <v>...] [-o <out>] + gamesconfiguration1-configuration [options] achievement-configurations patch <achievement-id> -r <kv>... [-p <v>...] [-o <out>] + gamesconfiguration1-configuration [options] achievement-configurations update <achievement-id> -r <kv>... [-p <v>...] [-o <out>] + gamesconfiguration1-configuration [options] image-configurations upload <resource-id> <image-type> -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + gamesconfiguration1-configuration [options] leaderboard-configurations delete <leaderboard-id> [-p <v>...] + gamesconfiguration1-configuration [options] leaderboard-configurations get <leaderboard-id> [-p <v>...] [-o <out>] + gamesconfiguration1-configuration [options] leaderboard-configurations insert <application-id> -r <kv>... [-p <v>...] [-o <out>] + gamesconfiguration1-configuration [options] leaderboard-configurations list <application-id> [-p <v>...] [-o <out>] + gamesconfiguration1-configuration [options] leaderboard-configurations patch <leaderboard-id> -r <kv>... [-p <v>...] [-o <out>] + gamesconfiguration1-configuration [options] leaderboard-configurations update <leaderboard-id> -r <kv>... [-p <v>...] [-o <out>] + gamesconfiguration1-configuration --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_gamesconfiguration1_configuration_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `gamesconfiguration1-configuration-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/gamesconfiguration1-configuration-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/gamesconfiguration1-configuration-secret.json`, assuming that the required *gamesConfiguration* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `gamesconfiguration1-configuration --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/gamesconfiguration1_configuration-cli/mkdocs.yml b/gen/gamesconfiguration1_configuration-cli/mkdocs.yml index d3d7652522..377eefdc1b 100644 --- a/gen/gamesconfiguration1_configuration-cli/mkdocs.yml +++ b/gen/gamesconfiguration1_configuration-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Games Configuration v0.0.1+20150413 +site_name: Games Configuration v0.1.0+20150413 site_url: http://byron.github.io/google-apis-rs/google-gamesconfiguration1_configuration-cli site_description: Write integrating applications with bcore diff --git a/gen/gamesconfiguration1_configuration-cli/src/cmn.rs b/gen/gamesconfiguration1_configuration-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/gamesconfiguration1_configuration-cli/src/cmn.rs +++ b/gen/gamesconfiguration1_configuration-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/gamesconfiguration1_configuration-cli/src/main.rs b/gen/gamesconfiguration1_configuration-cli/src/main.rs index 046971a6ee..346ecdf6d3 100644 --- a/gen/gamesconfiguration1_configuration-cli/src/main.rs +++ b/gen/gamesconfiguration1_configuration-cli/src/main.rs @@ -19,38 +19,39 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - gamesconfiguration1-configuration [options] achievement-configurations delete <achievement-id> [-p <v>]... - gamesconfiguration1-configuration [options] achievement-configurations get <achievement-id> [-p <v>]... [-o <out>] - gamesconfiguration1-configuration [options] achievement-configurations insert <application-id> -r <kv>... [-p <v>]... [-o <out>] - gamesconfiguration1-configuration [options] achievement-configurations list <application-id> [-p <v>]... [-o <out>] - gamesconfiguration1-configuration [options] achievement-configurations patch <achievement-id> -r <kv>... [-p <v>]... [-o <out>] - gamesconfiguration1-configuration [options] achievement-configurations update <achievement-id> -r <kv>... [-p <v>]... [-o <out>] - gamesconfiguration1-configuration [options] image-configurations upload <resource-id> <image-type> -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] - gamesconfiguration1-configuration [options] leaderboard-configurations delete <leaderboard-id> [-p <v>]... - gamesconfiguration1-configuration [options] leaderboard-configurations get <leaderboard-id> [-p <v>]... [-o <out>] - gamesconfiguration1-configuration [options] leaderboard-configurations insert <application-id> -r <kv>... [-p <v>]... [-o <out>] - gamesconfiguration1-configuration [options] leaderboard-configurations list <application-id> [-p <v>]... [-o <out>] - gamesconfiguration1-configuration [options] leaderboard-configurations patch <leaderboard-id> -r <kv>... [-p <v>]... [-o <out>] - gamesconfiguration1-configuration [options] leaderboard-configurations update <leaderboard-id> -r <kv>... [-p <v>]... [-o <out>] + gamesconfiguration1-configuration [options] achievement-configurations delete <achievement-id> [-p <v>...] + gamesconfiguration1-configuration [options] achievement-configurations get <achievement-id> [-p <v>...] [-o <out>] + gamesconfiguration1-configuration [options] achievement-configurations insert <application-id> -r <kv>... [-p <v>...] [-o <out>] + gamesconfiguration1-configuration [options] achievement-configurations list <application-id> [-p <v>...] [-o <out>] + gamesconfiguration1-configuration [options] achievement-configurations patch <achievement-id> -r <kv>... [-p <v>...] [-o <out>] + gamesconfiguration1-configuration [options] achievement-configurations update <achievement-id> -r <kv>... [-p <v>...] [-o <out>] + gamesconfiguration1-configuration [options] image-configurations upload <resource-id> <image-type> -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + gamesconfiguration1-configuration [options] leaderboard-configurations delete <leaderboard-id> [-p <v>...] + gamesconfiguration1-configuration [options] leaderboard-configurations get <leaderboard-id> [-p <v>...] [-o <out>] + gamesconfiguration1-configuration [options] leaderboard-configurations insert <application-id> -r <kv>... [-p <v>...] [-o <out>] + gamesconfiguration1-configuration [options] leaderboard-configurations list <application-id> [-p <v>...] [-o <out>] + gamesconfiguration1-configuration [options] leaderboard-configurations patch <leaderboard-id> -r <kv>... [-p <v>...] [-o <out>] + gamesconfiguration1-configuration [options] leaderboard-configurations update <leaderboard-id> -r <kv>... [-p <v>...] [-o <out>] gamesconfiguration1-configuration --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_gamesconfiguration1_configuration_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -99,6 +100,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -140,6 +144,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -156,36 +163,23 @@ impl Engine { fn _achievement_configurations_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::AchievementConfiguration::default(); - let mut call = self.hub.achievement_configurations().insert(&request, &self.opt.arg_application_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::AchievementConfiguration::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_draft_description_init(request: &mut api::AchievementConfiguration) { request_draft_init(request); if request.draft.as_mut().unwrap().description.is_none() { @@ -226,7 +220,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "achievement-type" => { request.achievement_type = Some(value.unwrap_or("").to_string()); }, @@ -295,15 +289,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.achievement_configurations().insert(request, &self.opt.arg_application_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -353,6 +372,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -369,36 +391,23 @@ impl Engine { fn _achievement_configurations_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::AchievementConfiguration::default(); - let mut call = self.hub.achievement_configurations().patch(&request, &self.opt.arg_achievement_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::AchievementConfiguration::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_draft_description_init(request: &mut api::AchievementConfiguration) { request_draft_init(request); if request.draft.as_mut().unwrap().description.is_none() { @@ -439,7 +448,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "achievement-type" => { request.achievement_type = Some(value.unwrap_or("").to_string()); }, @@ -508,15 +517,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.achievement_configurations().patch(request, &self.opt.arg_achievement_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -533,36 +567,23 @@ impl Engine { fn _achievement_configurations_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::AchievementConfiguration::default(); - let mut call = self.hub.achievement_configurations().update(&request, &self.opt.arg_achievement_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::AchievementConfiguration::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_draft_description_init(request: &mut api::AchievementConfiguration) { request_draft_init(request); if request.draft.as_mut().unwrap().description.is_none() { @@ -603,7 +624,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "achievement-type" => { request.achievement_type = Some(value.unwrap_or("").to_string()); }, @@ -672,15 +693,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.achievement_configurations().update(request, &self.opt.arg_achievement_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -733,6 +779,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -777,6 +826,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -818,6 +870,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -834,36 +889,23 @@ impl Engine { fn _leaderboard_configurations_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::LeaderboardConfiguration::default(); - let mut call = self.hub.leaderboard_configurations().insert(&request, &self.opt.arg_application_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::LeaderboardConfiguration::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_draft_init(request: &mut api::LeaderboardConfiguration) { if request.draft.is_none() { request.draft = Some(Default::default()); @@ -1002,7 +1044,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1127,15 +1169,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.leaderboard_configurations().insert(request, &self.opt.arg_application_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1185,6 +1252,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1201,36 +1271,23 @@ impl Engine { fn _leaderboard_configurations_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::LeaderboardConfiguration::default(); - let mut call = self.hub.leaderboard_configurations().patch(&request, &self.opt.arg_leaderboard_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::LeaderboardConfiguration::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_draft_init(request: &mut api::LeaderboardConfiguration) { if request.draft.is_none() { request.draft = Some(Default::default()); @@ -1369,7 +1426,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1494,15 +1551,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.leaderboard_configurations().patch(request, &self.opt.arg_leaderboard_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1519,36 +1601,23 @@ impl Engine { fn _leaderboard_configurations_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::LeaderboardConfiguration::default(); - let mut call = self.hub.leaderboard_configurations().update(&request, &self.opt.arg_leaderboard_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::LeaderboardConfiguration::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_draft_init(request: &mut api::LeaderboardConfiguration) { if request.draft.is_none() { request.draft = Some(Default::default()); @@ -1687,7 +1756,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1812,15 +1881,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.leaderboard_configurations().update(request, &self.opt.arg_leaderboard_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1948,6 +2042,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -1955,8 +2050,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/gamesconfiguration1_configuration/Cargo.toml b/gen/gamesconfiguration1_configuration/Cargo.toml index 8cef486989..6c19e0ddd4 100644 --- a/gen/gamesconfiguration1_configuration/Cargo.toml +++ b/gen/gamesconfiguration1_configuration/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-gamesconfiguration1_configuration" -version = "0.1.5+20150413" +version = "0.1.6+20150413" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with Games Configuration (protocol v1configuration)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/gamesconfiguration1_configuration" diff --git a/gen/gamesconfiguration1_configuration/README.md b/gen/gamesconfiguration1_configuration/README.md index 9eb6dc3ed9..fe2cb894ca 100644 --- a/gen/gamesconfiguration1_configuration/README.md +++ b/gen/gamesconfiguration1_configuration/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-gamesconfiguration1_configuration` library allows access to all features of the *Google Games Configuration* service. -This documentation was generated from *Games Configuration* crate version *0.1.5+20150413*, where *20150413* is the exact revision of the *gamesConfiguration:v1configuration* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *Games Configuration* crate version *0.1.6+20150413*, where *20150413* is the exact revision of the *gamesConfiguration:v1configuration* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *Games Configuration* *v1_configuration* API can be found at the [official documentation site](https://developers.google.com/games/services). @@ -114,14 +114,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/gamesconfiguration1_configuration/src/cmn.rs b/gen/gamesconfiguration1_configuration/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/gamesconfiguration1_configuration/src/cmn.rs +++ b/gen/gamesconfiguration1_configuration/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/gamesconfiguration1_configuration/src/lib.rs b/gen/gamesconfiguration1_configuration/src/lib.rs index 62c9bdde57..aec6f9cd9d 100644 --- a/gen/gamesconfiguration1_configuration/src/lib.rs +++ b/gen/gamesconfiguration1_configuration/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Games Configuration* crate version *0.1.5+20150413*, where *20150413* is the exact revision of the *gamesConfiguration:v1configuration* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *Games Configuration* crate version *0.1.6+20150413*, where *20150413* is the exact revision of the *gamesConfiguration:v1configuration* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *Games Configuration* *v1_configuration* API can be found at the //! [official documentation site](https://developers.google.com/games/services). @@ -115,14 +115,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -210,7 +211,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -286,14 +287,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -314,7 +316,7 @@ impl<'a, C, A> GamesConfiguration<C, A> GamesConfiguration { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -329,7 +331,7 @@ impl<'a, C, A> GamesConfiguration<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -771,10 +773,10 @@ impl<'a, C, A> AchievementConfigurationMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `achievementId` - The ID of the achievement used by this method. - pub fn update(&self, request: &AchievementConfiguration, achievement_id: &str) -> AchievementConfigurationUpdateCall<'a, C, A> { + pub fn update(&self, request: AchievementConfiguration, achievement_id: &str) -> AchievementConfigurationUpdateCall<'a, C, A> { AchievementConfigurationUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _achievement_id: achievement_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -790,10 +792,10 @@ impl<'a, C, A> AchievementConfigurationMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `applicationId` - The application ID from the Google Play developer console. - pub fn insert(&self, request: &AchievementConfiguration, application_id: &str) -> AchievementConfigurationInsertCall<'a, C, A> { + pub fn insert(&self, request: AchievementConfiguration, application_id: &str) -> AchievementConfigurationInsertCall<'a, C, A> { AchievementConfigurationInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _application_id: application_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -826,10 +828,10 @@ impl<'a, C, A> AchievementConfigurationMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `achievementId` - The ID of the achievement used by this method. - pub fn patch(&self, request: &AchievementConfiguration, achievement_id: &str) -> AchievementConfigurationPatchCall<'a, C, A> { + pub fn patch(&self, request: AchievementConfiguration, achievement_id: &str) -> AchievementConfigurationPatchCall<'a, C, A> { AchievementConfigurationPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _achievement_id: achievement_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -903,10 +905,10 @@ impl<'a, C, A> LeaderboardConfigurationMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `applicationId` - The application ID from the Google Play developer console. - pub fn insert(&self, request: &LeaderboardConfiguration, application_id: &str) -> LeaderboardConfigurationInsertCall<'a, C, A> { + pub fn insert(&self, request: LeaderboardConfiguration, application_id: &str) -> LeaderboardConfigurationInsertCall<'a, C, A> { LeaderboardConfigurationInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _application_id: application_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -939,10 +941,10 @@ impl<'a, C, A> LeaderboardConfigurationMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `leaderboardId` - The ID of the leaderboard. - pub fn patch(&self, request: &LeaderboardConfiguration, leaderboard_id: &str) -> LeaderboardConfigurationPatchCall<'a, C, A> { + pub fn patch(&self, request: LeaderboardConfiguration, leaderboard_id: &str) -> LeaderboardConfigurationPatchCall<'a, C, A> { LeaderboardConfigurationPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _leaderboard_id: leaderboard_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -958,10 +960,10 @@ impl<'a, C, A> LeaderboardConfigurationMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `leaderboardId` - The ID of the leaderboard. - pub fn update(&self, request: &LeaderboardConfiguration, leaderboard_id: &str) -> LeaderboardConfigurationUpdateCall<'a, C, A> { + pub fn update(&self, request: LeaderboardConfiguration, leaderboard_id: &str) -> LeaderboardConfigurationUpdateCall<'a, C, A> { LeaderboardConfigurationUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _leaderboard_id: leaderboard_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1088,14 +1090,15 @@ impl<'a, C, A> ImageConfigurationUploadCall<'a, C, A> where C: BorrowMut<hyper:: params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/games/v1configuration/images/{resourceId}/imageType/{imageType}".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/games/v1configuration/images/{resourceId}/imageType/{imageType}".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/games/v1configuration/images/{resourceId}/imageType/{imageType}".to_string() + ("https://www.googleapis.com/resumable/upload/games/v1configuration/images/{resourceId}/imageType/{imageType}".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::Androidpublisher.as_ref().to_string(), ()); } @@ -1201,12 +1204,17 @@ impl<'a, C, A> ImageConfigurationUploadCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -1216,9 +1224,9 @@ impl<'a, C, A> ImageConfigurationUploadCall<'a, C, A> where C: BorrowMut<hyper:: } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -1228,7 +1236,7 @@ impl<'a, C, A> ImageConfigurationUploadCall<'a, C, A> where C: BorrowMut<hyper:: auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -1259,7 +1267,7 @@ impl<'a, C, A> ImageConfigurationUploadCall<'a, C, A> where C: BorrowMut<hyper:: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1525,12 +1533,17 @@ impl<'a, C, A> AchievementConfigurationListCall<'a, C, A> where C: BorrowMut<hyp if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1539,7 +1552,7 @@ impl<'a, C, A> AchievementConfigurationListCall<'a, C, A> where C: BorrowMut<hyp Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1660,7 +1673,7 @@ impl<'a, C, A> AchievementConfigurationListCall<'a, C, A> where C: BorrowMut<hyp /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.achievement_configurations().update(&req, "achievementId") +/// let result = hub.achievement_configurations().update(req, "achievementId") /// .doit(); /// # } /// ``` @@ -1788,12 +1801,17 @@ impl<'a, C, A> AchievementConfigurationUpdateCall<'a, C, A> where C: BorrowMut<h if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1802,7 +1820,7 @@ impl<'a, C, A> AchievementConfigurationUpdateCall<'a, C, A> where C: BorrowMut<h Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1820,8 +1838,8 @@ impl<'a, C, A> AchievementConfigurationUpdateCall<'a, C, A> where C: BorrowMut<h /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AchievementConfiguration) -> AchievementConfigurationUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AchievementConfiguration) -> AchievementConfigurationUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the achievement used by this method. @@ -1918,7 +1936,7 @@ impl<'a, C, A> AchievementConfigurationUpdateCall<'a, C, A> where C: BorrowMut<h /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.achievement_configurations().insert(&req, "applicationId") +/// let result = hub.achievement_configurations().insert(req, "applicationId") /// .doit(); /// # } /// ``` @@ -2046,12 +2064,17 @@ impl<'a, C, A> AchievementConfigurationInsertCall<'a, C, A> where C: BorrowMut<h if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2060,7 +2083,7 @@ impl<'a, C, A> AchievementConfigurationInsertCall<'a, C, A> where C: BorrowMut<h Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2078,8 +2101,8 @@ impl<'a, C, A> AchievementConfigurationInsertCall<'a, C, A> where C: BorrowMut<h /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AchievementConfiguration) -> AchievementConfigurationInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AchievementConfiguration) -> AchievementConfigurationInsertCall<'a, C, A> { + self._request = new_value; self } /// The application ID from the Google Play developer console. @@ -2289,12 +2312,17 @@ impl<'a, C, A> AchievementConfigurationGetCall<'a, C, A> where C: BorrowMut<hype if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2303,7 +2331,7 @@ impl<'a, C, A> AchievementConfigurationGetCall<'a, C, A> where C: BorrowMut<hype Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2410,7 +2438,7 @@ impl<'a, C, A> AchievementConfigurationGetCall<'a, C, A> where C: BorrowMut<hype /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.achievement_configurations().patch(&req, "achievementId") +/// let result = hub.achievement_configurations().patch(req, "achievementId") /// .doit(); /// # } /// ``` @@ -2538,12 +2566,17 @@ impl<'a, C, A> AchievementConfigurationPatchCall<'a, C, A> where C: BorrowMut<hy if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2552,7 +2585,7 @@ impl<'a, C, A> AchievementConfigurationPatchCall<'a, C, A> where C: BorrowMut<hy Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2570,8 +2603,8 @@ impl<'a, C, A> AchievementConfigurationPatchCall<'a, C, A> where C: BorrowMut<hy /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AchievementConfiguration) -> AchievementConfigurationPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AchievementConfiguration) -> AchievementConfigurationPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the achievement used by this method. @@ -2780,12 +2813,17 @@ impl<'a, C, A> AchievementConfigurationDeleteCall<'a, C, A> where C: BorrowMut<h if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -2891,7 +2929,7 @@ impl<'a, C, A> AchievementConfigurationDeleteCall<'a, C, A> where C: BorrowMut<h /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.leaderboard_configurations().insert(&req, "applicationId") +/// let result = hub.leaderboard_configurations().insert(req, "applicationId") /// .doit(); /// # } /// ``` @@ -3019,12 +3057,17 @@ impl<'a, C, A> LeaderboardConfigurationInsertCall<'a, C, A> where C: BorrowMut<h if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3033,7 +3076,7 @@ impl<'a, C, A> LeaderboardConfigurationInsertCall<'a, C, A> where C: BorrowMut<h Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3051,8 +3094,8 @@ impl<'a, C, A> LeaderboardConfigurationInsertCall<'a, C, A> where C: BorrowMut<h /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &LeaderboardConfiguration) -> LeaderboardConfigurationInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: LeaderboardConfiguration) -> LeaderboardConfigurationInsertCall<'a, C, A> { + self._request = new_value; self } /// The application ID from the Google Play developer console. @@ -3262,12 +3305,17 @@ impl<'a, C, A> LeaderboardConfigurationGetCall<'a, C, A> where C: BorrowMut<hype if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3276,7 +3324,7 @@ impl<'a, C, A> LeaderboardConfigurationGetCall<'a, C, A> where C: BorrowMut<hype Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3383,7 +3431,7 @@ impl<'a, C, A> LeaderboardConfigurationGetCall<'a, C, A> where C: BorrowMut<hype /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.leaderboard_configurations().patch(&req, "leaderboardId") +/// let result = hub.leaderboard_configurations().patch(req, "leaderboardId") /// .doit(); /// # } /// ``` @@ -3511,12 +3559,17 @@ impl<'a, C, A> LeaderboardConfigurationPatchCall<'a, C, A> where C: BorrowMut<hy if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3525,7 +3578,7 @@ impl<'a, C, A> LeaderboardConfigurationPatchCall<'a, C, A> where C: BorrowMut<hy Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3543,8 +3596,8 @@ impl<'a, C, A> LeaderboardConfigurationPatchCall<'a, C, A> where C: BorrowMut<hy /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &LeaderboardConfiguration) -> LeaderboardConfigurationPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: LeaderboardConfiguration) -> LeaderboardConfigurationPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the leaderboard. @@ -3641,7 +3694,7 @@ impl<'a, C, A> LeaderboardConfigurationPatchCall<'a, C, A> where C: BorrowMut<hy /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.leaderboard_configurations().update(&req, "leaderboardId") +/// let result = hub.leaderboard_configurations().update(req, "leaderboardId") /// .doit(); /// # } /// ``` @@ -3769,12 +3822,17 @@ impl<'a, C, A> LeaderboardConfigurationUpdateCall<'a, C, A> where C: BorrowMut<h if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3783,7 +3841,7 @@ impl<'a, C, A> LeaderboardConfigurationUpdateCall<'a, C, A> where C: BorrowMut<h Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3801,8 +3859,8 @@ impl<'a, C, A> LeaderboardConfigurationUpdateCall<'a, C, A> where C: BorrowMut<h /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &LeaderboardConfiguration) -> LeaderboardConfigurationUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: LeaderboardConfiguration) -> LeaderboardConfigurationUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the leaderboard. @@ -4022,12 +4080,17 @@ impl<'a, C, A> LeaderboardConfigurationListCall<'a, C, A> where C: BorrowMut<hyp if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4036,7 +4099,7 @@ impl<'a, C, A> LeaderboardConfigurationListCall<'a, C, A> where C: BorrowMut<hyp Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4269,12 +4332,17 @@ impl<'a, C, A> LeaderboardConfigurationDeleteCall<'a, C, A> where C: BorrowMut<h if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; diff --git a/gen/gamesmanagement1_management-cli/Cargo.toml b/gen/gamesmanagement1_management-cli/Cargo.toml index 2d86314870..3fd2facf84 100644 --- a/gen/gamesmanagement1_management-cli/Cargo.toml +++ b/gen/gamesmanagement1_management-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-gamesmanagement1_management-cli" -version = "0.0.1+20150413" +version = "0.1.0+20150413" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with Games Management (protocol v1management)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/gamesmanagement1_management-cli" diff --git a/gen/gamesmanagement1_management-cli/README.md b/gen/gamesmanagement1_management-cli/README.md index 264ad8be94..6630c38858 100644 --- a/gen/gamesmanagement1_management-cli/README.md +++ b/gen/gamesmanagement1_management-cli/README.md @@ -1,4 +1,128 @@ -# HELLO GAMESMANAGEMENT:V1MANAGEMENT +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `gamesmanagement1-management` command-line interface *(CLI)* allows to use most features of the *Google Games Management* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *Games Management* API at revision *20150413*. The CLI is at version *0.1.0*. + +```bash + gamesmanagement1-management [options] achievements reset <achievement-id> [-p <v>...] [-o <out>] + gamesmanagement1-management [options] achievements reset-all [-p <v>...] [-o <out>] + gamesmanagement1-management [options] achievements reset-all-for-all-players [-p <v>...] + gamesmanagement1-management [options] achievements reset-for-all-players <achievement-id> [-p <v>...] + gamesmanagement1-management [options] achievements reset-multiple-for-all-players -r <kv>... [-p <v>...] + gamesmanagement1-management [options] applications list-hidden <application-id> [-p <v>...] [-o <out>] + gamesmanagement1-management [options] events reset <event-id> [-p <v>...] + gamesmanagement1-management [options] events reset-all [-p <v>...] + gamesmanagement1-management [options] events reset-all-for-all-players [-p <v>...] + gamesmanagement1-management [options] events reset-for-all-players <event-id> [-p <v>...] + gamesmanagement1-management [options] events reset-multiple-for-all-players -r <kv>... [-p <v>...] + gamesmanagement1-management [options] players hide <application-id> <player-id> [-p <v>...] + gamesmanagement1-management [options] players unhide <application-id> <player-id> [-p <v>...] + gamesmanagement1-management [options] quests reset <quest-id> [-p <v>...] + gamesmanagement1-management [options] quests reset-all [-p <v>...] + gamesmanagement1-management [options] quests reset-all-for-all-players [-p <v>...] + gamesmanagement1-management [options] quests reset-for-all-players <quest-id> [-p <v>...] + gamesmanagement1-management [options] quests reset-multiple-for-all-players -r <kv>... [-p <v>...] + gamesmanagement1-management [options] rooms reset [-p <v>...] + gamesmanagement1-management [options] rooms reset-for-all-players [-p <v>...] + gamesmanagement1-management [options] scores reset <leaderboard-id> [-p <v>...] [-o <out>] + gamesmanagement1-management [options] scores reset-all [-p <v>...] [-o <out>] + gamesmanagement1-management [options] scores reset-all-for-all-players [-p <v>...] + gamesmanagement1-management [options] scores reset-for-all-players <leaderboard-id> [-p <v>...] + gamesmanagement1-management [options] scores reset-multiple-for-all-players -r <kv>... [-p <v>...] + gamesmanagement1-management [options] turn-based-matches reset [-p <v>...] + gamesmanagement1-management [options] turn-based-matches reset-for-all-players [-p <v>...] + gamesmanagement1-management --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_gamesmanagement1_management_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `gamesmanagement1-management-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/gamesmanagement1-management-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/gamesmanagement1-management-secret.json`, assuming that the required *gamesManagement* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `gamesmanagement1-management --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/gamesmanagement1_management-cli/mkdocs.yml b/gen/gamesmanagement1_management-cli/mkdocs.yml index ea7fc7dde3..e88a6879ef 100644 --- a/gen/gamesmanagement1_management-cli/mkdocs.yml +++ b/gen/gamesmanagement1_management-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Games Management v0.0.1+20150413 +site_name: Games Management v0.1.0+20150413 site_url: http://byron.github.io/google-apis-rs/google-gamesmanagement1_management-cli site_description: Write integrating applications with bcore diff --git a/gen/gamesmanagement1_management-cli/src/cmn.rs b/gen/gamesmanagement1_management-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/gamesmanagement1_management-cli/src/cmn.rs +++ b/gen/gamesmanagement1_management-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/gamesmanagement1_management-cli/src/main.rs b/gen/gamesmanagement1_management-cli/src/main.rs index f59c4cd86b..4d5aa82208 100644 --- a/gen/gamesmanagement1_management-cli/src/main.rs +++ b/gen/gamesmanagement1_management-cli/src/main.rs @@ -19,52 +19,53 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - gamesmanagement1-management [options] achievements reset <achievement-id> [-p <v>]... [-o <out>] - gamesmanagement1-management [options] achievements reset-all [-p <v>]... [-o <out>] - gamesmanagement1-management [options] achievements reset-all-for-all-players [-p <v>]... - gamesmanagement1-management [options] achievements reset-for-all-players <achievement-id> [-p <v>]... - gamesmanagement1-management [options] achievements reset-multiple-for-all-players -r <kv>... [-p <v>]... - gamesmanagement1-management [options] applications list-hidden <application-id> [-p <v>]... [-o <out>] - gamesmanagement1-management [options] events reset <event-id> [-p <v>]... - gamesmanagement1-management [options] events reset-all [-p <v>]... - gamesmanagement1-management [options] events reset-all-for-all-players [-p <v>]... - gamesmanagement1-management [options] events reset-for-all-players <event-id> [-p <v>]... - gamesmanagement1-management [options] events reset-multiple-for-all-players -r <kv>... [-p <v>]... - gamesmanagement1-management [options] players hide <application-id> <player-id> [-p <v>]... - gamesmanagement1-management [options] players unhide <application-id> <player-id> [-p <v>]... - gamesmanagement1-management [options] quests reset <quest-id> [-p <v>]... - gamesmanagement1-management [options] quests reset-all [-p <v>]... - gamesmanagement1-management [options] quests reset-all-for-all-players [-p <v>]... - gamesmanagement1-management [options] quests reset-for-all-players <quest-id> [-p <v>]... - gamesmanagement1-management [options] quests reset-multiple-for-all-players -r <kv>... [-p <v>]... - gamesmanagement1-management [options] rooms reset [-p <v>]... - gamesmanagement1-management [options] rooms reset-for-all-players [-p <v>]... - gamesmanagement1-management [options] scores reset <leaderboard-id> [-p <v>]... [-o <out>] - gamesmanagement1-management [options] scores reset-all [-p <v>]... [-o <out>] - gamesmanagement1-management [options] scores reset-all-for-all-players [-p <v>]... - gamesmanagement1-management [options] scores reset-for-all-players <leaderboard-id> [-p <v>]... - gamesmanagement1-management [options] scores reset-multiple-for-all-players -r <kv>... [-p <v>]... - gamesmanagement1-management [options] turn-based-matches reset [-p <v>]... - gamesmanagement1-management [options] turn-based-matches reset-for-all-players [-p <v>]... + gamesmanagement1-management [options] achievements reset <achievement-id> [-p <v>...] [-o <out>] + gamesmanagement1-management [options] achievements reset-all [-p <v>...] [-o <out>] + gamesmanagement1-management [options] achievements reset-all-for-all-players [-p <v>...] + gamesmanagement1-management [options] achievements reset-for-all-players <achievement-id> [-p <v>...] + gamesmanagement1-management [options] achievements reset-multiple-for-all-players -r <kv>... [-p <v>...] + gamesmanagement1-management [options] applications list-hidden <application-id> [-p <v>...] [-o <out>] + gamesmanagement1-management [options] events reset <event-id> [-p <v>...] + gamesmanagement1-management [options] events reset-all [-p <v>...] + gamesmanagement1-management [options] events reset-all-for-all-players [-p <v>...] + gamesmanagement1-management [options] events reset-for-all-players <event-id> [-p <v>...] + gamesmanagement1-management [options] events reset-multiple-for-all-players -r <kv>... [-p <v>...] + gamesmanagement1-management [options] players hide <application-id> <player-id> [-p <v>...] + gamesmanagement1-management [options] players unhide <application-id> <player-id> [-p <v>...] + gamesmanagement1-management [options] quests reset <quest-id> [-p <v>...] + gamesmanagement1-management [options] quests reset-all [-p <v>...] + gamesmanagement1-management [options] quests reset-all-for-all-players [-p <v>...] + gamesmanagement1-management [options] quests reset-for-all-players <quest-id> [-p <v>...] + gamesmanagement1-management [options] quests reset-multiple-for-all-players -r <kv>... [-p <v>...] + gamesmanagement1-management [options] rooms reset [-p <v>...] + gamesmanagement1-management [options] rooms reset-for-all-players [-p <v>...] + gamesmanagement1-management [options] scores reset <leaderboard-id> [-p <v>...] [-o <out>] + gamesmanagement1-management [options] scores reset-all [-p <v>...] [-o <out>] + gamesmanagement1-management [options] scores reset-all-for-all-players [-p <v>...] + gamesmanagement1-management [options] scores reset-for-all-players <leaderboard-id> [-p <v>...] + gamesmanagement1-management [options] scores reset-multiple-for-all-players -r <kv>... [-p <v>...] + gamesmanagement1-management [options] turn-based-matches reset [-p <v>...] + gamesmanagement1-management [options] turn-based-matches reset-for-all-players [-p <v>...] gamesmanagement1-management --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_gamesmanagement1_management_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -113,6 +114,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -156,6 +160,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -199,6 +206,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -240,6 +250,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -254,8 +267,39 @@ impl Engine { fn _achievements_reset_multiple_for_all_players(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::AchievementResetMultipleForAllRequest::default(); - let mut call = self.hub.achievements().reset_multiple_for_all_players(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "achievement-ids" => { + if request.achievement_ids.is_none() { + request.achievement_ids = Some(Default::default()); + } + request.achievement_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.achievements().reset_multiple_for_all_players(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -277,33 +321,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "achievement-ids" => { - if request.achievement_ids.is_none() { - request.achievement_ids = Some(Default::default()); - } - request.achievement_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -351,6 +376,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -394,6 +422,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -435,6 +466,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -476,6 +510,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -517,6 +554,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -531,8 +571,39 @@ impl Engine { fn _events_reset_multiple_for_all_players(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::EventsResetMultipleForAllRequest::default(); - let mut call = self.hub.events().reset_multiple_for_all_players(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "event-ids" => { + if request.event_ids.is_none() { + request.event_ids = Some(Default::default()); + } + request.event_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.events().reset_multiple_for_all_players(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -554,33 +625,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "event-ids" => { - if request.event_ids.is_none() { - request.event_ids = Some(Default::default()); - } - request.event_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -622,6 +674,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -663,6 +718,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -704,6 +762,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -745,6 +806,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -786,6 +850,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -827,6 +894,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -841,8 +911,39 @@ impl Engine { fn _quests_reset_multiple_for_all_players(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::QuestsResetMultipleForAllRequest::default(); - let mut call = self.hub.quests().reset_multiple_for_all_players(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "quest-ids" => { + if request.quest_ids.is_none() { + request.quest_ids = Some(Default::default()); + } + request.quest_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.quests().reset_multiple_for_all_players(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -864,33 +965,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "quest-ids" => { - if request.quest_ids.is_none() { - request.quest_ids = Some(Default::default()); - } - request.quest_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -932,6 +1014,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -973,6 +1058,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1014,6 +1102,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1057,6 +1148,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1100,6 +1194,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1141,6 +1238,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1155,8 +1255,39 @@ impl Engine { fn _scores_reset_multiple_for_all_players(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::ScoresResetMultipleForAllRequest::default(); - let mut call = self.hub.scores().reset_multiple_for_all_players(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "leaderboard-ids" => { + if request.leaderboard_ids.is_none() { + request.leaderboard_ids = Some(Default::default()); + } + request.leaderboard_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.scores().reset_multiple_for_all_players(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1178,33 +1309,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "leaderboard-ids" => { - if request.leaderboard_ids.is_none() { - request.leaderboard_ids = Some(Default::default()); - } - request.leaderboard_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1246,6 +1358,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1287,6 +1402,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1465,6 +1583,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -1472,8 +1591,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/gamesmanagement1_management/Cargo.toml b/gen/gamesmanagement1_management/Cargo.toml index 3df26734e5..76eb65ff68 100644 --- a/gen/gamesmanagement1_management/Cargo.toml +++ b/gen/gamesmanagement1_management/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-gamesmanagement1_management" -version = "0.1.5+20150413" +version = "0.1.6+20150413" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with Games Management (protocol v1management)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/gamesmanagement1_management" diff --git a/gen/gamesmanagement1_management/README.md b/gen/gamesmanagement1_management/README.md index bc13cd6329..e6c540334c 100644 --- a/gen/gamesmanagement1_management/README.md +++ b/gen/gamesmanagement1_management/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-gamesmanagement1_management` library allows access to all features of the *Google Games Management* service. -This documentation was generated from *Games Management* crate version *0.1.5+20150413*, where *20150413* is the exact revision of the *gamesManagement:v1management* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *Games Management* crate version *0.1.6+20150413*, where *20150413* is the exact revision of the *gamesManagement:v1management* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *Games Management* *v1_management* API can be found at the [official documentation site](https://developers.google.com/games/services). @@ -114,14 +114,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/gamesmanagement1_management/src/cmn.rs b/gen/gamesmanagement1_management/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/gamesmanagement1_management/src/cmn.rs +++ b/gen/gamesmanagement1_management/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/gamesmanagement1_management/src/lib.rs b/gen/gamesmanagement1_management/src/lib.rs index 5d3956538e..f62eaf779c 100644 --- a/gen/gamesmanagement1_management/src/lib.rs +++ b/gen/gamesmanagement1_management/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Games Management* crate version *0.1.5+20150413*, where *20150413* is the exact revision of the *gamesManagement:v1management* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *Games Management* crate version *0.1.6+20150413*, where *20150413* is the exact revision of the *gamesManagement:v1management* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *Games Management* *v1_management* API can be found at the //! [official documentation site](https://developers.google.com/games/services). @@ -115,14 +115,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -210,7 +211,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -288,14 +289,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -316,7 +318,7 @@ impl<'a, C, A> GamesManagement<C, A> GamesManagement { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -346,7 +348,7 @@ impl<'a, C, A> GamesManagement<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -791,10 +793,10 @@ impl<'a, C, A> AchievementMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn reset_multiple_for_all_players(&self, request: &AchievementResetMultipleForAllRequest) -> AchievementResetMultipleForAllPlayerCall<'a, C, A> { + pub fn reset_multiple_for_all_players(&self, request: AchievementResetMultipleForAllRequest) -> AchievementResetMultipleForAllPlayerCall<'a, C, A> { AchievementResetMultipleForAllPlayerCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -940,10 +942,10 @@ impl<'a, C, A> ScoreMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn reset_multiple_for_all_players(&self, request: &ScoresResetMultipleForAllRequest) -> ScoreResetMultipleForAllPlayerCall<'a, C, A> { + pub fn reset_multiple_for_all_players(&self, request: ScoresResetMultipleForAllRequest) -> ScoreResetMultipleForAllPlayerCall<'a, C, A> { ScoreResetMultipleForAllPlayerCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1258,10 +1260,10 @@ impl<'a, C, A> QuestMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn reset_multiple_for_all_players(&self, request: &QuestsResetMultipleForAllRequest) -> QuestResetMultipleForAllPlayerCall<'a, C, A> { + pub fn reset_multiple_for_all_players(&self, request: QuestsResetMultipleForAllRequest) -> QuestResetMultipleForAllPlayerCall<'a, C, A> { QuestResetMultipleForAllPlayerCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1403,10 +1405,10 @@ impl<'a, C, A> EventMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn reset_multiple_for_all_players(&self, request: &EventsResetMultipleForAllRequest) -> EventResetMultipleForAllPlayerCall<'a, C, A> { + pub fn reset_multiple_for_all_players(&self, request: EventsResetMultipleForAllRequest) -> EventResetMultipleForAllPlayerCall<'a, C, A> { EventResetMultipleForAllPlayerCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1557,12 +1559,17 @@ impl<'a, C, A> AchievementResetAllForAllPlayerCall<'a, C, A> where C: BorrowMut< if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -1770,12 +1777,17 @@ impl<'a, C, A> AchievementResetForAllPlayerCall<'a, C, A> where C: BorrowMut<hyp if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -1994,12 +2006,17 @@ impl<'a, C, A> AchievementResetCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2008,7 +2025,7 @@ impl<'a, C, A> AchievementResetCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2115,7 +2132,7 @@ impl<'a, C, A> AchievementResetCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.achievements().reset_multiple_for_all_players(&req) +/// let result = hub.achievements().reset_multiple_for_all_players(req) /// .doit(); /// # } /// ``` @@ -2216,12 +2233,17 @@ impl<'a, C, A> AchievementResetMultipleForAllPlayerCall<'a, C, A> where C: Borro if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -2238,8 +2260,8 @@ impl<'a, C, A> AchievementResetMultipleForAllPlayerCall<'a, C, A> where C: Borro /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AchievementResetMultipleForAllRequest) -> AchievementResetMultipleForAllPlayerCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AchievementResetMultipleForAllRequest) -> AchievementResetMultipleForAllPlayerCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -2413,12 +2435,17 @@ impl<'a, C, A> AchievementResetAllCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2427,7 +2454,7 @@ impl<'a, C, A> AchievementResetAllCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2638,12 +2665,17 @@ impl<'a, C, A> PlayerHideCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -2873,12 +2905,17 @@ impl<'a, C, A> PlayerUnhideCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -2994,7 +3031,7 @@ impl<'a, C, A> PlayerUnhideCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.scores().reset_multiple_for_all_players(&req) +/// let result = hub.scores().reset_multiple_for_all_players(req) /// .doit(); /// # } /// ``` @@ -3095,12 +3132,17 @@ impl<'a, C, A> ScoreResetMultipleForAllPlayerCall<'a, C, A> where C: BorrowMut<h if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -3117,8 +3159,8 @@ impl<'a, C, A> ScoreResetMultipleForAllPlayerCall<'a, C, A> where C: BorrowMut<h /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ScoresResetMultipleForAllRequest) -> ScoreResetMultipleForAllPlayerCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ScoresResetMultipleForAllRequest) -> ScoreResetMultipleForAllPlayerCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -3291,12 +3333,17 @@ impl<'a, C, A> ScoreResetAllForAllPlayerCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -3479,12 +3526,17 @@ impl<'a, C, A> ScoreResetAllCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3493,7 +3545,7 @@ impl<'a, C, A> ScoreResetAllCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3702,12 +3754,17 @@ impl<'a, C, A> ScoreResetForAllPlayerCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -3926,12 +3983,17 @@ impl<'a, C, A> ScoreResetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3940,7 +4002,7 @@ impl<'a, C, A> ScoreResetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4133,12 +4195,17 @@ impl<'a, C, A> TurnBasedMatcheResetCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -4320,12 +4387,17 @@ impl<'a, C, A> TurnBasedMatcheResetForAllPlayerCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -4544,12 +4616,17 @@ impl<'a, C, A> ApplicationListHiddenCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4558,7 +4635,7 @@ impl<'a, C, A> ApplicationListHiddenCall<'a, C, A> where C: BorrowMut<hyper::Cli Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4765,12 +4842,17 @@ impl<'a, C, A> RoomResetForAllPlayerCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -4952,12 +5034,17 @@ impl<'a, C, A> RoomResetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -5139,12 +5226,17 @@ impl<'a, C, A> QuestResetAllForAllPlayerCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -5240,7 +5332,7 @@ impl<'a, C, A> QuestResetAllForAllPlayerCall<'a, C, A> where C: BorrowMut<hyper: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.quests().reset_multiple_for_all_players(&req) +/// let result = hub.quests().reset_multiple_for_all_players(req) /// .doit(); /// # } /// ``` @@ -5341,12 +5433,17 @@ impl<'a, C, A> QuestResetMultipleForAllPlayerCall<'a, C, A> where C: BorrowMut<h if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -5363,8 +5460,8 @@ impl<'a, C, A> QuestResetMultipleForAllPlayerCall<'a, C, A> where C: BorrowMut<h /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &QuestsResetMultipleForAllRequest) -> QuestResetMultipleForAllPlayerCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: QuestsResetMultipleForAllRequest) -> QuestResetMultipleForAllPlayerCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -5537,12 +5634,17 @@ impl<'a, C, A> QuestResetAllCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -5750,12 +5852,17 @@ impl<'a, C, A> QuestResetForAllPlayerCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -5973,12 +6080,17 @@ impl<'a, C, A> QuestResetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -6170,12 +6282,17 @@ impl<'a, C, A> EventResetAllForAllPlayerCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -6383,12 +6500,17 @@ impl<'a, C, A> EventResetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -6580,12 +6702,17 @@ impl<'a, C, A> EventResetAllCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -6681,7 +6808,7 @@ impl<'a, C, A> EventResetAllCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.events().reset_multiple_for_all_players(&req) +/// let result = hub.events().reset_multiple_for_all_players(req) /// .doit(); /// # } /// ``` @@ -6782,12 +6909,17 @@ impl<'a, C, A> EventResetMultipleForAllPlayerCall<'a, C, A> where C: BorrowMut<h if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -6804,8 +6936,8 @@ impl<'a, C, A> EventResetMultipleForAllPlayerCall<'a, C, A> where C: BorrowMut<h /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &EventsResetMultipleForAllRequest) -> EventResetMultipleForAllPlayerCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: EventsResetMultipleForAllRequest) -> EventResetMultipleForAllPlayerCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -7004,12 +7136,17 @@ impl<'a, C, A> EventResetForAllPlayerCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; diff --git a/gen/gan1_beta1-cli/Cargo.toml b/gen/gan1_beta1-cli/Cargo.toml index d9df66150a..8bee2542ec 100644 --- a/gen/gan1_beta1-cli/Cargo.toml +++ b/gen/gan1_beta1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-gan1_beta1-cli" -version = "0.0.1+20130205" +version = "0.1.0+20130205" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with gan (protocol v1beta1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/gan1_beta1-cli" diff --git a/gen/gan1_beta1-cli/README.md b/gen/gan1_beta1-cli/README.md index b647b465b4..af8cb6143e 100644 --- a/gen/gan1_beta1-cli/README.md +++ b/gen/gan1_beta1-cli/README.md @@ -1,4 +1,107 @@ -# HELLO GAN:V1BETA1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `gan1-beta1` command-line interface *(CLI)* allows to use most features of the *Google gan* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *gan* API at revision *20130205*. The CLI is at version *0.1.0*. + +```bash + gan1-beta1 [options] advertisers get <role> <role-id> [-p <v>...] [-o <out>] + gan1-beta1 [options] advertisers list <role> <role-id> [-p <v>...] [-o <out>] + gan1-beta1 [options] cc-offers list <publisher> [-p <v>...] [-o <out>] + gan1-beta1 [options] events list <role> <role-id> [-p <v>...] [-o <out>] + gan1-beta1 [options] links get <role> <role-id> <link-id> [-p <v>...] [-o <out>] + gan1-beta1 [options] links insert <role> <role-id> -r <kv>... [-p <v>...] [-o <out>] + gan1-beta1 [options] links list <role> <role-id> [-p <v>...] [-o <out>] + gan1-beta1 [options] publishers get <role> <role-id> [-p <v>...] [-o <out>] + gan1-beta1 [options] publishers list <role> <role-id> [-p <v>...] [-o <out>] + gan1-beta1 [options] reports get <role> <role-id> <report-type> [-p <v>...] [-o <out>] + gan1-beta1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_gan1_beta1_cli/index.html + +Configuration: + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `gan1-beta1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/gan1-beta1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/gan1-beta1-secret.json`, assuming that the required *gan* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `gan1-beta1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/gan1_beta1-cli/mkdocs.yml b/gen/gan1_beta1-cli/mkdocs.yml index 9849d35f0f..b4b12fcef0 100644 --- a/gen/gan1_beta1-cli/mkdocs.yml +++ b/gen/gan1_beta1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: gan v0.0.1+20130205 +site_name: gan v0.1.0+20130205 site_url: http://byron.github.io/google-apis-rs/google-gan1_beta1-cli site_description: Write integrating applications with bcore diff --git a/gen/gan1_beta1-cli/src/cmn.rs b/gen/gan1_beta1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/gan1_beta1-cli/src/cmn.rs +++ b/gen/gan1_beta1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/gan1_beta1-cli/src/main.rs b/gen/gan1_beta1-cli/src/main.rs index 021b7aa783..003733ffa4 100644 --- a/gen/gan1_beta1-cli/src/main.rs +++ b/gen/gan1_beta1-cli/src/main.rs @@ -19,31 +19,32 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - gan1-beta1 [options] advertisers get <role> <role-id> [-p <v>]... [-o <out>] - gan1-beta1 [options] advertisers list <role> <role-id> [-p <v>]... [-o <out>] - gan1-beta1 [options] cc-offers list <publisher> [-p <v>]... [-o <out>] - gan1-beta1 [options] events list <role> <role-id> [-p <v>]... [-o <out>] - gan1-beta1 [options] links get <role> <role-id> <link-id> [-p <v>]... [-o <out>] - gan1-beta1 [options] links insert <role> <role-id> -r <kv>... [-p <v>]... [-o <out>] - gan1-beta1 [options] links list <role> <role-id> [-p <v>]... [-o <out>] - gan1-beta1 [options] publishers get <role> <role-id> [-p <v>]... [-o <out>] - gan1-beta1 [options] publishers list <role> <role-id> [-p <v>]... [-o <out>] - gan1-beta1 [options] reports get <role> <role-id> <report-type> [-p <v>]... [-o <out>] + gan1-beta1 [options] advertisers get <role> <role-id> [-p <v>...] [-o <out>] + gan1-beta1 [options] advertisers list <role> <role-id> [-p <v>...] [-o <out>] + gan1-beta1 [options] cc-offers list <publisher> [-p <v>...] [-o <out>] + gan1-beta1 [options] events list <role> <role-id> [-p <v>...] [-o <out>] + gan1-beta1 [options] links get <role> <role-id> <link-id> [-p <v>...] [-o <out>] + gan1-beta1 [options] links insert <role> <role-id> -r <kv>... [-p <v>...] [-o <out>] + gan1-beta1 [options] links list <role> <role-id> [-p <v>...] [-o <out>] + gan1-beta1 [options] publishers get <role> <role-id> [-p <v>...] [-o <out>] + gan1-beta1 [options] publishers list <role> <role-id> [-p <v>...] [-o <out>] + gan1-beta1 [options] reports get <role> <role-id> <report-type> [-p <v>...] [-o <out>] gan1-beta1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_gan1_beta1_cli/index.html Configuration: --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -358,36 +359,23 @@ impl Engine { fn _links_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Link::default(); - let mut call = self.hub.links().insert(&request, &self.opt.arg_role, &self.opt.arg_role_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Link::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_epc_ninety_day_average_init(request: &mut api::Link) { if request.epc_ninety_day_average.is_none() { request.epc_ninety_day_average = Some(Default::default()); @@ -434,7 +422,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "link-type" => { request.link_type = Some(value.unwrap_or("").to_string()); }, @@ -569,10 +557,32 @@ impl Engine { request.destination_url = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.links().insert(request, &self.opt.arg_role, &self.opt.arg_role_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None @@ -982,6 +992,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -989,8 +1000,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/gan1_beta1/Cargo.toml b/gen/gan1_beta1/Cargo.toml index c4f057ea67..34ca099c6e 100644 --- a/gen/gan1_beta1/Cargo.toml +++ b/gen/gan1_beta1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-gan1_beta1" -version = "0.1.5+20130205" +version = "0.1.6+20130205" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with gan (protocol v1beta1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/gan1_beta1" diff --git a/gen/gan1_beta1/README.md b/gen/gan1_beta1/README.md index 5ab99853ab..fc6bb8792c 100644 --- a/gen/gan1_beta1/README.md +++ b/gen/gan1_beta1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-gan1_beta1` library allows access to all features of the *Google gan* service. -This documentation was generated from *gan* crate version *0.1.5+20130205*, where *20130205* is the exact revision of the *gan:v1beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *gan* crate version *0.1.6+20130205*, where *20130205* is the exact revision of the *gan:v1beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *gan* *v1_beta1* API can be found at the [official documentation site](https://developers.google.com/affiliate-network/). @@ -124,14 +124,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/gan1_beta1/src/cmn.rs b/gen/gan1_beta1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/gan1_beta1/src/cmn.rs +++ b/gen/gan1_beta1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/gan1_beta1/src/lib.rs b/gen/gan1_beta1/src/lib.rs index 289e9cf9db..127b5dda82 100644 --- a/gen/gan1_beta1/src/lib.rs +++ b/gen/gan1_beta1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *gan* crate version *0.1.5+20130205*, where *20130205* is the exact revision of the *gan:v1beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *gan* crate version *0.1.6+20130205*, where *20130205* is the exact revision of the *gan:v1beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *gan* *v1_beta1* API can be found at the //! [official documentation site](https://developers.google.com/affiliate-network/). @@ -125,14 +125,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -220,7 +221,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -285,14 +286,15 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -313,7 +315,7 @@ impl<'a, C, A> Gan<C, A> Gan { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -337,7 +339,7 @@ impl<'a, C, A> Gan<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -1249,10 +1251,10 @@ impl<'a, C, A> LinkMethods<'a, C, A> { /// * `request` - No description provided. /// * `role` - The role of the requester. Valid values: 'advertisers' or 'publishers'. /// * `roleId` - The ID of the requesting advertiser or publisher. - pub fn insert(&self, request: &Link, role: &str, role_id: &str) -> LinkInsertCall<'a, C, A> { + pub fn insert(&self, request: Link, role: &str, role_id: &str) -> LinkInsertCall<'a, C, A> { LinkInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _role: role.to_string(), _role_id: role_id.to_string(), _delegate: Default::default(), @@ -1786,12 +1788,17 @@ impl<'a, C, A> PublisherListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1800,7 +1807,7 @@ impl<'a, C, A> PublisherListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2063,12 +2070,17 @@ impl<'a, C, A> PublisherGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2077,7 +2089,7 @@ impl<'a, C, A> PublisherGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2185,7 +2197,7 @@ impl<'a, C, A> PublisherGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.links().insert(&req, "role", "roleId") +/// let result = hub.links().insert(req, "role", "roleId") /// .doit(); /// # } /// ``` @@ -2308,12 +2320,17 @@ impl<'a, C, A> LinkInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2322,7 +2339,7 @@ impl<'a, C, A> LinkInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2340,8 +2357,8 @@ impl<'a, C, A> LinkInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Link) -> LinkInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Link) -> LinkInsertCall<'a, C, A> { + self._request = new_value; self } /// The role of the requester. Valid values: 'advertisers' or 'publishers'. @@ -2542,12 +2559,17 @@ impl<'a, C, A> LinkGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2556,7 +2578,7 @@ impl<'a, C, A> LinkGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2852,12 +2874,17 @@ impl<'a, C, A> LinkListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2866,7 +2893,7 @@ impl<'a, C, A> LinkListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3242,12 +3269,17 @@ impl<'a, C, A> ReportGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3256,7 +3288,7 @@ impl<'a, C, A> ReportGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3568,12 +3600,17 @@ impl<'a, C, A> CcOfferListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3582,7 +3619,7 @@ impl<'a, C, A> CcOfferListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3801,12 +3838,17 @@ impl<'a, C, A> AdvertiserGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3815,7 +3857,7 @@ impl<'a, C, A> AdvertiserGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4066,12 +4108,17 @@ impl<'a, C, A> AdvertiserListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4080,7 +4127,7 @@ impl<'a, C, A> AdvertiserListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4418,12 +4465,17 @@ impl<'a, C, A> EventListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4432,7 +4484,7 @@ impl<'a, C, A> EventListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/genomics1_beta2-cli/Cargo.toml b/gen/genomics1_beta2-cli/Cargo.toml index e9adc21004..a8f96eea04 100644 --- a/gen/genomics1_beta2-cli/Cargo.toml +++ b/gen/genomics1_beta2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-genomics1_beta2-cli" -version = "0.0.1+20150326" +version = "0.1.0+20150326" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with genomics (protocol v1beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/genomics1_beta2-cli" diff --git a/gen/genomics1_beta2-cli/README.md b/gen/genomics1_beta2-cli/README.md index 678804b0a2..94b1a1e389 100644 --- a/gen/genomics1_beta2-cli/README.md +++ b/gen/genomics1_beta2-cli/README.md @@ -1,4 +1,161 @@ -# HELLO GENOMICS:V1BETA2 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `genomics1-beta2` command-line interface *(CLI)* allows to use most features of the *Google genomics* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *genomics* API at revision *20150326*. The CLI is at version *0.1.0*. + +```bash + genomics1-beta2 [options] annotation-sets create -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] annotation-sets delete <annotation-set-id> [-p <v>...] + genomics1-beta2 [options] annotation-sets get <annotation-set-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] annotation-sets patch <annotation-set-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] annotation-sets search -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] annotation-sets update <annotation-set-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] annotations batch-create -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] annotations create -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] annotations delete <annotation-id> [-p <v>...] + genomics1-beta2 [options] annotations get <annotation-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] annotations patch <annotation-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] annotations search -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] annotations update <annotation-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] callsets create -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] callsets delete <call-set-id> [-p <v>...] + genomics1-beta2 [options] callsets get <call-set-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] callsets patch <call-set-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] callsets search -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] callsets update <call-set-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] datasets create -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] datasets delete <dataset-id> [-p <v>...] + genomics1-beta2 [options] datasets get <dataset-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] datasets list [-p <v>...] [-o <out>] + genomics1-beta2 [options] datasets patch <dataset-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] datasets undelete <dataset-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] datasets update <dataset-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] experimental jobs-create -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] jobs cancel <job-id> [-p <v>...] + genomics1-beta2 [options] jobs get <job-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] jobs search -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] readgroupsets align -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] readgroupsets call -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] readgroupsets coveragebuckets-list <read-group-set-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] readgroupsets delete <read-group-set-id> [-p <v>...] + genomics1-beta2 [options] readgroupsets export -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] readgroupsets get <read-group-set-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] readgroupsets import -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] readgroupsets patch <read-group-set-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] readgroupsets search -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] readgroupsets update <read-group-set-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] reads search -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] references bases-list <reference-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] references get <reference-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] references search -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] referencesets get <reference-set-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] referencesets search -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] streaming-readstore streamreads -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] variants create -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] variants delete <variant-id> [-p <v>...] + genomics1-beta2 [options] variants get <variant-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] variants search -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] variants update <variant-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] variantsets delete <variant-set-id> [-p <v>...] + genomics1-beta2 [options] variantsets export <variant-set-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] variantsets get <variant-set-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] variantsets import-variants <variant-set-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] variantsets merge-variants <variant-set-id> -r <kv>... [-p <v>...] + genomics1-beta2 [options] variantsets patch <variant-set-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] variantsets search -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] variantsets update <variant-set-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_genomics1_beta2_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `genomics1-beta2-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/genomics1-beta2-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/genomics1-beta2-secret.json`, assuming that the required *genomics* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `genomics1-beta2 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/genomics1_beta2-cli/mkdocs.yml b/gen/genomics1_beta2-cli/mkdocs.yml index 691911deef..45585ed65c 100644 --- a/gen/genomics1_beta2-cli/mkdocs.yml +++ b/gen/genomics1_beta2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: genomics v0.0.1+20150326 +site_name: genomics v0.1.0+20150326 site_url: http://byron.github.io/google-apis-rs/google-genomics1_beta2-cli site_description: Write integrating applications with bcore diff --git a/gen/genomics1_beta2-cli/src/cmn.rs b/gen/genomics1_beta2-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/genomics1_beta2-cli/src/cmn.rs +++ b/gen/genomics1_beta2-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/genomics1_beta2-cli/src/main.rs b/gen/genomics1_beta2-cli/src/main.rs index efdb35f1ff..db0cce2dc6 100644 --- a/gen/genomics1_beta2-cli/src/main.rs +++ b/gen/genomics1_beta2-cli/src/main.rs @@ -19,85 +19,86 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - genomics1-beta2 [options] annotation-sets create -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] annotation-sets delete <annotation-set-id> [-p <v>]... - genomics1-beta2 [options] annotation-sets get <annotation-set-id> [-p <v>]... [-o <out>] - genomics1-beta2 [options] annotation-sets patch <annotation-set-id> -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] annotation-sets search -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] annotation-sets update <annotation-set-id> -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] annotations batch-create -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] annotations create -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] annotations delete <annotation-id> [-p <v>]... - genomics1-beta2 [options] annotations get <annotation-id> [-p <v>]... [-o <out>] - genomics1-beta2 [options] annotations patch <annotation-id> -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] annotations search -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] annotations update <annotation-id> -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] callsets create -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] callsets delete <call-set-id> [-p <v>]... - genomics1-beta2 [options] callsets get <call-set-id> [-p <v>]... [-o <out>] - genomics1-beta2 [options] callsets patch <call-set-id> -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] callsets search -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] callsets update <call-set-id> -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] datasets create -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] datasets delete <dataset-id> [-p <v>]... - genomics1-beta2 [options] datasets get <dataset-id> [-p <v>]... [-o <out>] - genomics1-beta2 [options] datasets list [-p <v>]... [-o <out>] - genomics1-beta2 [options] datasets patch <dataset-id> -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] datasets undelete <dataset-id> [-p <v>]... [-o <out>] - genomics1-beta2 [options] datasets update <dataset-id> -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] experimental jobs-create -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] jobs cancel <job-id> [-p <v>]... - genomics1-beta2 [options] jobs get <job-id> [-p <v>]... [-o <out>] - genomics1-beta2 [options] jobs search -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] readgroupsets align -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] readgroupsets call -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] readgroupsets coveragebuckets-list <read-group-set-id> [-p <v>]... [-o <out>] - genomics1-beta2 [options] readgroupsets delete <read-group-set-id> [-p <v>]... - genomics1-beta2 [options] readgroupsets export -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] readgroupsets get <read-group-set-id> [-p <v>]... [-o <out>] - genomics1-beta2 [options] readgroupsets import -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] readgroupsets patch <read-group-set-id> -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] readgroupsets search -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] readgroupsets update <read-group-set-id> -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] reads search -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] references bases-list <reference-id> [-p <v>]... [-o <out>] - genomics1-beta2 [options] references get <reference-id> [-p <v>]... [-o <out>] - genomics1-beta2 [options] references search -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] referencesets get <reference-set-id> [-p <v>]... [-o <out>] - genomics1-beta2 [options] referencesets search -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] streaming-readstore streamreads -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] variants create -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] variants delete <variant-id> [-p <v>]... - genomics1-beta2 [options] variants get <variant-id> [-p <v>]... [-o <out>] - genomics1-beta2 [options] variants search -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] variants update <variant-id> -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] variantsets delete <variant-set-id> [-p <v>]... - genomics1-beta2 [options] variantsets export <variant-set-id> -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] variantsets get <variant-set-id> [-p <v>]... [-o <out>] - genomics1-beta2 [options] variantsets import-variants <variant-set-id> -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] variantsets merge-variants <variant-set-id> -r <kv>... [-p <v>]... - genomics1-beta2 [options] variantsets patch <variant-set-id> -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] variantsets search -r <kv>... [-p <v>]... [-o <out>] - genomics1-beta2 [options] variantsets update <variant-set-id> -r <kv>... [-p <v>]... [-o <out>] + genomics1-beta2 [options] annotation-sets create -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] annotation-sets delete <annotation-set-id> [-p <v>...] + genomics1-beta2 [options] annotation-sets get <annotation-set-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] annotation-sets patch <annotation-set-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] annotation-sets search -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] annotation-sets update <annotation-set-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] annotations batch-create -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] annotations create -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] annotations delete <annotation-id> [-p <v>...] + genomics1-beta2 [options] annotations get <annotation-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] annotations patch <annotation-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] annotations search -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] annotations update <annotation-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] callsets create -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] callsets delete <call-set-id> [-p <v>...] + genomics1-beta2 [options] callsets get <call-set-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] callsets patch <call-set-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] callsets search -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] callsets update <call-set-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] datasets create -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] datasets delete <dataset-id> [-p <v>...] + genomics1-beta2 [options] datasets get <dataset-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] datasets list [-p <v>...] [-o <out>] + genomics1-beta2 [options] datasets patch <dataset-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] datasets undelete <dataset-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] datasets update <dataset-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] experimental jobs-create -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] jobs cancel <job-id> [-p <v>...] + genomics1-beta2 [options] jobs get <job-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] jobs search -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] readgroupsets align -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] readgroupsets call -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] readgroupsets coveragebuckets-list <read-group-set-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] readgroupsets delete <read-group-set-id> [-p <v>...] + genomics1-beta2 [options] readgroupsets export -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] readgroupsets get <read-group-set-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] readgroupsets import -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] readgroupsets patch <read-group-set-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] readgroupsets search -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] readgroupsets update <read-group-set-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] reads search -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] references bases-list <reference-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] references get <reference-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] references search -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] referencesets get <reference-set-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] referencesets search -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] streaming-readstore streamreads -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] variants create -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] variants delete <variant-id> [-p <v>...] + genomics1-beta2 [options] variants get <variant-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] variants search -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] variants update <variant-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] variantsets delete <variant-set-id> [-p <v>...] + genomics1-beta2 [options] variantsets export <variant-set-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] variantsets get <variant-set-id> [-p <v>...] [-o <out>] + genomics1-beta2 [options] variantsets import-variants <variant-set-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] variantsets merge-variants <variant-set-id> -r <kv>... [-p <v>...] + genomics1-beta2 [options] variantsets patch <variant-set-id> -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] variantsets search -r <kv>... [-p <v>...] [-o <out>] + genomics1-beta2 [options] variantsets update <variant-set-id> -r <kv>... [-p <v>...] [-o <out>] genomics1-beta2 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_genomics1_beta2_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -119,8 +120,48 @@ struct Engine { impl Engine { fn _annotation_sets_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::AnnotationSet::default(); - let mut call = self.hub.annotation_sets().create(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + "source-uri" => { + request.source_uri = Some(value.unwrap_or("").to_string()); + }, + "type" => { + request.type_ = Some(value.unwrap_or("").to_string()); + }, + "reference-set-id" => { + request.reference_set_id = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "dataset-id" => { + request.dataset_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.annotation_sets().create(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -142,42 +183,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "source-uri" => { - request.source_uri = Some(value.unwrap_or("").to_string()); - }, - "type" => { - request.type_ = Some(value.unwrap_or("").to_string()); - }, - "reference-set-id" => { - request.reference_set_id = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "dataset-id" => { - request.dataset_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -221,6 +234,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -262,6 +278,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -278,37 +297,24 @@ impl Engine { fn _annotation_sets_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::AnnotationSet::default(); - let mut call = self.hub.annotation_sets().patch(&request, &self.opt.arg_annotation_set_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::AnnotationSet::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "name" => { request.name = Some(value.unwrap_or("").to_string()); }, @@ -328,33 +334,11 @@ impl Engine { request.dataset_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _annotation_sets_search(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::SearchAnnotationSetsRequest::default(); - let mut call = self.hub.annotation_sets().search(&request); + let mut call = self.hub.annotation_sets().patch(request, &self.opt.arg_annotation_set_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -376,14 +360,48 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _annotation_sets_search(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::SearchAnnotationSetsRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "name" => { request.name = Some(value.unwrap_or("").to_string()); }, @@ -409,33 +427,11 @@ impl Engine { request.types.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _annotation_sets_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::AnnotationSet::default(); - let mut call = self.hub.annotation_sets().update(&request, &self.opt.arg_annotation_set_id); + let mut call = self.hub.annotation_sets().search(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -457,14 +453,48 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _annotation_sets_update(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::AnnotationSet::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "name" => { request.name = Some(value.unwrap_or("").to_string()); }, @@ -484,15 +514,40 @@ impl Engine { request.dataset_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.annotation_sets().update(request, &self.opt.arg_annotation_set_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -509,8 +564,30 @@ impl Engine { fn _annotations_batch_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::BatchCreateAnnotationsRequest::default(); - let mut call = self.hub.annotations().batch_create(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.annotations().batch_create(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -532,24 +609,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -566,36 +633,23 @@ impl Engine { fn _annotations_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Annotation::default(); - let mut call = self.hub.annotations().create(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Annotation::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_position_init(request: &mut api::Annotation) { if request.position.is_none() { request.position = Some(Default::default()); @@ -621,7 +675,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "name" => { request.name = Some(value.unwrap_or("").to_string()); }, @@ -697,15 +751,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.annotations().create(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -749,6 +828,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -790,6 +872,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -806,36 +891,23 @@ impl Engine { fn _annotations_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Annotation::default(); - let mut call = self.hub.annotations().patch(&request, &self.opt.arg_annotation_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Annotation::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_position_init(request: &mut api::Annotation) { if request.position.is_none() { request.position = Some(Default::default()); @@ -861,7 +933,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "name" => { request.name = Some(value.unwrap_or("").to_string()); }, @@ -937,33 +1009,11 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _annotations_search(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::SearchAnnotationsRequest::default(); - let mut call = self.hub.annotations().search(&request); + let mut call = self.hub.annotations().patch(request, &self.opt.arg_annotation_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -985,20 +1035,54 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _annotations_search(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::SearchAnnotationsRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_range_init(request: &mut api::SearchAnnotationsRequest) { if request.range.is_none() { request.range = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "page-token" => { request.page_token = Some(value.unwrap_or("").to_string()); }, @@ -1030,33 +1114,11 @@ impl Engine { request.page_size = Some(arg_from_str(value.unwrap_or("-0"), err, "page-size", "integer")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _annotations_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::Annotation::default(); - let mut call = self.hub.annotations().update(&request, &self.opt.arg_annotation_id); + let mut call = self.hub.annotations().search(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1078,13 +1140,47 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _annotations_update(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::Annotation::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_position_init(request: &mut api::Annotation) { if request.position.is_none() { request.position = Some(Default::default()); @@ -1110,7 +1206,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "name" => { request.name = Some(value.unwrap_or("").to_string()); }, @@ -1186,33 +1282,11 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _callsets_create(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::CallSet::default(); - let mut call = self.hub.callsets().create(&request); + let mut call = self.hub.annotations().update(request, &self.opt.arg_annotation_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1234,14 +1308,48 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _callsets_create(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::CallSet::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "sample-id" => { request.sample_id = Some(value.unwrap_or("").to_string()); }, @@ -1261,15 +1369,40 @@ impl Engine { request.created = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.callsets().create(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1313,6 +1446,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1354,6 +1490,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1370,8 +1509,48 @@ impl Engine { fn _callsets_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::CallSet::default(); - let mut call = self.hub.callsets().patch(&request, &self.opt.arg_call_set_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "sample-id" => { + request.sample_id = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "variant-set-ids" => { + if request.variant_set_ids.is_none() { + request.variant_set_ids = Some(Default::default()); + } + request.variant_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + "created" => { + request.created = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.callsets().patch(request, &self.opt.arg_call_set_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1393,42 +1572,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "sample-id" => { - request.sample_id = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "variant-set-ids" => { - if request.variant_set_ids.is_none() { - request.variant_set_ids = Some(Default::default()); - } - request.variant_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "created" => { - request.created = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1445,37 +1596,24 @@ impl Engine { fn _callsets_search(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::SearchCallSetsRequest::default(); - let mut call = self.hub.callsets().search(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::SearchCallSetsRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "page-token" => { request.page_token = Some(value.unwrap_or("").to_string()); }, @@ -1492,33 +1630,11 @@ impl Engine { request.page_size = Some(arg_from_str(value.unwrap_or("-0"), err, "page-size", "integer")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _callsets_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::CallSet::default(); - let mut call = self.hub.callsets().update(&request, &self.opt.arg_call_set_id); + let mut call = self.hub.callsets().search(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1540,14 +1656,48 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _callsets_update(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::CallSet::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "sample-id" => { request.sample_id = Some(value.unwrap_or("").to_string()); }, @@ -1567,33 +1717,11 @@ impl Engine { request.created = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _datasets_create(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::Dataset::default(); - let mut call = self.hub.datasets().create(&request); + let mut call = self.hub.callsets().update(request, &self.opt.arg_call_set_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1615,14 +1743,48 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _datasets_create(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::Dataset::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "is-public" => { request.is_public = Some(arg_from_str(value.unwrap_or("false"), err, "is-public", "boolean")); }, @@ -1636,15 +1798,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.datasets().create(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1688,6 +1875,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1729,6 +1919,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1781,6 +1974,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1797,8 +1993,42 @@ impl Engine { fn _datasets_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Dataset::default(); - let mut call = self.hub.datasets().patch(&request, &self.opt.arg_dataset_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "is-public" => { + request.is_public = Some(arg_from_str(value.unwrap_or("false"), err, "is-public", "boolean")); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "project-number" => { + request.project_number = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.datasets().patch(request, &self.opt.arg_dataset_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1820,36 +2050,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "is-public" => { - request.is_public = Some(arg_from_str(value.unwrap_or("false"), err, "is-public", "boolean")); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "project-number" => { - request.project_number = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1893,6 +2101,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1909,8 +2120,42 @@ impl Engine { fn _datasets_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Dataset::default(); - let mut call = self.hub.datasets().update(&request, &self.opt.arg_dataset_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "is-public" => { + request.is_public = Some(arg_from_str(value.unwrap_or("false"), err, "is-public", "boolean")); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "project-number" => { + request.project_number = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.datasets().update(request, &self.opt.arg_dataset_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1932,36 +2177,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "is-public" => { - request.is_public = Some(arg_from_str(value.unwrap_or("false"), err, "is-public", "boolean")); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "project-number" => { - request.project_number = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1978,37 +2201,24 @@ impl Engine { fn _experimental_jobs_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::ExperimentalCreateJobRequest::default(); - let mut call = self.hub.experimental().jobs_create(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ExperimentalCreateJobRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "paired-source-uris" => { if request.paired_source_uris.is_none() { request.paired_source_uris = Some(Default::default()); @@ -2034,15 +2244,40 @@ impl Engine { request.project_number = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.experimental().jobs_create(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2086,6 +2321,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2127,6 +2365,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2143,37 +2384,24 @@ impl Engine { fn _jobs_search(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::SearchJobsRequest::default(); - let mut call = self.hub.jobs().search(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::SearchJobsRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "status" => { if request.status.is_none() { request.status = Some(Default::default()); @@ -2196,33 +2424,11 @@ impl Engine { request.project_number = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _readgroupsets_align(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::AlignReadGroupSetsRequest::default(); - let mut call = self.hub.readgroupsets().align(&request); + let mut call = self.hub.jobs().search(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2244,13 +2450,47 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _readgroupsets_align(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::AlignReadGroupSetsRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_interleaved_fastq_source_init(request: &mut api::AlignReadGroupSetsRequest) { if request.interleaved_fastq_source.is_none() { request.interleaved_fastq_source = Some(Default::default()); @@ -2277,7 +2517,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "interleaved-fastq-source.source-uris" => { request_interleaved_fastq_source_init(&mut request); if request.interleaved_fastq_source.as_mut().unwrap().source_uris.is_none() { @@ -2355,33 +2595,11 @@ impl Engine { request.dataset_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _readgroupsets_call(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::CallReadGroupSetsRequest::default(); - let mut call = self.hub.readgroupsets().call(&request); + let mut call = self.hub.readgroupsets().align(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2403,14 +2621,48 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _readgroupsets_call(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::CallReadGroupSetsRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "source-uris" => { if request.source_uris.is_none() { request.source_uris = Some(Default::default()); @@ -2424,15 +2676,40 @@ impl Engine { request.dataset_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.readgroupsets().call(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2494,6 +2771,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2537,6 +2817,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2551,8 +2834,48 @@ impl Engine { fn _readgroupsets_export(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::ExportReadGroupSetsRequest::default(); - let mut call = self.hub.readgroupsets().export(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "export-uri" => { + request.export_uri = Some(value.unwrap_or("").to_string()); + }, + "reference-names" => { + if request.reference_names.is_none() { + request.reference_names = Some(Default::default()); + } + request.reference_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "read-group-set-ids" => { + if request.read_group_set_ids.is_none() { + request.read_group_set_ids = Some(Default::default()); + } + request.read_group_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "project-number" => { + request.project_number = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.readgroupsets().export(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2574,42 +2897,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "export-uri" => { - request.export_uri = Some(value.unwrap_or("").to_string()); - }, - "reference-names" => { - if request.reference_names.is_none() { - request.reference_names = Some(Default::default()); - } - request.reference_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "read-group-set-ids" => { - if request.read_group_set_ids.is_none() { - request.read_group_set_ids = Some(Default::default()); - } - request.read_group_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "project-number" => { - request.project_number = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2653,6 +2948,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2669,37 +2967,24 @@ impl Engine { fn _readgroupsets_import(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::ImportReadGroupSetsRequest::default(); - let mut call = self.hub.readgroupsets().import(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ImportReadGroupSetsRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "reference-set-id" => { request.reference_set_id = Some(value.unwrap_or("").to_string()); }, @@ -2716,15 +3001,40 @@ impl Engine { request.dataset_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.readgroupsets().import(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2741,8 +3051,45 @@ impl Engine { fn _readgroupsets_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::ReadGroupSet::default(); - let mut call = self.hub.readgroupsets().patch(&request, &self.opt.arg_read_group_set_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "filename" => { + request.filename = Some(value.unwrap_or("").to_string()); + }, + "reference-set-id" => { + request.reference_set_id = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + "dataset-id" => { + request.dataset_id = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.readgroupsets().patch(request, &self.opt.arg_read_group_set_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2764,39 +3111,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "filename" => { - request.filename = Some(value.unwrap_or("").to_string()); - }, - "reference-set-id" => { - request.reference_set_id = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "dataset-id" => { - request.dataset_id = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2813,37 +3135,24 @@ impl Engine { fn _readgroupsets_search(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::SearchReadGroupSetsRequest::default(); - let mut call = self.hub.readgroupsets().search(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::SearchReadGroupSetsRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "page-token" => { request.page_token = Some(value.unwrap_or("").to_string()); }, @@ -2860,15 +3169,40 @@ impl Engine { request.page_size = Some(arg_from_str(value.unwrap_or("-0"), err, "page-size", "integer")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.readgroupsets().search(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2885,37 +3219,24 @@ impl Engine { fn _readgroupsets_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::ReadGroupSet::default(); - let mut call = self.hub.readgroupsets().update(&request, &self.opt.arg_read_group_set_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ReadGroupSet::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "filename" => { request.filename = Some(value.unwrap_or("").to_string()); }, @@ -2932,33 +3253,11 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _reads_search(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::SearchReadsRequest::default(); - let mut call = self.hub.reads().search(&request); + let mut call = self.hub.readgroupsets().update(request, &self.opt.arg_read_group_set_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2980,14 +3279,48 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _reads_search(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::SearchReadsRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "read-group-set-ids" => { if request.read_group_set_ids.is_none() { request.read_group_set_ids = Some(Default::default()); @@ -3016,15 +3349,40 @@ impl Engine { request.end = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.reads().search(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3080,6 +3438,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3123,6 +3484,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3139,37 +3503,24 @@ impl Engine { fn _references_search(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::SearchReferencesRequest::default(); - let mut call = self.hub.references().search(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::SearchReferencesRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "md5checksums" => { if request.md5checksums.is_none() { request.md5checksums = Some(Default::default()); @@ -3192,15 +3543,40 @@ impl Engine { request.page_size = Some(arg_from_str(value.unwrap_or("-0"), err, "page-size", "integer")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.references().search(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3244,6 +3620,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3260,37 +3639,24 @@ impl Engine { fn _referencesets_search(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::SearchReferenceSetsRequest::default(); - let mut call = self.hub.referencesets().search(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::SearchReferenceSetsRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "md5checksums" => { if request.md5checksums.is_none() { request.md5checksums = Some(Default::default()); @@ -3313,33 +3679,11 @@ impl Engine { request.page_token = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _streaming_readstore_streamreads(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::StreamReadsRequest::default(); - let mut call = self.hub.streaming_readstore().streamreads(&request); + let mut call = self.hub.referencesets().search(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -3361,14 +3705,48 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _streaming_readstore_streamreads(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::StreamReadsRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "read-group-set-ids" => { if request.read_group_set_ids.is_none() { request.read_group_set_ids = Some(Default::default()); @@ -3385,10 +3763,32 @@ impl Engine { request.reference_name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.streaming_readstore().streamreads(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None @@ -3410,37 +3810,24 @@ impl Engine { fn _variants_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Variant::default(); - let mut call = self.hub.variants().create(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Variant::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "variant-set-id" => { request.variant_set_id = Some(value.unwrap_or("").to_string()); }, @@ -3484,15 +3871,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.variants().create(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3536,6 +3948,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -3577,6 +3992,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3593,37 +4011,24 @@ impl Engine { fn _variants_search(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::SearchVariantsRequest::default(); - let mut call = self.hub.variants().search(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::SearchVariantsRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "end" => { request.end = Some(value.unwrap_or("").to_string()); }, @@ -3658,33 +4063,11 @@ impl Engine { request.variant_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _variants_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::Variant::default(); - let mut call = self.hub.variants().update(&request, &self.opt.arg_variant_id); + let mut call = self.hub.variants().search(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -3706,14 +4089,48 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _variants_update(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::Variant::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "variant-set-id" => { request.variant_set_id = Some(value.unwrap_or("").to_string()); }, @@ -3757,15 +4174,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.variants().update(request, &self.opt.arg_variant_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3809,6 +4251,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -3823,8 +4268,48 @@ impl Engine { fn _variantsets_export(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::ExportVariantSetRequest::default(); - let mut call = self.hub.variantsets().export(&request, &self.opt.arg_variant_set_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "bigquery-dataset" => { + request.bigquery_dataset = Some(value.unwrap_or("").to_string()); + }, + "format" => { + request.format = Some(value.unwrap_or("").to_string()); + }, + "call-set-ids" => { + if request.call_set_ids.is_none() { + request.call_set_ids = Some(Default::default()); + } + request.call_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "project-number" => { + request.project_number = Some(value.unwrap_or("").to_string()); + }, + "bigquery-table" => { + request.bigquery_table = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.variantsets().export(request, &self.opt.arg_variant_set_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -3846,42 +4331,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "bigquery-dataset" => { - request.bigquery_dataset = Some(value.unwrap_or("").to_string()); - }, - "format" => { - request.format = Some(value.unwrap_or("").to_string()); - }, - "call-set-ids" => { - if request.call_set_ids.is_none() { - request.call_set_ids = Some(Default::default()); - } - request.call_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "project-number" => { - request.project_number = Some(value.unwrap_or("").to_string()); - }, - "bigquery-table" => { - request.bigquery_table = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3925,6 +4382,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3941,8 +4401,39 @@ impl Engine { fn _variantsets_import_variants(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::ImportVariantsRequest::default(); - let mut call = self.hub.variantsets().import_variants(&request, &self.opt.arg_variant_set_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "source-uris" => { + if request.source_uris.is_none() { + request.source_uris = Some(Default::default()); + } + request.source_uris.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "format" => { + request.format = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.variantsets().import_variants(request, &self.opt.arg_variant_set_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -3964,33 +4455,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "source-uris" => { - if request.source_uris.is_none() { - request.source_uris = Some(Default::default()); - } - request.source_uris.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "format" => { - request.format = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4007,8 +4479,30 @@ impl Engine { fn _variantsets_merge_variants(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::MergeVariantsRequest::default(); - let mut call = self.hub.variantsets().merge_variants(&request, &self.opt.arg_variant_set_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.variantsets().merge_variants(request, &self.opt.arg_variant_set_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -4030,24 +4524,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -4062,8 +4546,36 @@ impl Engine { fn _variantsets_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::VariantSet::default(); - let mut call = self.hub.variantsets().patch(&request, &self.opt.arg_variant_set_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "dataset-id" => { + request.dataset_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.variantsets().patch(request, &self.opt.arg_variant_set_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -4085,30 +4597,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "dataset-id" => { - request.dataset_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4125,8 +4621,42 @@ impl Engine { fn _variantsets_search(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::SearchVariantSetsRequest::default(); - let mut call = self.hub.variantsets().search(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "page-token" => { + request.page_token = Some(value.unwrap_or("").to_string()); + }, + "dataset-ids" => { + if request.dataset_ids.is_none() { + request.dataset_ids = Some(Default::default()); + } + request.dataset_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "page-size" => { + request.page_size = Some(arg_from_str(value.unwrap_or("-0"), err, "page-size", "integer")); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.variantsets().search(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -4148,36 +4678,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "page-token" => { - request.page_token = Some(value.unwrap_or("").to_string()); - }, - "dataset-ids" => { - if request.dataset_ids.is_none() { - request.dataset_ids = Some(Default::default()); - } - request.dataset_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "page-size" => { - request.page_size = Some(arg_from_str(value.unwrap_or("-0"), err, "page-size", "integer")); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4194,8 +4702,36 @@ impl Engine { fn _variantsets_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::VariantSet::default(); - let mut call = self.hub.variantsets().update(&request, &self.opt.arg_variant_set_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "dataset-id" => { + request.dataset_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.variantsets().update(request, &self.opt.arg_variant_set_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -4217,30 +4753,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "dataset-id" => { - request.dataset_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4512,6 +5032,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -4519,8 +5040,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/genomics1_beta2/Cargo.toml b/gen/genomics1_beta2/Cargo.toml index 045c5762ed..3a9673c90d 100644 --- a/gen/genomics1_beta2/Cargo.toml +++ b/gen/genomics1_beta2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-genomics1_beta2" -version = "0.1.5+20150326" +version = "0.1.6+20150326" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with genomics (protocol v1beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/genomics1_beta2" diff --git a/gen/genomics1_beta2/README.md b/gen/genomics1_beta2/README.md index 767c26c480..981d6dff36 100644 --- a/gen/genomics1_beta2/README.md +++ b/gen/genomics1_beta2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-genomics1_beta2` library allows access to all features of the *Google genomics* service. -This documentation was generated from *genomics* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *genomics:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *genomics* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *genomics:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *genomics* *v1_beta2* API can be found at the [official documentation site](https://developers.google.com/genomics/v1beta2/reference). @@ -128,21 +128,22 @@ let mut req = Annotation::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.annotations().patch(&req, "annotationId") +let result = hub.annotations().patch(req, "annotationId") .doit(); match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/genomics1_beta2/src/cmn.rs b/gen/genomics1_beta2/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/genomics1_beta2/src/cmn.rs +++ b/gen/genomics1_beta2/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/genomics1_beta2/src/lib.rs b/gen/genomics1_beta2/src/lib.rs index a6dac77b3d..0d7975f794 100644 --- a/gen/genomics1_beta2/src/lib.rs +++ b/gen/genomics1_beta2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *genomics* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *genomics:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *genomics* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *genomics:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *genomics* *v1_beta2* API can be found at the //! [official documentation site](https://developers.google.com/genomics/v1beta2/reference). @@ -129,21 +129,22 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.annotations().patch(&req, "annotationId") +//! let result = hub.annotations().patch(req, "annotationId") //! .doit(); //! //! match result { //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -231,7 +232,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -316,21 +317,22 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.annotations().patch(&req, "annotationId") +/// let result = hub.annotations().patch(req, "annotationId") /// .doit(); /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -351,7 +353,7 @@ impl<'a, C, A> Genomics<C, A> Genomics { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -396,7 +398,7 @@ impl<'a, C, A> Genomics<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -2471,10 +2473,10 @@ impl<'a, C, A> DatasetMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `datasetId` - The ID of the dataset to be updated. - pub fn update(&self, request: &Dataset, dataset_id: &str) -> DatasetUpdateCall<'a, C, A> { + pub fn update(&self, request: Dataset, dataset_id: &str) -> DatasetUpdateCall<'a, C, A> { DatasetUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _dataset_id: dataset_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2489,10 +2491,10 @@ impl<'a, C, A> DatasetMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn create(&self, request: &Dataset) -> DatasetCreateCall<'a, C, A> { + pub fn create(&self, request: Dataset) -> DatasetCreateCall<'a, C, A> { DatasetCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2573,10 +2575,10 @@ impl<'a, C, A> DatasetMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `datasetId` - The ID of the dataset to be updated. - pub fn patch(&self, request: &Dataset, dataset_id: &str) -> DatasetPatchCall<'a, C, A> { + pub fn patch(&self, request: Dataset, dataset_id: &str) -> DatasetPatchCall<'a, C, A> { DatasetPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _dataset_id: dataset_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2666,10 +2668,10 @@ impl<'a, C, A> JobMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn search(&self, request: &SearchJobsRequest) -> JobSearchCall<'a, C, A> { + pub fn search(&self, request: SearchJobsRequest) -> JobSearchCall<'a, C, A> { JobSearchCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2726,10 +2728,10 @@ impl<'a, C, A> ReferencesetMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn search(&self, request: &SearchReferenceSetsRequest) -> ReferencesetSearchCall<'a, C, A> { + pub fn search(&self, request: SearchReferenceSetsRequest) -> ReferencesetSearchCall<'a, C, A> { ReferencesetSearchCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2822,10 +2824,10 @@ impl<'a, C, A> CallsetMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn search(&self, request: &SearchCallSetsRequest) -> CallsetSearchCall<'a, C, A> { + pub fn search(&self, request: SearchCallSetsRequest) -> CallsetSearchCall<'a, C, A> { CallsetSearchCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2840,10 +2842,10 @@ impl<'a, C, A> CallsetMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `callSetId` - The ID of the call set to be updated. - pub fn patch(&self, request: &CallSet, call_set_id: &str) -> CallsetPatchCall<'a, C, A> { + pub fn patch(&self, request: CallSet, call_set_id: &str) -> CallsetPatchCall<'a, C, A> { CallsetPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _call_set_id: call_set_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2858,10 +2860,10 @@ impl<'a, C, A> CallsetMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn create(&self, request: &CallSet) -> CallsetCreateCall<'a, C, A> { + pub fn create(&self, request: CallSet) -> CallsetCreateCall<'a, C, A> { CallsetCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2893,10 +2895,10 @@ impl<'a, C, A> CallsetMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `callSetId` - The ID of the call set to be updated. - pub fn update(&self, request: &CallSet, call_set_id: &str) -> CallsetUpdateCall<'a, C, A> { + pub fn update(&self, request: CallSet, call_set_id: &str) -> CallsetUpdateCall<'a, C, A> { CallsetUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _call_set_id: call_set_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2956,10 +2958,10 @@ impl<'a, C, A> StreamingReadstoreMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn streamreads(&self, request: &StreamReadsRequest) -> StreamingReadstoreStreamreadCall<'a, C, A> { + pub fn streamreads(&self, request: StreamReadsRequest) -> StreamingReadstoreStreamreadCall<'a, C, A> { StreamingReadstoreStreamreadCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _additional_params: Default::default(), } @@ -3019,10 +3021,10 @@ impl<'a, C, A> ReadMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn search(&self, request: &SearchReadsRequest) -> ReadSearchCall<'a, C, A> { + pub fn search(&self, request: SearchReadsRequest) -> ReadSearchCall<'a, C, A> { ReadSearchCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3079,10 +3081,10 @@ impl<'a, C, A> ReadgroupsetMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn export(&self, request: &ExportReadGroupSetsRequest) -> ReadgroupsetExportCall<'a, C, A> { + pub fn export(&self, request: ExportReadGroupSetsRequest) -> ReadgroupsetExportCall<'a, C, A> { ReadgroupsetExportCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3097,10 +3099,10 @@ impl<'a, C, A> ReadgroupsetMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `readGroupSetId` - The ID of the read group set to be updated. The caller must have WRITE permissions to the dataset associated with this read group set. - pub fn patch(&self, request: &ReadGroupSet, read_group_set_id: &str) -> ReadgroupsetPatchCall<'a, C, A> { + pub fn patch(&self, request: ReadGroupSet, read_group_set_id: &str) -> ReadgroupsetPatchCall<'a, C, A> { ReadgroupsetPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _read_group_set_id: read_group_set_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3115,10 +3117,10 @@ impl<'a, C, A> ReadgroupsetMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn call(&self, request: &CallReadGroupSetsRequest) -> ReadgroupsetCallCall<'a, C, A> { + pub fn call(&self, request: CallReadGroupSetsRequest) -> ReadgroupsetCallCall<'a, C, A> { ReadgroupsetCallCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3134,10 +3136,10 @@ impl<'a, C, A> ReadgroupsetMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn import(&self, request: &ImportReadGroupSetsRequest) -> ReadgroupsetImportCall<'a, C, A> { + pub fn import(&self, request: ImportReadGroupSetsRequest) -> ReadgroupsetImportCall<'a, C, A> { ReadgroupsetImportCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3151,10 +3153,10 @@ impl<'a, C, A> ReadgroupsetMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn align(&self, request: &AlignReadGroupSetsRequest) -> ReadgroupsetAlignCall<'a, C, A> { + pub fn align(&self, request: AlignReadGroupSetsRequest) -> ReadgroupsetAlignCall<'a, C, A> { ReadgroupsetAlignCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3186,10 +3188,10 @@ impl<'a, C, A> ReadgroupsetMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `readGroupSetId` - The ID of the read group set to be updated. The caller must have WRITE permissions to the dataset associated with this read group set. - pub fn update(&self, request: &ReadGroupSet, read_group_set_id: &str) -> ReadgroupsetUpdateCall<'a, C, A> { + pub fn update(&self, request: ReadGroupSet, read_group_set_id: &str) -> ReadgroupsetUpdateCall<'a, C, A> { ReadgroupsetUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _read_group_set_id: read_group_set_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3248,10 +3250,10 @@ impl<'a, C, A> ReadgroupsetMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn search(&self, request: &SearchReadGroupSetsRequest) -> ReadgroupsetSearchCall<'a, C, A> { + pub fn search(&self, request: SearchReadGroupSetsRequest) -> ReadgroupsetSearchCall<'a, C, A> { ReadgroupsetSearchCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3331,10 +3333,10 @@ impl<'a, C, A> ReferenceMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn search(&self, request: &SearchReferencesRequest) -> ReferenceSearchCall<'a, C, A> { + pub fn search(&self, request: SearchReferencesRequest) -> ReferenceSearchCall<'a, C, A> { ReferenceSearchCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3426,10 +3428,10 @@ impl<'a, C, A> AnnotationSetMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `annotationSetId` - The ID of the annotation set to be updated. - pub fn update(&self, request: &AnnotationSet, annotation_set_id: &str) -> AnnotationSetUpdateCall<'a, C, A> { + pub fn update(&self, request: AnnotationSet, annotation_set_id: &str) -> AnnotationSetUpdateCall<'a, C, A> { AnnotationSetUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _annotation_set_id: annotation_set_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3444,10 +3446,10 @@ impl<'a, C, A> AnnotationSetMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn create(&self, request: &AnnotationSet) -> AnnotationSetCreateCall<'a, C, A> { + pub fn create(&self, request: AnnotationSet) -> AnnotationSetCreateCall<'a, C, A> { AnnotationSetCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3461,10 +3463,10 @@ impl<'a, C, A> AnnotationSetMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn search(&self, request: &SearchAnnotationSetsRequest) -> AnnotationSetSearchCall<'a, C, A> { + pub fn search(&self, request: SearchAnnotationSetsRequest) -> AnnotationSetSearchCall<'a, C, A> { AnnotationSetSearchCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3479,10 +3481,10 @@ impl<'a, C, A> AnnotationSetMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `annotationSetId` - The ID of the annotation set to be updated. - pub fn patch(&self, request: &AnnotationSet, annotation_set_id: &str) -> AnnotationSetPatchCall<'a, C, A> { + pub fn patch(&self, request: AnnotationSet, annotation_set_id: &str) -> AnnotationSetPatchCall<'a, C, A> { AnnotationSetPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _annotation_set_id: annotation_set_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3557,10 +3559,10 @@ impl<'a, C, A> VariantMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn search(&self, request: &SearchVariantsRequest) -> VariantSearchCall<'a, C, A> { + pub fn search(&self, request: SearchVariantsRequest) -> VariantSearchCall<'a, C, A> { VariantSearchCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3608,10 +3610,10 @@ impl<'a, C, A> VariantMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn create(&self, request: &Variant) -> VariantCreateCall<'a, C, A> { + pub fn create(&self, request: Variant) -> VariantCreateCall<'a, C, A> { VariantCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3626,10 +3628,10 @@ impl<'a, C, A> VariantMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `variantId` - The ID of the variant to be updated. - pub fn update(&self, request: &Variant, variant_id: &str) -> VariantUpdateCall<'a, C, A> { + pub fn update(&self, request: Variant, variant_id: &str) -> VariantUpdateCall<'a, C, A> { VariantUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _variant_id: variant_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3686,10 +3688,10 @@ impl<'a, C, A> AnnotationMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `annotationId` - The ID of the annotation set to be updated. - pub fn update(&self, request: &Annotation, annotation_id: &str) -> AnnotationUpdateCall<'a, C, A> { + pub fn update(&self, request: Annotation, annotation_id: &str) -> AnnotationUpdateCall<'a, C, A> { AnnotationUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _annotation_id: annotation_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3721,10 +3723,10 @@ impl<'a, C, A> AnnotationMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn search(&self, request: &SearchAnnotationsRequest) -> AnnotationSearchCall<'a, C, A> { + pub fn search(&self, request: SearchAnnotationsRequest) -> AnnotationSearchCall<'a, C, A> { AnnotationSearchCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3756,10 +3758,10 @@ impl<'a, C, A> AnnotationMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `annotationId` - The ID of the annotation set to be updated. - pub fn patch(&self, request: &Annotation, annotation_id: &str) -> AnnotationPatchCall<'a, C, A> { + pub fn patch(&self, request: Annotation, annotation_id: &str) -> AnnotationPatchCall<'a, C, A> { AnnotationPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _annotation_id: annotation_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3774,10 +3776,10 @@ impl<'a, C, A> AnnotationMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn create(&self, request: &Annotation) -> AnnotationCreateCall<'a, C, A> { + pub fn create(&self, request: Annotation) -> AnnotationCreateCall<'a, C, A> { AnnotationCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3794,10 +3796,10 @@ impl<'a, C, A> AnnotationMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn batch_create(&self, request: &BatchCreateAnnotationsRequest) -> AnnotationBatchCreateCall<'a, C, A> { + pub fn batch_create(&self, request: BatchCreateAnnotationsRequest) -> AnnotationBatchCreateCall<'a, C, A> { AnnotationBatchCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3852,10 +3854,10 @@ impl<'a, C, A> ExperimentalMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn jobs_create(&self, request: &ExperimentalCreateJobRequest) -> ExperimentalJobCreateCall<'a, C, A> { + pub fn jobs_create(&self, request: ExperimentalCreateJobRequest) -> ExperimentalJobCreateCall<'a, C, A> { ExperimentalJobCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3911,10 +3913,10 @@ impl<'a, C, A> VariantsetMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `variantSetId` - The ID of the variant to be updated. - pub fn update(&self, request: &VariantSet, variant_set_id: &str) -> VariantsetUpdateCall<'a, C, A> { + pub fn update(&self, request: VariantSet, variant_set_id: &str) -> VariantsetUpdateCall<'a, C, A> { VariantsetUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _variant_set_id: variant_set_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3930,10 +3932,10 @@ impl<'a, C, A> VariantsetMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `variantSetId` - Required. The ID of the variant set that contains variant data which should be exported. The caller must have READ access to this variant set. - pub fn export(&self, request: &ExportVariantSetRequest, variant_set_id: &str) -> VariantsetExportCall<'a, C, A> { + pub fn export(&self, request: ExportVariantSetRequest, variant_set_id: &str) -> VariantsetExportCall<'a, C, A> { VariantsetExportCall { hub: self.hub, - _request: request.clone(), + _request: request, _variant_set_id: variant_set_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3949,10 +3951,10 @@ impl<'a, C, A> VariantsetMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `variantSetId` - The ID of the variant to be updated. - pub fn patch(&self, request: &VariantSet, variant_set_id: &str) -> VariantsetPatchCall<'a, C, A> { + pub fn patch(&self, request: VariantSet, variant_set_id: &str) -> VariantsetPatchCall<'a, C, A> { VariantsetPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _variant_set_id: variant_set_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3969,10 +3971,10 @@ impl<'a, C, A> VariantsetMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn search(&self, request: &SearchVariantSetsRequest) -> VariantsetSearchCall<'a, C, A> { + pub fn search(&self, request: SearchVariantSetsRequest) -> VariantsetSearchCall<'a, C, A> { VariantsetSearchCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -4006,10 +4008,10 @@ impl<'a, C, A> VariantsetMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `variantSetId` - The destination variant set. - pub fn merge_variants(&self, request: &MergeVariantsRequest, variant_set_id: &str) -> VariantsetMergeVariantCall<'a, C, A> { + pub fn merge_variants(&self, request: MergeVariantsRequest, variant_set_id: &str) -> VariantsetMergeVariantCall<'a, C, A> { VariantsetMergeVariantCall { hub: self.hub, - _request: request.clone(), + _request: request, _variant_set_id: variant_set_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -4044,10 +4046,10 @@ impl<'a, C, A> VariantsetMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `variantSetId` - Required. The variant set to which variant data should be imported. - pub fn import_variants(&self, request: &ImportVariantsRequest, variant_set_id: &str) -> VariantsetImportVariantCall<'a, C, A> { + pub fn import_variants(&self, request: ImportVariantsRequest, variant_set_id: &str) -> VariantsetImportVariantCall<'a, C, A> { VariantsetImportVariantCall { hub: self.hub, - _request: request.clone(), + _request: request, _variant_set_id: variant_set_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -4096,7 +4098,7 @@ impl<'a, C, A> VariantsetMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.datasets().update(&req, "datasetId") +/// let result = hub.datasets().update(req, "datasetId") /// .doit(); /// # } /// ``` @@ -4224,12 +4226,17 @@ impl<'a, C, A> DatasetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4238,7 +4245,7 @@ impl<'a, C, A> DatasetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4256,8 +4263,8 @@ impl<'a, C, A> DatasetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Dataset) -> DatasetUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Dataset) -> DatasetUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the dataset to be updated. @@ -4354,7 +4361,7 @@ impl<'a, C, A> DatasetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.datasets().create(&req) +/// let result = hub.datasets().create(req) /// .doit(); /// # } /// ``` @@ -4456,12 +4463,17 @@ impl<'a, C, A> DatasetCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4470,7 +4482,7 @@ impl<'a, C, A> DatasetCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4488,8 +4500,8 @@ impl<'a, C, A> DatasetCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Dataset) -> DatasetCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Dataset) -> DatasetCreateCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -4688,12 +4700,17 @@ impl<'a, C, A> DatasetDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -4912,12 +4929,17 @@ impl<'a, C, A> DatasetUndeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4926,7 +4948,7 @@ impl<'a, C, A> DatasetUndeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5146,12 +5168,17 @@ impl<'a, C, A> DatasetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5160,7 +5187,7 @@ impl<'a, C, A> DatasetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5369,12 +5396,17 @@ impl<'a, C, A> DatasetListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5383,7 +5415,7 @@ impl<'a, C, A> DatasetListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5501,7 +5533,7 @@ impl<'a, C, A> DatasetListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.datasets().patch(&req, "datasetId") +/// let result = hub.datasets().patch(req, "datasetId") /// .doit(); /// # } /// ``` @@ -5629,12 +5661,17 @@ impl<'a, C, A> DatasetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5643,7 +5680,7 @@ impl<'a, C, A> DatasetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5661,8 +5698,8 @@ impl<'a, C, A> DatasetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Dataset) -> DatasetPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Dataset) -> DatasetPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the dataset to be updated. @@ -5871,12 +5908,17 @@ impl<'a, C, A> JobCancelCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -6095,12 +6137,17 @@ impl<'a, C, A> JobGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6109,7 +6156,7 @@ impl<'a, C, A> JobGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6216,7 +6263,7 @@ impl<'a, C, A> JobGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.jobs().search(&req) +/// let result = hub.jobs().search(req) /// .doit(); /// # } /// ``` @@ -6318,12 +6365,17 @@ impl<'a, C, A> JobSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6332,7 +6384,7 @@ impl<'a, C, A> JobSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6350,8 +6402,8 @@ impl<'a, C, A> JobSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &SearchJobsRequest) -> JobSearchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: SearchJobsRequest) -> JobSearchCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -6440,7 +6492,7 @@ impl<'a, C, A> JobSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.referencesets().search(&req) +/// let result = hub.referencesets().search(req) /// .doit(); /// # } /// ``` @@ -6542,12 +6594,17 @@ impl<'a, C, A> ReferencesetSearchCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6556,7 +6613,7 @@ impl<'a, C, A> ReferencesetSearchCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6574,8 +6631,8 @@ impl<'a, C, A> ReferencesetSearchCall<'a, C, A> where C: BorrowMut<hyper::Client /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &SearchReferenceSetsRequest) -> ReferencesetSearchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: SearchReferenceSetsRequest) -> ReferencesetSearchCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -6777,12 +6834,17 @@ impl<'a, C, A> ReferencesetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6791,7 +6853,7 @@ impl<'a, C, A> ReferencesetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7010,12 +7072,17 @@ impl<'a, C, A> CallsetDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -7123,7 +7190,7 @@ impl<'a, C, A> CallsetDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.callsets().search(&req) +/// let result = hub.callsets().search(req) /// .doit(); /// # } /// ``` @@ -7225,12 +7292,17 @@ impl<'a, C, A> CallsetSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7239,7 +7311,7 @@ impl<'a, C, A> CallsetSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7257,8 +7329,8 @@ impl<'a, C, A> CallsetSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &SearchCallSetsRequest) -> CallsetSearchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: SearchCallSetsRequest) -> CallsetSearchCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -7345,7 +7417,7 @@ impl<'a, C, A> CallsetSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.callsets().patch(&req, "callSetId") +/// let result = hub.callsets().patch(req, "callSetId") /// .doit(); /// # } /// ``` @@ -7473,12 +7545,17 @@ impl<'a, C, A> CallsetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7487,7 +7564,7 @@ impl<'a, C, A> CallsetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7505,8 +7582,8 @@ impl<'a, C, A> CallsetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &CallSet) -> CallsetPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CallSet) -> CallsetPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the call set to be updated. @@ -7603,7 +7680,7 @@ impl<'a, C, A> CallsetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.callsets().create(&req) +/// let result = hub.callsets().create(req) /// .doit(); /// # } /// ``` @@ -7705,12 +7782,17 @@ impl<'a, C, A> CallsetCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7719,7 +7801,7 @@ impl<'a, C, A> CallsetCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7737,8 +7819,8 @@ impl<'a, C, A> CallsetCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &CallSet) -> CallsetCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CallSet) -> CallsetCreateCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -7938,12 +8020,17 @@ impl<'a, C, A> CallsetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7952,7 +8039,7 @@ impl<'a, C, A> CallsetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8059,7 +8146,7 @@ impl<'a, C, A> CallsetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.callsets().update(&req, "callSetId") +/// let result = hub.callsets().update(req, "callSetId") /// .doit(); /// # } /// ``` @@ -8187,12 +8274,17 @@ impl<'a, C, A> CallsetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8201,7 +8293,7 @@ impl<'a, C, A> CallsetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8219,8 +8311,8 @@ impl<'a, C, A> CallsetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &CallSet) -> CallsetUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CallSet) -> CallsetUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the call set to be updated. @@ -8321,7 +8413,7 @@ impl<'a, C, A> CallsetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.streaming_readstore().streamreads(&req) +/// let result = hub.streaming_readstore().streamreads(req) /// .doit(); /// # } /// ``` @@ -8416,12 +8508,17 @@ impl<'a, C, A> StreamingReadstoreStreamreadCall<'a, C, A> where C: BorrowMut<hyp if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8430,7 +8527,7 @@ impl<'a, C, A> StreamingReadstoreStreamreadCall<'a, C, A> where C: BorrowMut<hyp Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8448,8 +8545,8 @@ impl<'a, C, A> StreamingReadstoreStreamreadCall<'a, C, A> where C: BorrowMut<hyp /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &StreamReadsRequest) -> StreamingReadstoreStreamreadCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: StreamReadsRequest) -> StreamingReadstoreStreamreadCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -8526,7 +8623,7 @@ impl<'a, C, A> StreamingReadstoreStreamreadCall<'a, C, A> where C: BorrowMut<hyp /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.reads().search(&req) +/// let result = hub.reads().search(req) /// .doit(); /// # } /// ``` @@ -8628,12 +8725,17 @@ impl<'a, C, A> ReadSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8642,7 +8744,7 @@ impl<'a, C, A> ReadSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8660,8 +8762,8 @@ impl<'a, C, A> ReadSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &SearchReadsRequest) -> ReadSearchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: SearchReadsRequest) -> ReadSearchCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -8750,7 +8852,7 @@ impl<'a, C, A> ReadSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.readgroupsets().export(&req) +/// let result = hub.readgroupsets().export(req) /// .doit(); /// # } /// ``` @@ -8852,12 +8954,17 @@ impl<'a, C, A> ReadgroupsetExportCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8866,7 +8973,7 @@ impl<'a, C, A> ReadgroupsetExportCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8884,8 +8991,8 @@ impl<'a, C, A> ReadgroupsetExportCall<'a, C, A> where C: BorrowMut<hyper::Client /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ExportReadGroupSetsRequest) -> ReadgroupsetExportCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ExportReadGroupSetsRequest) -> ReadgroupsetExportCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -8972,7 +9079,7 @@ impl<'a, C, A> ReadgroupsetExportCall<'a, C, A> where C: BorrowMut<hyper::Client /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.readgroupsets().patch(&req, "readGroupSetId") +/// let result = hub.readgroupsets().patch(req, "readGroupSetId") /// .doit(); /// # } /// ``` @@ -9100,12 +9207,17 @@ impl<'a, C, A> ReadgroupsetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9114,7 +9226,7 @@ impl<'a, C, A> ReadgroupsetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9132,8 +9244,8 @@ impl<'a, C, A> ReadgroupsetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client> /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ReadGroupSet) -> ReadgroupsetPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ReadGroupSet) -> ReadgroupsetPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the read group set to be updated. The caller must have WRITE permissions to the dataset associated with this read group set. @@ -9230,7 +9342,7 @@ impl<'a, C, A> ReadgroupsetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.readgroupsets().call(&req) +/// let result = hub.readgroupsets().call(req) /// .doit(); /// # } /// ``` @@ -9332,12 +9444,17 @@ impl<'a, C, A> ReadgroupsetCallCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9346,7 +9463,7 @@ impl<'a, C, A> ReadgroupsetCallCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9364,8 +9481,8 @@ impl<'a, C, A> ReadgroupsetCallCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &CallReadGroupSetsRequest) -> ReadgroupsetCallCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CallReadGroupSetsRequest) -> ReadgroupsetCallCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -9454,7 +9571,7 @@ impl<'a, C, A> ReadgroupsetCallCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.readgroupsets().import(&req) +/// let result = hub.readgroupsets().import(req) /// .doit(); /// # } /// ``` @@ -9556,12 +9673,17 @@ impl<'a, C, A> ReadgroupsetImportCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9570,7 +9692,7 @@ impl<'a, C, A> ReadgroupsetImportCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9588,8 +9710,8 @@ impl<'a, C, A> ReadgroupsetImportCall<'a, C, A> where C: BorrowMut<hyper::Client /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ImportReadGroupSetsRequest) -> ReadgroupsetImportCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ImportReadGroupSetsRequest) -> ReadgroupsetImportCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -9676,7 +9798,7 @@ impl<'a, C, A> ReadgroupsetImportCall<'a, C, A> where C: BorrowMut<hyper::Client /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.readgroupsets().align(&req) +/// let result = hub.readgroupsets().align(req) /// .doit(); /// # } /// ``` @@ -9778,12 +9900,17 @@ impl<'a, C, A> ReadgroupsetAlignCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9792,7 +9919,7 @@ impl<'a, C, A> ReadgroupsetAlignCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9810,8 +9937,8 @@ impl<'a, C, A> ReadgroupsetAlignCall<'a, C, A> where C: BorrowMut<hyper::Client> /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AlignReadGroupSetsRequest) -> ReadgroupsetAlignCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AlignReadGroupSetsRequest) -> ReadgroupsetAlignCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -10011,12 +10138,17 @@ impl<'a, C, A> ReadgroupsetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10025,7 +10157,7 @@ impl<'a, C, A> ReadgroupsetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10132,7 +10264,7 @@ impl<'a, C, A> ReadgroupsetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.readgroupsets().update(&req, "readGroupSetId") +/// let result = hub.readgroupsets().update(req, "readGroupSetId") /// .doit(); /// # } /// ``` @@ -10260,12 +10392,17 @@ impl<'a, C, A> ReadgroupsetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10274,7 +10411,7 @@ impl<'a, C, A> ReadgroupsetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10292,8 +10429,8 @@ impl<'a, C, A> ReadgroupsetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ReadGroupSet) -> ReadgroupsetUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ReadGroupSet) -> ReadgroupsetUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the read group set to be updated. The caller must have WRITE permissions to the dataset associated with this read group set. @@ -10535,12 +10672,17 @@ impl<'a, C, A> ReadgroupsetCoveragebucketListCall<'a, C, A> where C: BorrowMut<h if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10549,7 +10691,7 @@ impl<'a, C, A> ReadgroupsetCoveragebucketListCall<'a, C, A> where C: BorrowMut<h Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10810,12 +10952,17 @@ impl<'a, C, A> ReadgroupsetDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -10923,7 +11070,7 @@ impl<'a, C, A> ReadgroupsetDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.readgroupsets().search(&req) +/// let result = hub.readgroupsets().search(req) /// .doit(); /// # } /// ``` @@ -11025,12 +11172,17 @@ impl<'a, C, A> ReadgroupsetSearchCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11039,7 +11191,7 @@ impl<'a, C, A> ReadgroupsetSearchCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11057,8 +11209,8 @@ impl<'a, C, A> ReadgroupsetSearchCall<'a, C, A> where C: BorrowMut<hyper::Client /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &SearchReadGroupSetsRequest) -> ReadgroupsetSearchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: SearchReadGroupSetsRequest) -> ReadgroupsetSearchCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -11280,12 +11432,17 @@ impl<'a, C, A> ReferenceBaseListCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11294,7 +11451,7 @@ impl<'a, C, A> ReferenceBaseListCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11431,7 +11588,7 @@ impl<'a, C, A> ReferenceBaseListCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.references().search(&req) +/// let result = hub.references().search(req) /// .doit(); /// # } /// ``` @@ -11533,12 +11690,17 @@ impl<'a, C, A> ReferenceSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11547,7 +11709,7 @@ impl<'a, C, A> ReferenceSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11565,8 +11727,8 @@ impl<'a, C, A> ReferenceSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &SearchReferencesRequest) -> ReferenceSearchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: SearchReferencesRequest) -> ReferenceSearchCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -11768,12 +11930,17 @@ impl<'a, C, A> ReferenceGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11782,7 +11949,7 @@ impl<'a, C, A> ReferenceGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12002,12 +12169,17 @@ impl<'a, C, A> AnnotationSetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12016,7 +12188,7 @@ impl<'a, C, A> AnnotationSetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12123,7 +12295,7 @@ impl<'a, C, A> AnnotationSetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.annotation_sets().update(&req, "annotationSetId") +/// let result = hub.annotation_sets().update(req, "annotationSetId") /// .doit(); /// # } /// ``` @@ -12251,12 +12423,17 @@ impl<'a, C, A> AnnotationSetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12265,7 +12442,7 @@ impl<'a, C, A> AnnotationSetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12283,8 +12460,8 @@ impl<'a, C, A> AnnotationSetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AnnotationSet) -> AnnotationSetUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AnnotationSet) -> AnnotationSetUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the annotation set to be updated. @@ -12381,7 +12558,7 @@ impl<'a, C, A> AnnotationSetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.annotation_sets().create(&req) +/// let result = hub.annotation_sets().create(req) /// .doit(); /// # } /// ``` @@ -12483,12 +12660,17 @@ impl<'a, C, A> AnnotationSetCreateCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12497,7 +12679,7 @@ impl<'a, C, A> AnnotationSetCreateCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12515,8 +12697,8 @@ impl<'a, C, A> AnnotationSetCreateCall<'a, C, A> where C: BorrowMut<hyper::Clien /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AnnotationSet) -> AnnotationSetCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AnnotationSet) -> AnnotationSetCreateCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -12603,7 +12785,7 @@ impl<'a, C, A> AnnotationSetCreateCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.annotation_sets().search(&req) +/// let result = hub.annotation_sets().search(req) /// .doit(); /// # } /// ``` @@ -12705,12 +12887,17 @@ impl<'a, C, A> AnnotationSetSearchCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12719,7 +12906,7 @@ impl<'a, C, A> AnnotationSetSearchCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12737,8 +12924,8 @@ impl<'a, C, A> AnnotationSetSearchCall<'a, C, A> where C: BorrowMut<hyper::Clien /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &SearchAnnotationSetsRequest) -> AnnotationSetSearchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: SearchAnnotationSetsRequest) -> AnnotationSetSearchCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -12825,7 +13012,7 @@ impl<'a, C, A> AnnotationSetSearchCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.annotation_sets().patch(&req, "annotationSetId") +/// let result = hub.annotation_sets().patch(req, "annotationSetId") /// .doit(); /// # } /// ``` @@ -12953,12 +13140,17 @@ impl<'a, C, A> AnnotationSetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12967,7 +13159,7 @@ impl<'a, C, A> AnnotationSetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12985,8 +13177,8 @@ impl<'a, C, A> AnnotationSetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AnnotationSet) -> AnnotationSetPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AnnotationSet) -> AnnotationSetPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the annotation set to be updated. @@ -13195,12 +13387,17 @@ impl<'a, C, A> AnnotationSetDeleteCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -13308,7 +13505,7 @@ impl<'a, C, A> AnnotationSetDeleteCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.variants().search(&req) +/// let result = hub.variants().search(req) /// .doit(); /// # } /// ``` @@ -13410,12 +13607,17 @@ impl<'a, C, A> VariantSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13424,7 +13626,7 @@ impl<'a, C, A> VariantSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13442,8 +13644,8 @@ impl<'a, C, A> VariantSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &SearchVariantsRequest) -> VariantSearchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: SearchVariantsRequest) -> VariantSearchCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -13642,12 +13844,17 @@ impl<'a, C, A> VariantDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -13866,12 +14073,17 @@ impl<'a, C, A> VariantGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13880,7 +14092,7 @@ impl<'a, C, A> VariantGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13987,7 +14199,7 @@ impl<'a, C, A> VariantGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.variants().create(&req) +/// let result = hub.variants().create(req) /// .doit(); /// # } /// ``` @@ -14089,12 +14301,17 @@ impl<'a, C, A> VariantCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14103,7 +14320,7 @@ impl<'a, C, A> VariantCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14121,8 +14338,8 @@ impl<'a, C, A> VariantCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Variant) -> VariantCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Variant) -> VariantCreateCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -14209,7 +14426,7 @@ impl<'a, C, A> VariantCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.variants().update(&req, "variantId") +/// let result = hub.variants().update(req, "variantId") /// .doit(); /// # } /// ``` @@ -14337,12 +14554,17 @@ impl<'a, C, A> VariantUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14351,7 +14573,7 @@ impl<'a, C, A> VariantUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14369,8 +14591,8 @@ impl<'a, C, A> VariantUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Variant) -> VariantUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Variant) -> VariantUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the variant to be updated. @@ -14467,7 +14689,7 @@ impl<'a, C, A> VariantUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.annotations().update(&req, "annotationId") +/// let result = hub.annotations().update(req, "annotationId") /// .doit(); /// # } /// ``` @@ -14595,12 +14817,17 @@ impl<'a, C, A> AnnotationUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14609,7 +14836,7 @@ impl<'a, C, A> AnnotationUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14627,8 +14854,8 @@ impl<'a, C, A> AnnotationUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Annotation) -> AnnotationUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Annotation) -> AnnotationUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the annotation set to be updated. @@ -14838,12 +15065,17 @@ impl<'a, C, A> AnnotationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14852,7 +15084,7 @@ impl<'a, C, A> AnnotationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14959,7 +15191,7 @@ impl<'a, C, A> AnnotationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.annotations().search(&req) +/// let result = hub.annotations().search(req) /// .doit(); /// # } /// ``` @@ -15061,12 +15293,17 @@ impl<'a, C, A> AnnotationSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15075,7 +15312,7 @@ impl<'a, C, A> AnnotationSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15093,8 +15330,8 @@ impl<'a, C, A> AnnotationSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &SearchAnnotationsRequest) -> AnnotationSearchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: SearchAnnotationsRequest) -> AnnotationSearchCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -15293,12 +15530,17 @@ impl<'a, C, A> AnnotationDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -15404,7 +15646,7 @@ impl<'a, C, A> AnnotationDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.annotations().patch(&req, "annotationId") +/// let result = hub.annotations().patch(req, "annotationId") /// .doit(); /// # } /// ``` @@ -15532,12 +15774,17 @@ impl<'a, C, A> AnnotationPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15546,7 +15793,7 @@ impl<'a, C, A> AnnotationPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15564,8 +15811,8 @@ impl<'a, C, A> AnnotationPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Annotation) -> AnnotationPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Annotation) -> AnnotationPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the annotation set to be updated. @@ -15662,7 +15909,7 @@ impl<'a, C, A> AnnotationPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.annotations().create(&req) +/// let result = hub.annotations().create(req) /// .doit(); /// # } /// ``` @@ -15764,12 +16011,17 @@ impl<'a, C, A> AnnotationCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15778,7 +16030,7 @@ impl<'a, C, A> AnnotationCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15796,8 +16048,8 @@ impl<'a, C, A> AnnotationCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Annotation) -> AnnotationCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Annotation) -> AnnotationCreateCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -15887,7 +16139,7 @@ impl<'a, C, A> AnnotationCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.annotations().batch_create(&req) +/// let result = hub.annotations().batch_create(req) /// .doit(); /// # } /// ``` @@ -15989,12 +16241,17 @@ impl<'a, C, A> AnnotationBatchCreateCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16003,7 +16260,7 @@ impl<'a, C, A> AnnotationBatchCreateCall<'a, C, A> where C: BorrowMut<hyper::Cli Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16021,8 +16278,8 @@ impl<'a, C, A> AnnotationBatchCreateCall<'a, C, A> where C: BorrowMut<hyper::Cli /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &BatchCreateAnnotationsRequest) -> AnnotationBatchCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: BatchCreateAnnotationsRequest) -> AnnotationBatchCreateCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -16109,7 +16366,7 @@ impl<'a, C, A> AnnotationBatchCreateCall<'a, C, A> where C: BorrowMut<hyper::Cli /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.experimental().jobs_create(&req) +/// let result = hub.experimental().jobs_create(req) /// .doit(); /// # } /// ``` @@ -16211,12 +16468,17 @@ impl<'a, C, A> ExperimentalJobCreateCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16225,7 +16487,7 @@ impl<'a, C, A> ExperimentalJobCreateCall<'a, C, A> where C: BorrowMut<hyper::Cli Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16243,8 +16505,8 @@ impl<'a, C, A> ExperimentalJobCreateCall<'a, C, A> where C: BorrowMut<hyper::Cli /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ExperimentalCreateJobRequest) -> ExperimentalJobCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ExperimentalCreateJobRequest) -> ExperimentalJobCreateCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -16331,7 +16593,7 @@ impl<'a, C, A> ExperimentalJobCreateCall<'a, C, A> where C: BorrowMut<hyper::Cli /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.variantsets().update(&req, "variantSetId") +/// let result = hub.variantsets().update(req, "variantSetId") /// .doit(); /// # } /// ``` @@ -16459,12 +16721,17 @@ impl<'a, C, A> VariantsetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16473,7 +16740,7 @@ impl<'a, C, A> VariantsetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16491,8 +16758,8 @@ impl<'a, C, A> VariantsetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &VariantSet) -> VariantsetUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: VariantSet) -> VariantsetUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the variant to be updated. @@ -16589,7 +16856,7 @@ impl<'a, C, A> VariantsetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.variantsets().export(&req, "variantSetId") +/// let result = hub.variantsets().export(req, "variantSetId") /// .doit(); /// # } /// ``` @@ -16717,12 +16984,17 @@ impl<'a, C, A> VariantsetExportCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16731,7 +17003,7 @@ impl<'a, C, A> VariantsetExportCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16749,8 +17021,8 @@ impl<'a, C, A> VariantsetExportCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ExportVariantSetRequest) -> VariantsetExportCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ExportVariantSetRequest) -> VariantsetExportCall<'a, C, A> { + self._request = new_value; self } /// Required. The ID of the variant set that contains variant data which should be exported. The caller must have READ access to this variant set. @@ -16847,7 +17119,7 @@ impl<'a, C, A> VariantsetExportCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.variantsets().patch(&req, "variantSetId") +/// let result = hub.variantsets().patch(req, "variantSetId") /// .doit(); /// # } /// ``` @@ -16975,12 +17247,17 @@ impl<'a, C, A> VariantsetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16989,7 +17266,7 @@ impl<'a, C, A> VariantsetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -17007,8 +17284,8 @@ impl<'a, C, A> VariantsetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &VariantSet) -> VariantsetPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: VariantSet) -> VariantsetPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the variant to be updated. @@ -17107,7 +17384,7 @@ impl<'a, C, A> VariantsetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.variantsets().search(&req) +/// let result = hub.variantsets().search(req) /// .doit(); /// # } /// ``` @@ -17209,12 +17486,17 @@ impl<'a, C, A> VariantsetSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -17223,7 +17505,7 @@ impl<'a, C, A> VariantsetSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -17241,8 +17523,8 @@ impl<'a, C, A> VariantsetSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &SearchVariantSetsRequest) -> VariantsetSearchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: SearchVariantSetsRequest) -> VariantsetSearchCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -17442,12 +17724,17 @@ impl<'a, C, A> VariantsetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -17456,7 +17743,7 @@ impl<'a, C, A> VariantsetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -17565,7 +17852,7 @@ impl<'a, C, A> VariantsetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.variantsets().merge_variants(&req, "variantSetId") +/// let result = hub.variantsets().merge_variants(req, "variantSetId") /// .doit(); /// # } /// ``` @@ -17692,12 +17979,17 @@ impl<'a, C, A> VariantsetMergeVariantCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -17714,8 +18006,8 @@ impl<'a, C, A> VariantsetMergeVariantCall<'a, C, A> where C: BorrowMut<hyper::Cl /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &MergeVariantsRequest) -> VariantsetMergeVariantCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: MergeVariantsRequest) -> VariantsetMergeVariantCall<'a, C, A> { + self._request = new_value; self } /// The destination variant set. @@ -17924,12 +18216,17 @@ impl<'a, C, A> VariantsetDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -18037,7 +18334,7 @@ impl<'a, C, A> VariantsetDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.variantsets().import_variants(&req, "variantSetId") +/// let result = hub.variantsets().import_variants(req, "variantSetId") /// .doit(); /// # } /// ``` @@ -18165,12 +18462,17 @@ impl<'a, C, A> VariantsetImportVariantCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -18179,7 +18481,7 @@ impl<'a, C, A> VariantsetImportVariantCall<'a, C, A> where C: BorrowMut<hyper::C Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -18197,8 +18499,8 @@ impl<'a, C, A> VariantsetImportVariantCall<'a, C, A> where C: BorrowMut<hyper::C /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ImportVariantsRequest) -> VariantsetImportVariantCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ImportVariantsRequest) -> VariantsetImportVariantCall<'a, C, A> { + self._request = new_value; self } /// Required. The variant set to which variant data should be imported. diff --git a/gen/gmail1-cli/Cargo.toml b/gen/gmail1-cli/Cargo.toml index dd6bd70e21..58b243c8a7 100644 --- a/gen/gmail1-cli/Cargo.toml +++ b/gen/gmail1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-gmail1-cli" -version = "0.0.1+20150303" +version = "0.1.0+20150303" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with gmail (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/gmail1-cli" diff --git a/gen/gmail1-cli/README.md b/gen/gmail1-cli/README.md index 40a1d34cc4..8af4cc54c7 100644 --- a/gen/gmail1-cli/README.md +++ b/gen/gmail1-cli/README.md @@ -1,4 +1,131 @@ -# HELLO GMAIL:V1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `gmail1` command-line interface *(CLI)* allows to use most features of the *Google gmail* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *gmail* API at revision *20150303*. The CLI is at version *0.1.0*. + +```bash + gmail1 [options] users drafts-create <user-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + gmail1 [options] users drafts-delete <user-id> <id> [-p <v>...] + gmail1 [options] users drafts-get <user-id> <id> [-p <v>...] [-o <out>] + gmail1 [options] users drafts-list <user-id> [-p <v>...] [-o <out>] + gmail1 [options] users drafts-send <user-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + gmail1 [options] users drafts-update <user-id> <id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + gmail1 [options] users get-profile <user-id> [-p <v>...] [-o <out>] + gmail1 [options] users history-list <user-id> [-p <v>...] [-o <out>] + gmail1 [options] users labels-create <user-id> -r <kv>... [-p <v>...] [-o <out>] + gmail1 [options] users labels-delete <user-id> <id> [-p <v>...] + gmail1 [options] users labels-get <user-id> <id> [-p <v>...] [-o <out>] + gmail1 [options] users labels-list <user-id> [-p <v>...] [-o <out>] + gmail1 [options] users labels-patch <user-id> <id> -r <kv>... [-p <v>...] [-o <out>] + gmail1 [options] users labels-update <user-id> <id> -r <kv>... [-p <v>...] [-o <out>] + gmail1 [options] users messages-attachments-get <user-id> <message-id> <id> [-p <v>...] [-o <out>] + gmail1 [options] users messages-delete <user-id> <id> [-p <v>...] + gmail1 [options] users messages-get <user-id> <id> [-p <v>...] [-o <out>] + gmail1 [options] users messages-import <user-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + gmail1 [options] users messages-insert <user-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + gmail1 [options] users messages-list <user-id> [-p <v>...] [-o <out>] + gmail1 [options] users messages-modify <user-id> <id> -r <kv>... [-p <v>...] [-o <out>] + gmail1 [options] users messages-send <user-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + gmail1 [options] users messages-trash <user-id> <id> [-p <v>...] [-o <out>] + gmail1 [options] users messages-untrash <user-id> <id> [-p <v>...] [-o <out>] + gmail1 [options] users threads-delete <user-id> <id> [-p <v>...] + gmail1 [options] users threads-get <user-id> <id> [-p <v>...] [-o <out>] + gmail1 [options] users threads-list <user-id> [-p <v>...] [-o <out>] + gmail1 [options] users threads-modify <user-id> <id> -r <kv>... [-p <v>...] [-o <out>] + gmail1 [options] users threads-trash <user-id> <id> [-p <v>...] [-o <out>] + gmail1 [options] users threads-untrash <user-id> <id> [-p <v>...] [-o <out>] + gmail1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_gmail1_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `gmail1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/gmail1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/gmail1-secret.json`, assuming that the required *gmail* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `gmail1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/gmail1-cli/mkdocs.yml b/gen/gmail1-cli/mkdocs.yml index 8802363c1c..920533c106 100644 --- a/gen/gmail1-cli/mkdocs.yml +++ b/gen/gmail1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: gmail v0.0.1+20150303 +site_name: gmail v0.1.0+20150303 site_url: http://byron.github.io/google-apis-rs/google-gmail1-cli site_description: Write integrating applications with bcore diff --git a/gen/gmail1-cli/src/cmn.rs b/gen/gmail1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/gmail1-cli/src/cmn.rs +++ b/gen/gmail1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/gmail1-cli/src/main.rs b/gen/gmail1-cli/src/main.rs index ae217387e7..2a9f6c576a 100644 --- a/gen/gmail1-cli/src/main.rs +++ b/gen/gmail1-cli/src/main.rs @@ -19,55 +19,56 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - gmail1 [options] users drafts-create <user-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] - gmail1 [options] users drafts-delete <user-id> <id> [-p <v>]... - gmail1 [options] users drafts-get <user-id> <id> [-p <v>]... [-o <out>] - gmail1 [options] users drafts-list <user-id> [-p <v>]... [-o <out>] - gmail1 [options] users drafts-send <user-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] - gmail1 [options] users drafts-update <user-id> <id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] - gmail1 [options] users get-profile <user-id> [-p <v>]... [-o <out>] - gmail1 [options] users history-list <user-id> [-p <v>]... [-o <out>] - gmail1 [options] users labels-create <user-id> -r <kv>... [-p <v>]... [-o <out>] - gmail1 [options] users labels-delete <user-id> <id> [-p <v>]... - gmail1 [options] users labels-get <user-id> <id> [-p <v>]... [-o <out>] - gmail1 [options] users labels-list <user-id> [-p <v>]... [-o <out>] - gmail1 [options] users labels-patch <user-id> <id> -r <kv>... [-p <v>]... [-o <out>] - gmail1 [options] users labels-update <user-id> <id> -r <kv>... [-p <v>]... [-o <out>] - gmail1 [options] users messages-attachments-get <user-id> <message-id> <id> [-p <v>]... [-o <out>] - gmail1 [options] users messages-delete <user-id> <id> [-p <v>]... - gmail1 [options] users messages-get <user-id> <id> [-p <v>]... [-o <out>] - gmail1 [options] users messages-import <user-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] - gmail1 [options] users messages-insert <user-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] - gmail1 [options] users messages-list <user-id> [-p <v>]... [-o <out>] - gmail1 [options] users messages-modify <user-id> <id> -r <kv>... [-p <v>]... [-o <out>] - gmail1 [options] users messages-send <user-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] - gmail1 [options] users messages-trash <user-id> <id> [-p <v>]... [-o <out>] - gmail1 [options] users messages-untrash <user-id> <id> [-p <v>]... [-o <out>] - gmail1 [options] users threads-delete <user-id> <id> [-p <v>]... - gmail1 [options] users threads-get <user-id> <id> [-p <v>]... [-o <out>] - gmail1 [options] users threads-list <user-id> [-p <v>]... [-o <out>] - gmail1 [options] users threads-modify <user-id> <id> -r <kv>... [-p <v>]... [-o <out>] - gmail1 [options] users threads-trash <user-id> <id> [-p <v>]... [-o <out>] - gmail1 [options] users threads-untrash <user-id> <id> [-p <v>]... [-o <out>] + gmail1 [options] users drafts-create <user-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + gmail1 [options] users drafts-delete <user-id> <id> [-p <v>...] + gmail1 [options] users drafts-get <user-id> <id> [-p <v>...] [-o <out>] + gmail1 [options] users drafts-list <user-id> [-p <v>...] [-o <out>] + gmail1 [options] users drafts-send <user-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + gmail1 [options] users drafts-update <user-id> <id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + gmail1 [options] users get-profile <user-id> [-p <v>...] [-o <out>] + gmail1 [options] users history-list <user-id> [-p <v>...] [-o <out>] + gmail1 [options] users labels-create <user-id> -r <kv>... [-p <v>...] [-o <out>] + gmail1 [options] users labels-delete <user-id> <id> [-p <v>...] + gmail1 [options] users labels-get <user-id> <id> [-p <v>...] [-o <out>] + gmail1 [options] users labels-list <user-id> [-p <v>...] [-o <out>] + gmail1 [options] users labels-patch <user-id> <id> -r <kv>... [-p <v>...] [-o <out>] + gmail1 [options] users labels-update <user-id> <id> -r <kv>... [-p <v>...] [-o <out>] + gmail1 [options] users messages-attachments-get <user-id> <message-id> <id> [-p <v>...] [-o <out>] + gmail1 [options] users messages-delete <user-id> <id> [-p <v>...] + gmail1 [options] users messages-get <user-id> <id> [-p <v>...] [-o <out>] + gmail1 [options] users messages-import <user-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + gmail1 [options] users messages-insert <user-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + gmail1 [options] users messages-list <user-id> [-p <v>...] [-o <out>] + gmail1 [options] users messages-modify <user-id> <id> -r <kv>... [-p <v>...] [-o <out>] + gmail1 [options] users messages-send <user-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + gmail1 [options] users messages-trash <user-id> <id> [-p <v>...] [-o <out>] + gmail1 [options] users messages-untrash <user-id> <id> [-p <v>...] [-o <out>] + gmail1 [options] users threads-delete <user-id> <id> [-p <v>...] + gmail1 [options] users threads-get <user-id> <id> [-p <v>...] [-o <out>] + gmail1 [options] users threads-list <user-id> [-p <v>...] [-o <out>] + gmail1 [options] users threads-modify <user-id> <id> -r <kv>... [-p <v>...] [-o <out>] + gmail1 [options] users threads-trash <user-id> <id> [-p <v>...] [-o <out>] + gmail1 [options] users threads-untrash <user-id> <id> [-p <v>...] [-o <out>] gmail1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_gmail1_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -89,36 +90,23 @@ struct Engine { impl Engine { fn _users_drafts_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Draft::default(); - let mut call = self.hub.users().drafts_create(&request, &self.opt.arg_user_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Draft::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_message_init(request: &mut api::Draft) { if request.message.is_none() { request.message = Some(Default::default()); @@ -139,7 +127,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "message.history-id" => { request_message_init(&mut request); request.message.as_mut().unwrap().history_id = Some(value.unwrap_or("").to_string()); @@ -200,10 +188,32 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.users().drafts_create(request, &self.opt.arg_user_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = if self.opt.cmd_simple { "simple" @@ -218,6 +228,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -262,6 +275,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -306,6 +322,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -355,6 +374,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -371,36 +393,23 @@ impl Engine { fn _users_drafts_send(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Draft::default(); - let mut call = self.hub.users().drafts_send(&request, &self.opt.arg_user_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Draft::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_message_init(request: &mut api::Draft) { if request.message.is_none() { request.message = Some(Default::default()); @@ -421,7 +430,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "message.history-id" => { request_message_init(&mut request); request.message.as_mut().unwrap().history_id = Some(value.unwrap_or("").to_string()); @@ -482,10 +491,32 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.users().drafts_send(request, &self.opt.arg_user_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = if self.opt.cmd_simple { "simple" @@ -500,6 +531,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -517,36 +551,23 @@ impl Engine { fn _users_drafts_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Draft::default(); - let mut call = self.hub.users().drafts_update(&request, &self.opt.arg_user_id, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Draft::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_message_init(request: &mut api::Draft) { if request.message.is_none() { request.message = Some(Default::default()); @@ -567,7 +588,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "message.history-id" => { request_message_init(&mut request); request.message.as_mut().unwrap().history_id = Some(value.unwrap_or("").to_string()); @@ -628,10 +649,32 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.users().drafts_update(request, &self.opt.arg_user_id, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = if self.opt.cmd_simple { "simple" @@ -646,6 +689,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -690,6 +736,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -745,6 +794,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -761,37 +813,24 @@ impl Engine { fn _users_labels_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Label::default(); - let mut call = self.hub.users().labels_create(&request, &self.opt.arg_user_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Label::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "name" => { request.name = Some(value.unwrap_or("").to_string()); }, @@ -820,15 +859,40 @@ impl Engine { request.messages_unread = Some(arg_from_str(value.unwrap_or("-0"), err, "messages-unread", "integer")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.users().labels_create(request, &self.opt.arg_user_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -872,6 +936,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -913,6 +980,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -956,6 +1026,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -972,37 +1045,24 @@ impl Engine { fn _users_labels_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Label::default(); - let mut call = self.hub.users().labels_patch(&request, &self.opt.arg_user_id, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Label::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "name" => { request.name = Some(value.unwrap_or("").to_string()); }, @@ -1031,15 +1091,40 @@ impl Engine { request.messages_unread = Some(arg_from_str(value.unwrap_or("-0"), err, "messages-unread", "integer")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.users().labels_patch(request, &self.opt.arg_user_id, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1056,37 +1141,24 @@ impl Engine { fn _users_labels_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Label::default(); - let mut call = self.hub.users().labels_update(&request, &self.opt.arg_user_id, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Label::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "name" => { request.name = Some(value.unwrap_or("").to_string()); }, @@ -1115,15 +1187,40 @@ impl Engine { request.messages_unread = Some(arg_from_str(value.unwrap_or("-0"), err, "messages-unread", "integer")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.users().labels_update(request, &self.opt.arg_user_id, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1167,6 +1264,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1210,6 +1310,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1257,6 +1360,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1273,8 +1379,97 @@ impl Engine { fn _users_messages_import(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Message::default(); - let mut call = self.hub.users().messages_import(&request, &self.opt.arg_user_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + fn request_payload_body_init(request: &mut api::Message) { + request_payload_init(request); + if request.payload.as_mut().unwrap().body.is_none() { + request.payload.as_mut().unwrap().body = Some(Default::default()); + } + } + + fn request_payload_init(request: &mut api::Message) { + if request.payload.is_none() { + request.payload = Some(Default::default()); + } + } + + match &temp_cursor.to_string()[..] { + "history-id" => { + request.history_id = Some(value.unwrap_or("").to_string()); + }, + "payload.body.data" => { + request_payload_body_init(&mut request); + request.payload.as_mut().unwrap().body.as_mut().unwrap().data = Some(value.unwrap_or("").to_string()); + }, + "payload.body.attachment-id" => { + request_payload_body_init(&mut request); + request.payload.as_mut().unwrap().body.as_mut().unwrap().attachment_id = Some(value.unwrap_or("").to_string()); + }, + "payload.body.size" => { + request_payload_body_init(&mut request); + request.payload.as_mut().unwrap().body.as_mut().unwrap().size = Some(arg_from_str(value.unwrap_or("-0"), err, "payload.body.size", "integer")); + }, + "payload.mime-type" => { + request_payload_body_init(&mut request); + request.payload.as_mut().unwrap().mime_type = Some(value.unwrap_or("").to_string()); + }, + "payload.part-id" => { + request_payload_body_init(&mut request); + request.payload.as_mut().unwrap().part_id = Some(value.unwrap_or("").to_string()); + }, + "payload.filename" => { + request_payload_body_init(&mut request); + request.payload.as_mut().unwrap().filename = Some(value.unwrap_or("").to_string()); + }, + "snippet" => { + request_payload_init(&mut request); + request.snippet = Some(value.unwrap_or("").to_string()); + }, + "raw" => { + request_payload_init(&mut request); + request.raw = Some(value.unwrap_or("").to_string()); + }, + "size-estimate" => { + request_payload_init(&mut request); + request.size_estimate = Some(arg_from_str(value.unwrap_or("-0"), err, "size-estimate", "integer")); + }, + "thread-id" => { + request_payload_init(&mut request); + request.thread_id = Some(value.unwrap_or("").to_string()); + }, + "label-ids" => { + request_payload_init(&mut request); + if request.label_ids.is_none() { + request.label_ids = Some(Default::default()); + } + request.label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "id" => { + request_payload_init(&mut request); + request.id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.users().messages_import(request, &self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1308,13 +1503,57 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = + if self.opt.cmd_simple { + "simple" + } else if self.opt.cmd_resumable { + "resumable" + } else { + unreachable!() + }; + let mut input_file = input_file_from_opts(&self.opt.arg_file, err); + let mime_type = input_mime_from_opts(&self.opt.arg_mime, err); + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), + "resumable" => call.upload_resumable(input_file.unwrap(), mime_type.unwrap()), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _users_messages_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::Message::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_payload_body_init(request: &mut api::Message) { request_payload_init(request); if request.payload.as_mut().unwrap().body.is_none() { @@ -1328,7 +1567,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "history-id" => { request.history_id = Some(value.unwrap_or("").to_string()); }, @@ -1384,43 +1623,11 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = - if self.opt.cmd_simple { - "simple" - } else if self.opt.cmd_resumable { - "resumable" - } else { - unreachable!() - }; - let mut input_file = input_file_from_opts(&self.opt.arg_file, err); - let mime_type = input_mime_from_opts(&self.opt.arg_mime, err); - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), - "resumable" => call.upload_resumable(input_file.unwrap(), mime_type.unwrap()), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _users_messages_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::Message::default(); - let mut call = self.hub.users().messages_insert(&request, &self.opt.arg_user_id); + let mut call = self.hub.users().messages_insert(request, &self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1448,86 +1655,6 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_payload_body_init(request: &mut api::Message) { - request_payload_init(request); - if request.payload.as_mut().unwrap().body.is_none() { - request.payload.as_mut().unwrap().body = Some(Default::default()); - } - } - - fn request_payload_init(request: &mut api::Message) { - if request.payload.is_none() { - request.payload = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "history-id" => { - request.history_id = Some(value.unwrap_or("").to_string()); - }, - "payload.body.data" => { - request_payload_body_init(&mut request); - request.payload.as_mut().unwrap().body.as_mut().unwrap().data = Some(value.unwrap_or("").to_string()); - }, - "payload.body.attachment-id" => { - request_payload_body_init(&mut request); - request.payload.as_mut().unwrap().body.as_mut().unwrap().attachment_id = Some(value.unwrap_or("").to_string()); - }, - "payload.body.size" => { - request_payload_body_init(&mut request); - request.payload.as_mut().unwrap().body.as_mut().unwrap().size = Some(arg_from_str(value.unwrap_or("-0"), err, "payload.body.size", "integer")); - }, - "payload.mime-type" => { - request_payload_body_init(&mut request); - request.payload.as_mut().unwrap().mime_type = Some(value.unwrap_or("").to_string()); - }, - "payload.part-id" => { - request_payload_body_init(&mut request); - request.payload.as_mut().unwrap().part_id = Some(value.unwrap_or("").to_string()); - }, - "payload.filename" => { - request_payload_body_init(&mut request); - request.payload.as_mut().unwrap().filename = Some(value.unwrap_or("").to_string()); - }, - "snippet" => { - request_payload_init(&mut request); - request.snippet = Some(value.unwrap_or("").to_string()); - }, - "raw" => { - request_payload_init(&mut request); - request.raw = Some(value.unwrap_or("").to_string()); - }, - "size-estimate" => { - request_payload_init(&mut request); - request.size_estimate = Some(arg_from_str(value.unwrap_or("-0"), err, "size-estimate", "integer")); - }, - "thread-id" => { - request_payload_init(&mut request); - request.thread_id = Some(value.unwrap_or("").to_string()); - }, - "label-ids" => { - request_payload_init(&mut request); - if request.label_ids.is_none() { - request.label_ids = Some(Default::default()); - } - request.label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "id" => { - request_payload_init(&mut request); - request.id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = if self.opt.cmd_simple { "simple" @@ -1542,6 +1669,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -1601,6 +1731,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1617,8 +1750,42 @@ impl Engine { fn _users_messages_modify(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::ModifyMessageRequest::default(); - let mut call = self.hub.users().messages_modify(&request, &self.opt.arg_user_id, &self.opt.arg_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "remove-label-ids" => { + if request.remove_label_ids.is_none() { + request.remove_label_ids = Some(Default::default()); + } + request.remove_label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "add-label-ids" => { + if request.add_label_ids.is_none() { + request.add_label_ids = Some(Default::default()); + } + request.add_label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.users().messages_modify(request, &self.opt.arg_user_id, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1640,36 +1807,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "remove-label-ids" => { - if request.remove_label_ids.is_none() { - request.remove_label_ids = Some(Default::default()); - } - request.remove_label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "add-label-ids" => { - if request.add_label_ids.is_none() { - request.add_label_ids = Some(Default::default()); - } - request.add_label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1686,36 +1831,23 @@ impl Engine { fn _users_messages_send(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Message::default(); - let mut call = self.hub.users().messages_send(&request, &self.opt.arg_user_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Message::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_payload_body_init(request: &mut api::Message) { request_payload_init(request); if request.payload.as_mut().unwrap().body.is_none() { @@ -1729,7 +1861,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "history-id" => { request.history_id = Some(value.unwrap_or("").to_string()); }, @@ -1785,10 +1917,32 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.users().messages_send(request, &self.opt.arg_user_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = if self.opt.cmd_simple { "simple" @@ -1803,6 +1957,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -1847,6 +2004,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1890,6 +2050,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1933,6 +2096,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1980,6 +2146,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2038,6 +2207,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2054,8 +2226,42 @@ impl Engine { fn _users_threads_modify(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::ModifyThreadRequest::default(); - let mut call = self.hub.users().threads_modify(&request, &self.opt.arg_user_id, &self.opt.arg_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "remove-label-ids" => { + if request.remove_label_ids.is_none() { + request.remove_label_ids = Some(Default::default()); + } + request.remove_label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "add-label-ids" => { + if request.add_label_ids.is_none() { + request.add_label_ids = Some(Default::default()); + } + request.add_label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.users().threads_modify(request, &self.opt.arg_user_id, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2077,36 +2283,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "remove-label-ids" => { - if request.remove_label_ids.is_none() { - request.remove_label_ids = Some(Default::default()); - } - request.remove_label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "add-label-ids" => { - if request.add_label_ids.is_none() { - request.add_label_ids = Some(Default::default()); - } - request.add_label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2150,6 +2334,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2193,6 +2380,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2344,6 +2534,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -2351,8 +2542,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/gmail1/Cargo.toml b/gen/gmail1/Cargo.toml index 98ff204a31..d932b5f9e7 100644 --- a/gen/gmail1/Cargo.toml +++ b/gen/gmail1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-gmail1" -version = "0.1.5+20150303" +version = "0.1.6+20150303" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with gmail (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/gmail1" diff --git a/gen/gmail1/README.md b/gen/gmail1/README.md index c6280528a5..4e43891c1c 100644 --- a/gen/gmail1/README.md +++ b/gen/gmail1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-gmail1` library allows access to all features of the *Google gmail* service. -This documentation was generated from *gmail* crate version *0.1.5+20150303*, where *20150303* is the exact revision of the *gmail:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *gmail* crate version *0.1.6+20150303*, where *20150303* is the exact revision of the *gmail:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *gmail* *v1* API can be found at the [official documentation site](https://developers.google.com/gmail/api/). @@ -115,7 +115,7 @@ let mut req = Message::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `upload(...)`. // Values shown here are possibly random and not representative ! -let result = hub.users().messages_import(&req, "userId") +let result = hub.users().messages_import(req, "userId") .process_for_calendar(true) .never_mark_spam(false) .internal_date_source("sed") @@ -126,14 +126,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/gmail1/src/cmn.rs b/gen/gmail1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/gmail1/src/cmn.rs +++ b/gen/gmail1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/gmail1/src/lib.rs b/gen/gmail1/src/lib.rs index d245f1cf4b..716ddd49cb 100644 --- a/gen/gmail1/src/lib.rs +++ b/gen/gmail1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *gmail* crate version *0.1.5+20150303*, where *20150303* is the exact revision of the *gmail:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *gmail* crate version *0.1.6+20150303*, where *20150303* is the exact revision of the *gmail:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *gmail* *v1* API can be found at the //! [official documentation site](https://developers.google.com/gmail/api/). @@ -116,7 +116,7 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `upload(...)`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.users().messages_import(&req, "userId") +//! let result = hub.users().messages_import(req, "userId") //! .process_for_calendar(false) //! .never_mark_spam(true) //! .internal_date_source("takimata") @@ -127,14 +127,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -222,7 +223,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -316,7 +317,7 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().messages_import(&req, "userId") +/// let result = hub.users().messages_import(req, "userId") /// .process_for_calendar(false) /// .never_mark_spam(true) /// .internal_date_source("sea") @@ -327,14 +328,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -355,7 +357,7 @@ impl<'a, C, A> Gmail<C, A> Gmail { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -364,7 +366,7 @@ impl<'a, C, A> Gmail<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -907,10 +909,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `userId` - The user's email address. The special value me can be used to indicate the authenticated user. - pub fn messages_import(&self, request: &Message, user_id: &str) -> UserMessageImportCall<'a, C, A> { + pub fn messages_import(&self, request: Message, user_id: &str) -> UserMessageImportCall<'a, C, A> { UserMessageImportCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_id: user_id.to_string(), _process_for_calendar: Default::default(), _never_mark_spam: Default::default(), @@ -951,10 +953,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `userId` - The user's email address. The special value me can be used to indicate the authenticated user. - pub fn drafts_create(&self, request: &Draft, user_id: &str) -> UserDraftCreateCall<'a, C, A> { + pub fn drafts_create(&self, request: Draft, user_id: &str) -> UserDraftCreateCall<'a, C, A> { UserDraftCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_id: user_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -970,10 +972,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `userId` - The user's email address. The special value me can be used to indicate the authenticated user. - pub fn labels_create(&self, request: &Label, user_id: &str) -> UserLabelCreateCall<'a, C, A> { + pub fn labels_create(&self, request: Label, user_id: &str) -> UserLabelCreateCall<'a, C, A> { UserLabelCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_id: user_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1046,10 +1048,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `userId` - The user's email address. The special value me can be used to indicate the authenticated user. - pub fn drafts_send(&self, request: &Draft, user_id: &str) -> UserDraftSendCall<'a, C, A> { + pub fn drafts_send(&self, request: Draft, user_id: &str) -> UserDraftSendCall<'a, C, A> { UserDraftSendCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_id: user_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1121,10 +1123,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// * `request` - No description provided. /// * `userId` - The user's email address. The special value me can be used to indicate the authenticated user. /// * `id` - The ID of the draft to update. - pub fn drafts_update(&self, request: &Draft, user_id: &str, id: &str) -> UserDraftUpdateCall<'a, C, A> { + pub fn drafts_update(&self, request: Draft, user_id: &str, id: &str) -> UserDraftUpdateCall<'a, C, A> { UserDraftUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_id: user_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -1162,10 +1164,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// * `request` - No description provided. /// * `userId` - The user's email address. The special value me can be used to indicate the authenticated user. /// * `id` - The ID of the label to update. - pub fn labels_update(&self, request: &Label, user_id: &str, id: &str) -> UserLabelUpdateCall<'a, C, A> { + pub fn labels_update(&self, request: Label, user_id: &str, id: &str) -> UserLabelUpdateCall<'a, C, A> { UserLabelUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_id: user_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -1202,10 +1204,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// * `request` - No description provided. /// * `userId` - The user's email address. The special value me can be used to indicate the authenticated user. /// * `id` - The ID of the label to update. - pub fn labels_patch(&self, request: &Label, user_id: &str, id: &str) -> UserLabelPatchCall<'a, C, A> { + pub fn labels_patch(&self, request: Label, user_id: &str, id: &str) -> UserLabelPatchCall<'a, C, A> { UserLabelPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_id: user_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -1264,10 +1266,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// * `request` - No description provided. /// * `userId` - The user's email address. The special value me can be used to indicate the authenticated user. /// * `id` - The ID of the thread to modify. - pub fn threads_modify(&self, request: &ModifyThreadRequest, user_id: &str, id: &str) -> UserThreadModifyCall<'a, C, A> { + pub fn threads_modify(&self, request: ModifyThreadRequest, user_id: &str, id: &str) -> UserThreadModifyCall<'a, C, A> { UserThreadModifyCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_id: user_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -1325,10 +1327,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// * `request` - No description provided. /// * `userId` - The user's email address. The special value me can be used to indicate the authenticated user. /// * `id` - The ID of the message to modify. - pub fn messages_modify(&self, request: &ModifyMessageRequest, user_id: &str, id: &str) -> UserMessageModifyCall<'a, C, A> { + pub fn messages_modify(&self, request: ModifyMessageRequest, user_id: &str, id: &str) -> UserMessageModifyCall<'a, C, A> { UserMessageModifyCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_id: user_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -1383,10 +1385,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `userId` - The user's email address. The special value me can be used to indicate the authenticated user. - pub fn messages_send(&self, request: &Message, user_id: &str) -> UserMessageSendCall<'a, C, A> { + pub fn messages_send(&self, request: Message, user_id: &str) -> UserMessageSendCall<'a, C, A> { UserMessageSendCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_id: user_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1483,10 +1485,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `userId` - The user's email address. The special value me can be used to indicate the authenticated user. - pub fn messages_insert(&self, request: &Message, user_id: &str) -> UserMessageInsertCall<'a, C, A> { + pub fn messages_insert(&self, request: Message, user_id: &str) -> UserMessageInsertCall<'a, C, A> { UserMessageInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_id: user_id.to_string(), _internal_date_source: Default::default(), _deleted: Default::default(), @@ -1538,7 +1540,7 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().messages_import(&req, "userId") +/// let result = hub.users().messages_import(req, "userId") /// .process_for_calendar(false) /// .never_mark_spam(false) /// .internal_date_source("aliquyam") @@ -1604,14 +1606,15 @@ impl<'a, C, A> UserMessageImportCall<'a, C, A> where C: BorrowMut<hyper::Client> params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/gmail/v1/users/{userId}/messages/import".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/gmail/v1/users/{userId}/messages/import".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/gmail/v1/users/{userId}/messages/import".to_string() + ("https://www.googleapis.com/resumable/upload/gmail/v1/users/{userId}/messages/import".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::Gmai.as_ref().to_string(), ()); } @@ -1730,12 +1733,17 @@ impl<'a, C, A> UserMessageImportCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -1745,9 +1753,9 @@ impl<'a, C, A> UserMessageImportCall<'a, C, A> where C: BorrowMut<hyper::Client> } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -1757,7 +1765,7 @@ impl<'a, C, A> UserMessageImportCall<'a, C, A> where C: BorrowMut<hyper::Client> auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -1788,7 +1796,7 @@ impl<'a, C, A> UserMessageImportCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1832,8 +1840,8 @@ impl<'a, C, A> UserMessageImportCall<'a, C, A> where C: BorrowMut<hyper::Client> /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Message) -> UserMessageImportCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Message) -> UserMessageImportCall<'a, C, A> { + self._request = new_value; self } /// The user's email address. The special value me can be used to indicate the authenticated user. @@ -2091,12 +2099,17 @@ impl<'a, C, A> UserHistoryListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2105,7 +2118,7 @@ impl<'a, C, A> UserHistoryListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2241,7 +2254,7 @@ impl<'a, C, A> UserHistoryListCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().drafts_create(&req, "userId") +/// let result = hub.users().drafts_create(req, "userId") /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } /// ``` @@ -2287,14 +2300,15 @@ impl<'a, C, A> UserDraftCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/gmail/v1/users/{userId}/drafts".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/gmail/v1/users/{userId}/drafts".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/gmail/v1/users/{userId}/drafts".to_string() + ("https://www.googleapis.com/resumable/upload/gmail/v1/users/{userId}/drafts".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::Gmai.as_ref().to_string(), ()); } @@ -2413,12 +2427,17 @@ impl<'a, C, A> UserDraftCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -2428,9 +2447,9 @@ impl<'a, C, A> UserDraftCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -2440,7 +2459,7 @@ impl<'a, C, A> UserDraftCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -2471,7 +2490,7 @@ impl<'a, C, A> UserDraftCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2515,8 +2534,8 @@ impl<'a, C, A> UserDraftCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Draft) -> UserDraftCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Draft) -> UserDraftCreateCall<'a, C, A> { + self._request = new_value; self } /// The user's email address. The special value me can be used to indicate the authenticated user. @@ -2613,7 +2632,7 @@ impl<'a, C, A> UserDraftCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().labels_create(&req, "userId") +/// let result = hub.users().labels_create(req, "userId") /// .doit(); /// # } /// ``` @@ -2741,12 +2760,17 @@ impl<'a, C, A> UserLabelCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2755,7 +2779,7 @@ impl<'a, C, A> UserLabelCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2773,8 +2797,8 @@ impl<'a, C, A> UserLabelCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Label) -> UserLabelCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Label) -> UserLabelCreateCall<'a, C, A> { + self._request = new_value; self } /// The user's email address. The special value me can be used to indicate the authenticated user. @@ -2985,12 +3009,17 @@ impl<'a, C, A> UserLabelDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -3221,12 +3250,17 @@ impl<'a, C, A> UserLabelGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3235,7 +3269,7 @@ impl<'a, C, A> UserLabelGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3467,12 +3501,17 @@ impl<'a, C, A> UserMessageTrashCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3481,7 +3520,7 @@ impl<'a, C, A> UserMessageTrashCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3599,7 +3638,7 @@ impl<'a, C, A> UserMessageTrashCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().drafts_send(&req, "userId") +/// let result = hub.users().drafts_send(req, "userId") /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } /// ``` @@ -3645,14 +3684,15 @@ impl<'a, C, A> UserDraftSendCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/gmail/v1/users/{userId}/drafts/send".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/gmail/v1/users/{userId}/drafts/send".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/gmail/v1/users/{userId}/drafts/send".to_string() + ("https://www.googleapis.com/resumable/upload/gmail/v1/users/{userId}/drafts/send".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::Gmai.as_ref().to_string(), ()); } @@ -3771,12 +3811,17 @@ impl<'a, C, A> UserDraftSendCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -3786,9 +3831,9 @@ impl<'a, C, A> UserDraftSendCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -3798,7 +3843,7 @@ impl<'a, C, A> UserDraftSendCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -3829,7 +3874,7 @@ impl<'a, C, A> UserDraftSendCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3873,8 +3918,8 @@ impl<'a, C, A> UserDraftSendCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Draft) -> UserDraftSendCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Draft) -> UserDraftSendCall<'a, C, A> { + self._request = new_value; self } /// The user's email address. The special value me can be used to indicate the authenticated user. @@ -4086,12 +4131,17 @@ impl<'a, C, A> UserMessageUntrashCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4100,7 +4150,7 @@ impl<'a, C, A> UserMessageUntrashCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4330,12 +4380,17 @@ impl<'a, C, A> UserLabelListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4344,7 +4399,7 @@ impl<'a, C, A> UserLabelListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4565,12 +4620,17 @@ impl<'a, C, A> UserMessageDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -4687,7 +4747,7 @@ impl<'a, C, A> UserMessageDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().drafts_update(&req, "userId", "id") +/// let result = hub.users().drafts_update(req, "userId", "id") /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } /// ``` @@ -4735,14 +4795,15 @@ impl<'a, C, A> UserDraftUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/gmail/v1/users/{userId}/drafts/{id}".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/gmail/v1/users/{userId}/drafts/{id}".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/gmail/v1/users/{userId}/drafts/{id}".to_string() + ("https://www.googleapis.com/resumable/upload/gmail/v1/users/{userId}/drafts/{id}".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::Gmai.as_ref().to_string(), ()); } @@ -4861,12 +4922,17 @@ impl<'a, C, A> UserDraftUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -4876,9 +4942,9 @@ impl<'a, C, A> UserDraftUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -4888,7 +4954,7 @@ impl<'a, C, A> UserDraftUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -4919,7 +4985,7 @@ impl<'a, C, A> UserDraftUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4963,8 +5029,8 @@ impl<'a, C, A> UserDraftUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Draft) -> UserDraftUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Draft) -> UserDraftUpdateCall<'a, C, A> { + self._request = new_value; self } /// The user's email address. The special value me can be used to indicate the authenticated user. @@ -5191,12 +5257,17 @@ impl<'a, C, A> UserDraftGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5205,7 +5276,7 @@ impl<'a, C, A> UserDraftGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5329,7 +5400,7 @@ impl<'a, C, A> UserDraftGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().labels_update(&req, "userId", "id") +/// let result = hub.users().labels_update(req, "userId", "id") /// .doit(); /// # } /// ``` @@ -5459,12 +5530,17 @@ impl<'a, C, A> UserLabelUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5473,7 +5549,7 @@ impl<'a, C, A> UserLabelUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5491,8 +5567,8 @@ impl<'a, C, A> UserLabelUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Label) -> UserLabelUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Label) -> UserLabelUpdateCall<'a, C, A> { + self._request = new_value; self } /// The user's email address. The special value me can be used to indicate the authenticated user. @@ -5714,12 +5790,17 @@ impl<'a, C, A> UserThreadUntrashCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5728,7 +5809,7 @@ impl<'a, C, A> UserThreadUntrashCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5845,7 +5926,7 @@ impl<'a, C, A> UserThreadUntrashCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().labels_patch(&req, "userId", "id") +/// let result = hub.users().labels_patch(req, "userId", "id") /// .doit(); /// # } /// ``` @@ -5975,12 +6056,17 @@ impl<'a, C, A> UserLabelPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5989,7 +6075,7 @@ impl<'a, C, A> UserLabelPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6007,8 +6093,8 @@ impl<'a, C, A> UserLabelPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Label) -> UserLabelPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Label) -> UserLabelPatchCall<'a, C, A> { + self._request = new_value; self } /// The user's email address. The special value me can be used to indicate the authenticated user. @@ -6229,12 +6315,17 @@ impl<'a, C, A> UserDraftDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -6492,12 +6583,17 @@ impl<'a, C, A> UserThreadListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6506,7 +6602,7 @@ impl<'a, C, A> UserThreadListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6649,7 +6745,7 @@ impl<'a, C, A> UserThreadListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().threads_modify(&req, "userId", "id") +/// let result = hub.users().threads_modify(req, "userId", "id") /// .doit(); /// # } /// ``` @@ -6779,12 +6875,17 @@ impl<'a, C, A> UserThreadModifyCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6793,7 +6894,7 @@ impl<'a, C, A> UserThreadModifyCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6811,8 +6912,8 @@ impl<'a, C, A> UserThreadModifyCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ModifyThreadRequest) -> UserThreadModifyCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ModifyThreadRequest) -> UserThreadModifyCall<'a, C, A> { + self._request = new_value; self } /// The user's email address. The special value me can be used to indicate the authenticated user. @@ -7033,12 +7134,17 @@ impl<'a, C, A> UserThreadDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -7271,12 +7377,17 @@ impl<'a, C, A> UserMessageAttachmentGetCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7285,7 +7396,7 @@ impl<'a, C, A> UserMessageAttachmentGetCall<'a, C, A> where C: BorrowMut<hyper:: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7412,7 +7523,7 @@ impl<'a, C, A> UserMessageAttachmentGetCall<'a, C, A> where C: BorrowMut<hyper:: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().messages_modify(&req, "userId", "id") +/// let result = hub.users().messages_modify(req, "userId", "id") /// .doit(); /// # } /// ``` @@ -7542,12 +7653,17 @@ impl<'a, C, A> UserMessageModifyCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7556,7 +7672,7 @@ impl<'a, C, A> UserMessageModifyCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7574,8 +7690,8 @@ impl<'a, C, A> UserMessageModifyCall<'a, C, A> where C: BorrowMut<hyper::Client> /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ModifyMessageRequest) -> UserMessageModifyCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ModifyMessageRequest) -> UserMessageModifyCall<'a, C, A> { + self._request = new_value; self } /// The user's email address. The special value me can be used to indicate the authenticated user. @@ -7797,12 +7913,17 @@ impl<'a, C, A> UserThreadTrashCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7811,7 +7932,7 @@ impl<'a, C, A> UserThreadTrashCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8051,12 +8172,17 @@ impl<'a, C, A> UserDraftListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8065,7 +8191,7 @@ impl<'a, C, A> UserDraftListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8187,7 +8313,7 @@ impl<'a, C, A> UserDraftListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().messages_send(&req, "userId") +/// let result = hub.users().messages_send(req, "userId") /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } /// ``` @@ -8233,14 +8359,15 @@ impl<'a, C, A> UserMessageSendCall<'a, C, A> where C: BorrowMut<hyper::Client>, params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/gmail/v1/users/{userId}/messages/send".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/gmail/v1/users/{userId}/messages/send".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/gmail/v1/users/{userId}/messages/send".to_string() + ("https://www.googleapis.com/resumable/upload/gmail/v1/users/{userId}/messages/send".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::Gmai.as_ref().to_string(), ()); } @@ -8359,12 +8486,17 @@ impl<'a, C, A> UserMessageSendCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -8374,9 +8506,9 @@ impl<'a, C, A> UserMessageSendCall<'a, C, A> where C: BorrowMut<hyper::Client>, } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -8386,7 +8518,7 @@ impl<'a, C, A> UserMessageSendCall<'a, C, A> where C: BorrowMut<hyper::Client>, auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -8417,7 +8549,7 @@ impl<'a, C, A> UserMessageSendCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8461,8 +8593,8 @@ impl<'a, C, A> UserMessageSendCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Message) -> UserMessageSendCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Message) -> UserMessageSendCall<'a, C, A> { + self._request = new_value; self } /// The user's email address. The special value me can be used to indicate the authenticated user. @@ -8688,12 +8820,17 @@ impl<'a, C, A> UserMessageGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8702,7 +8839,7 @@ impl<'a, C, A> UserMessageGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8976,12 +9113,17 @@ impl<'a, C, A> UserMessageListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8990,7 +9132,7 @@ impl<'a, C, A> UserMessageListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9246,12 +9388,17 @@ impl<'a, C, A> UserGetProfileCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9260,7 +9407,7 @@ impl<'a, C, A> UserGetProfileCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9496,12 +9643,17 @@ impl<'a, C, A> UserThreadGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9510,7 +9662,7 @@ impl<'a, C, A> UserThreadGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9643,7 +9795,7 @@ impl<'a, C, A> UserThreadGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().messages_insert(&req, "userId") +/// let result = hub.users().messages_insert(req, "userId") /// .internal_date_source("nonumy") /// .deleted(true) /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); @@ -9699,14 +9851,15 @@ impl<'a, C, A> UserMessageInsertCall<'a, C, A> where C: BorrowMut<hyper::Client> params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/gmail/v1/users/{userId}/messages".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/gmail/v1/users/{userId}/messages".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/gmail/v1/users/{userId}/messages".to_string() + ("https://www.googleapis.com/resumable/upload/gmail/v1/users/{userId}/messages".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::Gmai.as_ref().to_string(), ()); } @@ -9825,12 +9978,17 @@ impl<'a, C, A> UserMessageInsertCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -9840,9 +9998,9 @@ impl<'a, C, A> UserMessageInsertCall<'a, C, A> where C: BorrowMut<hyper::Client> } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -9852,7 +10010,7 @@ impl<'a, C, A> UserMessageInsertCall<'a, C, A> where C: BorrowMut<hyper::Client> auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -9883,7 +10041,7 @@ impl<'a, C, A> UserMessageInsertCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9927,8 +10085,8 @@ impl<'a, C, A> UserMessageInsertCall<'a, C, A> where C: BorrowMut<hyper::Client> /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Message) -> UserMessageInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Message) -> UserMessageInsertCall<'a, C, A> { + self._request = new_value; self } /// The user's email address. The special value me can be used to indicate the authenticated user. diff --git a/gen/groupsmigration1-cli/Cargo.toml b/gen/groupsmigration1-cli/Cargo.toml index a5346db386..76e24847c3 100644 --- a/gen/groupsmigration1-cli/Cargo.toml +++ b/gen/groupsmigration1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-groupsmigration1-cli" -version = "0.0.1+20140416" +version = "0.1.0+20140416" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with Groups Migration (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/groupsmigration1-cli" diff --git a/gen/groupsmigration1-cli/README.md b/gen/groupsmigration1-cli/README.md index dc0dd01327..d5c44a2ed2 100644 --- a/gen/groupsmigration1-cli/README.md +++ b/gen/groupsmigration1-cli/README.md @@ -1,4 +1,102 @@ -# HELLO GROUPSMIGRATION:V1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `groupsmigration1` command-line interface *(CLI)* allows to use most features of the *Google Groups Migration* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *Groups Migration* API at revision *20140416*. The CLI is at version *0.1.0*. + +```bash + groupsmigration1 [options] archive insert <group-id> -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + groupsmigration1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_groupsmigration1_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `groupsmigration1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/groupsmigration1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/groupsmigration1-secret.json`, assuming that the required *groupsmigration* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `groupsmigration1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/groupsmigration1-cli/mkdocs.yml b/gen/groupsmigration1-cli/mkdocs.yml index 14a19519d1..3a965ae1c3 100644 --- a/gen/groupsmigration1-cli/mkdocs.yml +++ b/gen/groupsmigration1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Groups Migration v0.0.1+20140416 +site_name: Groups Migration v0.1.0+20140416 site_url: http://byron.github.io/google-apis-rs/google-groupsmigration1-cli site_description: Write integrating applications with bcore diff --git a/gen/groupsmigration1-cli/src/cmn.rs b/gen/groupsmigration1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/groupsmigration1-cli/src/cmn.rs +++ b/gen/groupsmigration1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/groupsmigration1-cli/src/main.rs b/gen/groupsmigration1-cli/src/main.rs index a324d36057..609234b14e 100644 --- a/gen/groupsmigration1-cli/src/main.rs +++ b/gen/groupsmigration1-cli/src/main.rs @@ -19,26 +19,27 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - groupsmigration1 [options] archive insert <group-id> -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] + groupsmigration1 [options] archive insert <group-id> -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] groupsmigration1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_groupsmigration1_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -96,6 +97,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -190,6 +194,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -197,8 +202,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/groupsmigration1/Cargo.toml b/gen/groupsmigration1/Cargo.toml index fd43b4e73a..7403b5e0ae 100644 --- a/gen/groupsmigration1/Cargo.toml +++ b/gen/groupsmigration1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-groupsmigration1" -version = "0.1.5+20140416" +version = "0.1.6+20140416" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with Groups Migration (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/groupsmigration1" diff --git a/gen/groupsmigration1/README.md b/gen/groupsmigration1/README.md index fb5f65253b..c807bfadfa 100644 --- a/gen/groupsmigration1/README.md +++ b/gen/groupsmigration1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-groupsmigration1` library allows access to all features of the *Google Groups Migration* service. -This documentation was generated from *Groups Migration* crate version *0.1.5+20140416*, where *20140416* is the exact revision of the *groupsmigration:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *Groups Migration* crate version *0.1.6+20140416*, where *20140416* is the exact revision of the *groupsmigration:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *Groups Migration* *v1* API can be found at the [official documentation site](https://developers.google.com/google-apps/groups-migration/). @@ -104,14 +104,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/groupsmigration1/src/cmn.rs b/gen/groupsmigration1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/groupsmigration1/src/cmn.rs +++ b/gen/groupsmigration1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/groupsmigration1/src/lib.rs b/gen/groupsmigration1/src/lib.rs index c60920de86..cc3d59ad46 100644 --- a/gen/groupsmigration1/src/lib.rs +++ b/gen/groupsmigration1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Groups Migration* crate version *0.1.5+20140416*, where *20140416* is the exact revision of the *groupsmigration:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *Groups Migration* crate version *0.1.6+20140416*, where *20140416* is the exact revision of the *groupsmigration:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *Groups Migration* *v1* API can be found at the //! [official documentation site](https://developers.google.com/google-apps/groups-migration/). @@ -105,14 +105,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -200,7 +201,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -275,14 +276,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -303,7 +305,7 @@ impl<'a, C, A> GroupsMigration<C, A> GroupsMigration { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -312,7 +314,7 @@ impl<'a, C, A> GroupsMigration<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -488,14 +490,15 @@ impl<'a, C, A> ArchiveInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/groups/v1/groups/{groupId}/archive".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/groups/v1/groups/{groupId}/archive".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/groups/v1/groups/{groupId}/archive".to_string() + ("https://www.googleapis.com/resumable/upload/groups/v1/groups/{groupId}/archive".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::AppGroupMigration.as_ref().to_string(), ()); } @@ -601,12 +604,17 @@ impl<'a, C, A> ArchiveInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -616,9 +624,9 @@ impl<'a, C, A> ArchiveInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -628,7 +636,7 @@ impl<'a, C, A> ArchiveInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -659,7 +667,7 @@ impl<'a, C, A> ArchiveInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/groupssettings1-cli/Cargo.toml b/gen/groupssettings1-cli/Cargo.toml index 939f966a96..be66f4952b 100644 --- a/gen/groupssettings1-cli/Cargo.toml +++ b/gen/groupssettings1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-groupssettings1-cli" -version = "0.0.1+20140428" +version = "0.1.0+20140428" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with groupssettings (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/groupssettings1-cli" diff --git a/gen/groupssettings1-cli/README.md b/gen/groupssettings1-cli/README.md index 2583be4b69..d748a8404f 100644 --- a/gen/groupssettings1-cli/README.md +++ b/gen/groupssettings1-cli/README.md @@ -1,4 +1,104 @@ -# HELLO GROUPSSETTINGS:V1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `groupssettings1` command-line interface *(CLI)* allows to use most features of the *Google groupssettings* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *groupssettings* API at revision *20140428*. The CLI is at version *0.1.0*. + +```bash + groupssettings1 [options] groups get <group-unique-id> [-p <v>...] [-o <out>] + groupssettings1 [options] groups patch <group-unique-id> -r <kv>... [-p <v>...] [-o <out>] + groupssettings1 [options] groups update <group-unique-id> -r <kv>... [-p <v>...] [-o <out>] + groupssettings1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_groupssettings1_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `groupssettings1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/groupssettings1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/groupssettings1-secret.json`, assuming that the required *groupssettings* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `groupssettings1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/groupssettings1-cli/mkdocs.yml b/gen/groupssettings1-cli/mkdocs.yml index 5a01a4c845..10738917fd 100644 --- a/gen/groupssettings1-cli/mkdocs.yml +++ b/gen/groupssettings1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: groupssettings v0.0.1+20140428 +site_name: groupssettings v0.1.0+20140428 site_url: http://byron.github.io/google-apis-rs/google-groupssettings1-cli site_description: Write integrating applications with bcore diff --git a/gen/groupssettings1-cli/src/cmn.rs b/gen/groupssettings1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/groupssettings1-cli/src/cmn.rs +++ b/gen/groupssettings1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/groupssettings1-cli/src/main.rs b/gen/groupssettings1-cli/src/main.rs index adfaeb5d42..398ae8c799 100644 --- a/gen/groupssettings1-cli/src/main.rs +++ b/gen/groupssettings1-cli/src/main.rs @@ -19,28 +19,29 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - groupssettings1 [options] groups get <group-unique-id> [-p <v>]... [-o <out>] - groupssettings1 [options] groups patch <group-unique-id> -r <kv>... [-p <v>]... [-o <out>] - groupssettings1 [options] groups update <group-unique-id> -r <kv>... [-p <v>]... [-o <out>] + groupssettings1 [options] groups get <group-unique-id> [-p <v>...] [-o <out>] + groupssettings1 [options] groups patch <group-unique-id> -r <kv>... [-p <v>...] [-o <out>] + groupssettings1 [options] groups update <group-unique-id> -r <kv>... [-p <v>...] [-o <out>] groupssettings1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_groupssettings1_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -89,6 +90,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -105,37 +109,24 @@ impl Engine { fn _groups_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Groups::default(); - let mut call = self.hub.groups().patch(&request, &self.opt.arg_group_unique_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Groups::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "allow-external-members" => { request.allow_external_members = Some(value.unwrap_or("").to_string()); }, @@ -221,15 +212,40 @@ impl Engine { request.allow_google_communication = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.groups().patch(request, &self.opt.arg_group_unique_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -246,37 +262,24 @@ impl Engine { fn _groups_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Groups::default(); - let mut call = self.hub.groups().update(&request, &self.opt.arg_group_unique_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Groups::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "allow-external-members" => { request.allow_external_members = Some(value.unwrap_or("").to_string()); }, @@ -362,15 +365,40 @@ impl Engine { request.allow_google_communication = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.groups().update(request, &self.opt.arg_group_unique_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -468,6 +496,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -475,8 +504,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/groupssettings1/Cargo.toml b/gen/groupssettings1/Cargo.toml index 08805a8c0b..17b57f4a41 100644 --- a/gen/groupssettings1/Cargo.toml +++ b/gen/groupssettings1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-groupssettings1" -version = "0.1.5+20140428" +version = "0.1.6+20140428" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with groupssettings (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/groupssettings1" diff --git a/gen/groupssettings1/README.md b/gen/groupssettings1/README.md index 236f74a1d6..d5e61c3b3b 100644 --- a/gen/groupssettings1/README.md +++ b/gen/groupssettings1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-groupssettings1` library allows access to all features of the *Google groupssettings* service. -This documentation was generated from *groupssettings* crate version *0.1.5+20140428*, where *20140428* is the exact revision of the *groupssettings:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *groupssettings* crate version *0.1.6+20140428*, where *20140428* is the exact revision of the *groupssettings:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *groupssettings* *v1* API can be found at the [official documentation site](https://developers.google.com/google-apps/groups-settings/get_started). @@ -100,21 +100,22 @@ let mut req = Groups::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.groups().update(&req, "groupUniqueId") +let result = hub.groups().update(req, "groupUniqueId") .doit(); match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/groupssettings1/src/cmn.rs b/gen/groupssettings1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/groupssettings1/src/cmn.rs +++ b/gen/groupssettings1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/groupssettings1/src/lib.rs b/gen/groupssettings1/src/lib.rs index 3ccd1ea981..b0c1d568fb 100644 --- a/gen/groupssettings1/src/lib.rs +++ b/gen/groupssettings1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *groupssettings* crate version *0.1.5+20140428*, where *20140428* is the exact revision of the *groupssettings:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *groupssettings* crate version *0.1.6+20140428*, where *20140428* is the exact revision of the *groupssettings:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *groupssettings* *v1* API can be found at the //! [official documentation site](https://developers.google.com/google-apps/groups-settings/get_started). @@ -101,21 +101,22 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.groups().update(&req, "groupUniqueId") +//! let result = hub.groups().update(req, "groupUniqueId") //! .doit(); //! //! match result { //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -203,7 +204,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -276,21 +277,22 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.groups().update(&req, "groupUniqueId") +/// let result = hub.groups().update(req, "groupUniqueId") /// .doit(); /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -311,7 +313,7 @@ impl<'a, C, A> Groupssettings<C, A> Groupssettings { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -320,7 +322,7 @@ impl<'a, C, A> Groupssettings<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -484,10 +486,10 @@ impl<'a, C, A> GroupMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `groupUniqueId` - The resource ID - pub fn update(&self, request: &Groups, group_unique_id: &str) -> GroupUpdateCall<'a, C, A> { + pub fn update(&self, request: Groups, group_unique_id: &str) -> GroupUpdateCall<'a, C, A> { GroupUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _group_unique_id: group_unique_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -503,10 +505,10 @@ impl<'a, C, A> GroupMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `groupUniqueId` - The resource ID - pub fn patch(&self, request: &Groups, group_unique_id: &str) -> GroupPatchCall<'a, C, A> { + pub fn patch(&self, request: Groups, group_unique_id: &str) -> GroupPatchCall<'a, C, A> { GroupPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _group_unique_id: group_unique_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -572,7 +574,7 @@ impl<'a, C, A> GroupMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.groups().update(&req, "groupUniqueId") +/// let result = hub.groups().update(req, "groupUniqueId") /// .doit(); /// # } /// ``` @@ -700,12 +702,17 @@ impl<'a, C, A> GroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -714,7 +721,7 @@ impl<'a, C, A> GroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -732,8 +739,8 @@ impl<'a, C, A> GroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Groups) -> GroupUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Groups) -> GroupUpdateCall<'a, C, A> { + self._request = new_value; self } /// The resource ID @@ -830,7 +837,7 @@ impl<'a, C, A> GroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.groups().patch(&req, "groupUniqueId") +/// let result = hub.groups().patch(req, "groupUniqueId") /// .doit(); /// # } /// ``` @@ -958,12 +965,17 @@ impl<'a, C, A> GroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -972,7 +984,7 @@ impl<'a, C, A> GroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -990,8 +1002,8 @@ impl<'a, C, A> GroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Groups) -> GroupPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Groups) -> GroupPatchCall<'a, C, A> { + self._request = new_value; self } /// The resource ID @@ -1201,12 +1213,17 @@ impl<'a, C, A> GroupGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1215,7 +1232,7 @@ impl<'a, C, A> GroupGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/identitytoolkit3-cli/Cargo.toml b/gen/identitytoolkit3-cli/Cargo.toml index 4edbe32ba7..7aa5a224bf 100644 --- a/gen/identitytoolkit3-cli/Cargo.toml +++ b/gen/identitytoolkit3-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-identitytoolkit3-cli" -version = "0.0.1+20150406" +version = "0.1.0+20150406" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with Identity Toolkit (protocol v3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/identitytoolkit3-cli" diff --git a/gen/identitytoolkit3-cli/README.md b/gen/identitytoolkit3-cli/README.md index e5bc6ba8ca..37622e3af7 100644 --- a/gen/identitytoolkit3-cli/README.md +++ b/gen/identitytoolkit3-cli/README.md @@ -1,4 +1,109 @@ -# HELLO IDENTITYTOOLKIT:V3 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `identitytoolkit3` command-line interface *(CLI)* allows to use most features of the *Google Identity Toolkit* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *Identity Toolkit* API at revision *20150406*. The CLI is at version *0.1.0*. + +```bash + identitytoolkit3 [options] relyingparty create-auth-uri -r <kv>... [-p <v>...] [-o <out>] + identitytoolkit3 [options] relyingparty delete-account -r <kv>... [-p <v>...] [-o <out>] + identitytoolkit3 [options] relyingparty download-account -r <kv>... [-p <v>...] [-o <out>] + identitytoolkit3 [options] relyingparty get-account-info -r <kv>... [-p <v>...] [-o <out>] + identitytoolkit3 [options] relyingparty get-oob-confirmation-code -r <kv>... [-p <v>...] [-o <out>] + identitytoolkit3 [options] relyingparty get-public-keys [-p <v>...] [-o <out>] + identitytoolkit3 [options] relyingparty get-recaptcha-param [-p <v>...] [-o <out>] + identitytoolkit3 [options] relyingparty reset-password -r <kv>... [-p <v>...] [-o <out>] + identitytoolkit3 [options] relyingparty set-account-info -r <kv>... [-p <v>...] [-o <out>] + identitytoolkit3 [options] relyingparty upload-account -r <kv>... [-p <v>...] [-o <out>] + identitytoolkit3 [options] relyingparty verify-assertion -r <kv>... [-p <v>...] [-o <out>] + identitytoolkit3 [options] relyingparty verify-password -r <kv>... [-p <v>...] [-o <out>] + identitytoolkit3 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_identitytoolkit3_cli/index.html + +Configuration: + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `identitytoolkit3-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/identitytoolkit3-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/identitytoolkit3-secret.json`, assuming that the required *identitytoolkit* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `identitytoolkit3 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/identitytoolkit3-cli/mkdocs.yml b/gen/identitytoolkit3-cli/mkdocs.yml index c5daaaa007..f3cb0895eb 100644 --- a/gen/identitytoolkit3-cli/mkdocs.yml +++ b/gen/identitytoolkit3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Identity Toolkit v0.0.1+20150406 +site_name: Identity Toolkit v0.1.0+20150406 site_url: http://byron.github.io/google-apis-rs/google-identitytoolkit3-cli site_description: Write integrating applications with bcore diff --git a/gen/identitytoolkit3-cli/src/cmn.rs b/gen/identitytoolkit3-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/identitytoolkit3-cli/src/cmn.rs +++ b/gen/identitytoolkit3-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/identitytoolkit3-cli/src/main.rs b/gen/identitytoolkit3-cli/src/main.rs index 591940e396..d7fde8a5f6 100644 --- a/gen/identitytoolkit3-cli/src/main.rs +++ b/gen/identitytoolkit3-cli/src/main.rs @@ -19,33 +19,34 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - identitytoolkit3 [options] relyingparty create-auth-uri -r <kv>... [-p <v>]... [-o <out>] - identitytoolkit3 [options] relyingparty delete-account -r <kv>... [-p <v>]... [-o <out>] - identitytoolkit3 [options] relyingparty download-account -r <kv>... [-p <v>]... [-o <out>] - identitytoolkit3 [options] relyingparty get-account-info -r <kv>... [-p <v>]... [-o <out>] - identitytoolkit3 [options] relyingparty get-oob-confirmation-code -r <kv>... [-p <v>]... [-o <out>] - identitytoolkit3 [options] relyingparty get-public-keys [-p <v>]... [-o <out>] - identitytoolkit3 [options] relyingparty get-recaptcha-param [-p <v>]... [-o <out>] - identitytoolkit3 [options] relyingparty reset-password -r <kv>... [-p <v>]... [-o <out>] - identitytoolkit3 [options] relyingparty set-account-info -r <kv>... [-p <v>]... [-o <out>] - identitytoolkit3 [options] relyingparty upload-account -r <kv>... [-p <v>]... [-o <out>] - identitytoolkit3 [options] relyingparty verify-assertion -r <kv>... [-p <v>]... [-o <out>] - identitytoolkit3 [options] relyingparty verify-password -r <kv>... [-p <v>]... [-o <out>] + identitytoolkit3 [options] relyingparty create-auth-uri -r <kv>... [-p <v>...] [-o <out>] + identitytoolkit3 [options] relyingparty delete-account -r <kv>... [-p <v>...] [-o <out>] + identitytoolkit3 [options] relyingparty download-account -r <kv>... [-p <v>...] [-o <out>] + identitytoolkit3 [options] relyingparty get-account-info -r <kv>... [-p <v>...] [-o <out>] + identitytoolkit3 [options] relyingparty get-oob-confirmation-code -r <kv>... [-p <v>...] [-o <out>] + identitytoolkit3 [options] relyingparty get-public-keys [-p <v>...] [-o <out>] + identitytoolkit3 [options] relyingparty get-recaptcha-param [-p <v>...] [-o <out>] + identitytoolkit3 [options] relyingparty reset-password -r <kv>... [-p <v>...] [-o <out>] + identitytoolkit3 [options] relyingparty set-account-info -r <kv>... [-p <v>...] [-o <out>] + identitytoolkit3 [options] relyingparty upload-account -r <kv>... [-p <v>...] [-o <out>] + identitytoolkit3 [options] relyingparty verify-assertion -r <kv>... [-p <v>...] [-o <out>] + identitytoolkit3 [options] relyingparty verify-password -r <kv>... [-p <v>...] [-o <out>] identitytoolkit3 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_identitytoolkit3_cli/index.html Configuration: --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -67,37 +68,24 @@ struct Engine { impl Engine { fn _relyingparty_create_auth_uri(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::IdentitytoolkitRelyingpartyCreateAuthUriRequest::default(); - let mut call = self.hub.relyingparty().create_auth_uri(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::IdentitytoolkitRelyingpartyCreateAuthUriRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "openid-realm" => { request.openid_realm = Some(value.unwrap_or("").to_string()); }, @@ -129,10 +117,32 @@ impl Engine { request.identifier = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.relyingparty().create_auth_uri(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None @@ -154,8 +164,33 @@ impl Engine { fn _relyingparty_delete_account(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::IdentitytoolkitRelyingpartyDeleteAccountRequest::default(); - let mut call = self.hub.relyingparty().delete_account(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "local-id" => { + request.local_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.relyingparty().delete_account(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -177,22 +212,6 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "local-id" => { - request.local_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None @@ -214,8 +233,36 @@ impl Engine { fn _relyingparty_download_account(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::IdentitytoolkitRelyingpartyDownloadAccountRequest::default(); - let mut call = self.hub.relyingparty().download_account(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "next-page-token" => { + request.next_page_token = Some(value.unwrap_or("").to_string()); + }, + "max-results" => { + request.max_results = Some(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.relyingparty().download_account(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -237,25 +284,6 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "next-page-token" => { - request.next_page_token = Some(value.unwrap_or("").to_string()); - }, - "max-results" => { - request.max_results = Some(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None @@ -277,8 +305,45 @@ impl Engine { fn _relyingparty_get_account_info(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::IdentitytoolkitRelyingpartyGetAccountInfoRequest::default(); - let mut call = self.hub.relyingparty().get_account_info(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "id-token" => { + request.id_token = Some(value.unwrap_or("").to_string()); + }, + "email" => { + if request.email.is_none() { + request.email = Some(Default::default()); + } + request.email.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "local-id" => { + if request.local_id.is_none() { + request.local_id = Some(Default::default()); + } + request.local_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.relyingparty().get_account_info(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -300,34 +365,6 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "id-token" => { - request.id_token = Some(value.unwrap_or("").to_string()); - }, - "email" => { - if request.email.is_none() { - request.email = Some(Default::default()); - } - request.email.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "local-id" => { - if request.local_id.is_none() { - request.local_id = Some(Default::default()); - } - request.local_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None @@ -349,37 +386,24 @@ impl Engine { fn _relyingparty_get_oob_confirmation_code(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Relyingparty::default(); - let mut call = self.hub.relyingparty().get_oob_confirmation_code(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Relyingparty::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -405,10 +429,32 @@ impl Engine { request.captcha_resp = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.relyingparty().get_oob_confirmation_code(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None @@ -516,8 +562,42 @@ impl Engine { fn _relyingparty_reset_password(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::IdentitytoolkitRelyingpartyResetPasswordRequest::default(); - let mut call = self.hub.relyingparty().reset_password(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "new-password" => { + request.new_password = Some(value.unwrap_or("").to_string()); + }, + "old-password" => { + request.old_password = Some(value.unwrap_or("").to_string()); + }, + "oob-code" => { + request.oob_code = Some(value.unwrap_or("").to_string()); + }, + "email" => { + request.email = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.relyingparty().reset_password(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -539,31 +619,6 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "new-password" => { - request.new_password = Some(value.unwrap_or("").to_string()); - }, - "old-password" => { - request.old_password = Some(value.unwrap_or("").to_string()); - }, - "oob-code" => { - request.oob_code = Some(value.unwrap_or("").to_string()); - }, - "email" => { - request.email = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None @@ -585,37 +640,24 @@ impl Engine { fn _relyingparty_set_account_info(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::IdentitytoolkitRelyingpartySetAccountInfoRequest::default(); - let mut call = self.hub.relyingparty().set_account_info(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::IdentitytoolkitRelyingpartySetAccountInfoRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "display-name" => { request.display_name = Some(value.unwrap_or("").to_string()); }, @@ -653,10 +695,32 @@ impl Engine { request.email = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.relyingparty().set_account_info(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None @@ -678,8 +742,45 @@ impl Engine { fn _relyingparty_upload_account(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::IdentitytoolkitRelyingpartyUploadAccountRequest::default(); - let mut call = self.hub.relyingparty().upload_account(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "salt-separator" => { + request.salt_separator = Some(value.unwrap_or("").to_string()); + }, + "hash-algorithm" => { + request.hash_algorithm = Some(value.unwrap_or("").to_string()); + }, + "memory-cost" => { + request.memory_cost = Some(arg_from_str(value.unwrap_or("-0"), err, "memory-cost", "integer")); + }, + "signer-key" => { + request.signer_key = Some(value.unwrap_or("").to_string()); + }, + "rounds" => { + request.rounds = Some(arg_from_str(value.unwrap_or("-0"), err, "rounds", "integer")); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.relyingparty().upload_account(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -701,34 +802,6 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "salt-separator" => { - request.salt_separator = Some(value.unwrap_or("").to_string()); - }, - "hash-algorithm" => { - request.hash_algorithm = Some(value.unwrap_or("").to_string()); - }, - "memory-cost" => { - request.memory_cost = Some(arg_from_str(value.unwrap_or("-0"), err, "memory-cost", "integer")); - }, - "signer-key" => { - request.signer_key = Some(value.unwrap_or("").to_string()); - }, - "rounds" => { - request.rounds = Some(arg_from_str(value.unwrap_or("-0"), err, "rounds", "integer")); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None @@ -750,8 +823,42 @@ impl Engine { fn _relyingparty_verify_assertion(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::IdentitytoolkitRelyingpartyVerifyAssertionRequest::default(); - let mut call = self.hub.relyingparty().verify_assertion(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "request-uri" => { + request.request_uri = Some(value.unwrap_or("").to_string()); + }, + "post-body" => { + request.post_body = Some(value.unwrap_or("").to_string()); + }, + "return-refresh-token" => { + request.return_refresh_token = Some(arg_from_str(value.unwrap_or("false"), err, "return-refresh-token", "boolean")); + }, + "pending-id-token" => { + request.pending_id_token = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.relyingparty().verify_assertion(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -773,31 +880,6 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "request-uri" => { - request.request_uri = Some(value.unwrap_or("").to_string()); - }, - "post-body" => { - request.post_body = Some(value.unwrap_or("").to_string()); - }, - "return-refresh-token" => { - request.return_refresh_token = Some(arg_from_str(value.unwrap_or("false"), err, "return-refresh-token", "boolean")); - }, - "pending-id-token" => { - request.pending_id_token = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None @@ -819,8 +901,45 @@ impl Engine { fn _relyingparty_verify_password(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::IdentitytoolkitRelyingpartyVerifyPasswordRequest::default(); - let mut call = self.hub.relyingparty().verify_password(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "captcha-response" => { + request.captcha_response = Some(value.unwrap_or("").to_string()); + }, + "captcha-challenge" => { + request.captcha_challenge = Some(value.unwrap_or("").to_string()); + }, + "password" => { + request.password = Some(value.unwrap_or("").to_string()); + }, + "email" => { + request.email = Some(value.unwrap_or("").to_string()); + }, + "pending-id-token" => { + request.pending_id_token = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.relyingparty().verify_password(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -842,34 +961,6 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "captcha-response" => { - request.captcha_response = Some(value.unwrap_or("").to_string()); - }, - "captcha-challenge" => { - request.captcha_challenge = Some(value.unwrap_or("").to_string()); - }, - "password" => { - request.password = Some(value.unwrap_or("").to_string()); - }, - "email" => { - request.email = Some(value.unwrap_or("").to_string()); - }, - "pending-id-token" => { - request.pending_id_token = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None @@ -990,6 +1081,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -997,8 +1089,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/identitytoolkit3/Cargo.toml b/gen/identitytoolkit3/Cargo.toml index 989c8d4072..ce4fc4555d 100644 --- a/gen/identitytoolkit3/Cargo.toml +++ b/gen/identitytoolkit3/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-identitytoolkit3" -version = "0.1.5+20150406" +version = "0.1.6+20150406" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with Identity Toolkit (protocol v3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/identitytoolkit3" diff --git a/gen/identitytoolkit3/README.md b/gen/identitytoolkit3/README.md index 0c7a161ae7..669844d933 100644 --- a/gen/identitytoolkit3/README.md +++ b/gen/identitytoolkit3/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-identitytoolkit3` library allows access to all features of the *Google Identity Toolkit* service. -This documentation was generated from *Identity Toolkit* crate version *0.1.5+20150406*, where *20150406* is the exact revision of the *identitytoolkit:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *Identity Toolkit* crate version *0.1.6+20150406*, where *20150406* is the exact revision of the *identitytoolkit:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *Identity Toolkit* *v3* API can be found at the [official documentation site](https://developers.google.com/identity-toolkit/v3/). @@ -98,21 +98,22 @@ let mut req = IdentitytoolkitRelyingpartyVerifyAssertionRequest::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.relyingparty().verify_assertion(&req) +let result = hub.relyingparty().verify_assertion(req) .doit(); match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/identitytoolkit3/src/cmn.rs b/gen/identitytoolkit3/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/identitytoolkit3/src/cmn.rs +++ b/gen/identitytoolkit3/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/identitytoolkit3/src/lib.rs b/gen/identitytoolkit3/src/lib.rs index 83515bf7b1..6809eb25a1 100644 --- a/gen/identitytoolkit3/src/lib.rs +++ b/gen/identitytoolkit3/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Identity Toolkit* crate version *0.1.5+20150406*, where *20150406* is the exact revision of the *identitytoolkit:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *Identity Toolkit* crate version *0.1.6+20150406*, where *20150406* is the exact revision of the *identitytoolkit:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *Identity Toolkit* *v3* API can be found at the //! [official documentation site](https://developers.google.com/identity-toolkit/v3/). @@ -99,21 +99,22 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.relyingparty().verify_assertion(&req) +//! let result = hub.relyingparty().verify_assertion(req) //! .doit(); //! //! match result { //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -201,7 +202,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -252,21 +253,22 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.relyingparty().verify_assertion(&req) +/// let result = hub.relyingparty().verify_assertion(req) /// .doit(); /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -287,7 +289,7 @@ impl<'a, C, A> IdentityToolkit<C, A> IdentityToolkit { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -296,7 +298,7 @@ impl<'a, C, A> IdentityToolkit<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -1124,10 +1126,10 @@ impl<'a, C, A> RelyingpartyMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn get_oob_confirmation_code(&self, request: &Relyingparty) -> RelyingpartyGetOobConfirmationCodeCall<'a, C, A> { + pub fn get_oob_confirmation_code(&self, request: Relyingparty) -> RelyingpartyGetOobConfirmationCodeCall<'a, C, A> { RelyingpartyGetOobConfirmationCodeCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _additional_params: Default::default(), } @@ -1151,10 +1153,10 @@ impl<'a, C, A> RelyingpartyMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn create_auth_uri(&self, request: &IdentitytoolkitRelyingpartyCreateAuthUriRequest) -> RelyingpartyCreateAuthUriCall<'a, C, A> { + pub fn create_auth_uri(&self, request: IdentitytoolkitRelyingpartyCreateAuthUriRequest) -> RelyingpartyCreateAuthUriCall<'a, C, A> { RelyingpartyCreateAuthUriCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _additional_params: Default::default(), } @@ -1167,10 +1169,10 @@ impl<'a, C, A> RelyingpartyMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn verify_assertion(&self, request: &IdentitytoolkitRelyingpartyVerifyAssertionRequest) -> RelyingpartyVerifyAssertionCall<'a, C, A> { + pub fn verify_assertion(&self, request: IdentitytoolkitRelyingpartyVerifyAssertionRequest) -> RelyingpartyVerifyAssertionCall<'a, C, A> { RelyingpartyVerifyAssertionCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _additional_params: Default::default(), } @@ -1183,10 +1185,10 @@ impl<'a, C, A> RelyingpartyMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn upload_account(&self, request: &IdentitytoolkitRelyingpartyUploadAccountRequest) -> RelyingpartyUploadAccountCall<'a, C, A> { + pub fn upload_account(&self, request: IdentitytoolkitRelyingpartyUploadAccountRequest) -> RelyingpartyUploadAccountCall<'a, C, A> { RelyingpartyUploadAccountCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _additional_params: Default::default(), } @@ -1199,10 +1201,10 @@ impl<'a, C, A> RelyingpartyMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn get_account_info(&self, request: &IdentitytoolkitRelyingpartyGetAccountInfoRequest) -> RelyingpartyGetAccountInfoCall<'a, C, A> { + pub fn get_account_info(&self, request: IdentitytoolkitRelyingpartyGetAccountInfoRequest) -> RelyingpartyGetAccountInfoCall<'a, C, A> { RelyingpartyGetAccountInfoCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _additional_params: Default::default(), } @@ -1215,10 +1217,10 @@ impl<'a, C, A> RelyingpartyMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn reset_password(&self, request: &IdentitytoolkitRelyingpartyResetPasswordRequest) -> RelyingpartyResetPasswordCall<'a, C, A> { + pub fn reset_password(&self, request: IdentitytoolkitRelyingpartyResetPasswordRequest) -> RelyingpartyResetPasswordCall<'a, C, A> { RelyingpartyResetPasswordCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _additional_params: Default::default(), } @@ -1231,10 +1233,10 @@ impl<'a, C, A> RelyingpartyMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn download_account(&self, request: &IdentitytoolkitRelyingpartyDownloadAccountRequest) -> RelyingpartyDownloadAccountCall<'a, C, A> { + pub fn download_account(&self, request: IdentitytoolkitRelyingpartyDownloadAccountRequest) -> RelyingpartyDownloadAccountCall<'a, C, A> { RelyingpartyDownloadAccountCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _additional_params: Default::default(), } @@ -1247,10 +1249,10 @@ impl<'a, C, A> RelyingpartyMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn set_account_info(&self, request: &IdentitytoolkitRelyingpartySetAccountInfoRequest) -> RelyingpartySetAccountInfoCall<'a, C, A> { + pub fn set_account_info(&self, request: IdentitytoolkitRelyingpartySetAccountInfoRequest) -> RelyingpartySetAccountInfoCall<'a, C, A> { RelyingpartySetAccountInfoCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _additional_params: Default::default(), } @@ -1263,10 +1265,10 @@ impl<'a, C, A> RelyingpartyMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn delete_account(&self, request: &IdentitytoolkitRelyingpartyDeleteAccountRequest) -> RelyingpartyDeleteAccountCall<'a, C, A> { + pub fn delete_account(&self, request: IdentitytoolkitRelyingpartyDeleteAccountRequest) -> RelyingpartyDeleteAccountCall<'a, C, A> { RelyingpartyDeleteAccountCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _additional_params: Default::default(), } @@ -1290,10 +1292,10 @@ impl<'a, C, A> RelyingpartyMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn verify_password(&self, request: &IdentitytoolkitRelyingpartyVerifyPasswordRequest) -> RelyingpartyVerifyPasswordCall<'a, C, A> { + pub fn verify_password(&self, request: IdentitytoolkitRelyingpartyVerifyPasswordRequest) -> RelyingpartyVerifyPasswordCall<'a, C, A> { RelyingpartyVerifyPasswordCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _additional_params: Default::default(), } @@ -1340,7 +1342,7 @@ impl<'a, C, A> RelyingpartyMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.relyingparty().get_oob_confirmation_code(&req) +/// let result = hub.relyingparty().get_oob_confirmation_code(req) /// .doit(); /// # } /// ``` @@ -1435,12 +1437,17 @@ impl<'a, C, A> RelyingpartyGetOobConfirmationCodeCall<'a, C, A> where C: BorrowM if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1449,7 +1456,7 @@ impl<'a, C, A> RelyingpartyGetOobConfirmationCodeCall<'a, C, A> where C: BorrowM Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1467,8 +1474,8 @@ impl<'a, C, A> RelyingpartyGetOobConfirmationCodeCall<'a, C, A> where C: BorrowM /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Relyingparty) -> RelyingpartyGetOobConfirmationCodeCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Relyingparty) -> RelyingpartyGetOobConfirmationCodeCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -1619,12 +1626,17 @@ impl<'a, C, A> RelyingpartyGetPublicKeyCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1633,7 +1645,7 @@ impl<'a, C, A> RelyingpartyGetPublicKeyCall<'a, C, A> where C: BorrowMut<hyper:: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1714,7 +1726,7 @@ impl<'a, C, A> RelyingpartyGetPublicKeyCall<'a, C, A> where C: BorrowMut<hyper:: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.relyingparty().create_auth_uri(&req) +/// let result = hub.relyingparty().create_auth_uri(req) /// .doit(); /// # } /// ``` @@ -1809,12 +1821,17 @@ impl<'a, C, A> RelyingpartyCreateAuthUriCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1823,7 +1840,7 @@ impl<'a, C, A> RelyingpartyCreateAuthUriCall<'a, C, A> where C: BorrowMut<hyper: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1841,8 +1858,8 @@ impl<'a, C, A> RelyingpartyCreateAuthUriCall<'a, C, A> where C: BorrowMut<hyper: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &IdentitytoolkitRelyingpartyCreateAuthUriRequest) -> RelyingpartyCreateAuthUriCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: IdentitytoolkitRelyingpartyCreateAuthUriRequest) -> RelyingpartyCreateAuthUriCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -1913,7 +1930,7 @@ impl<'a, C, A> RelyingpartyCreateAuthUriCall<'a, C, A> where C: BorrowMut<hyper: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.relyingparty().verify_assertion(&req) +/// let result = hub.relyingparty().verify_assertion(req) /// .doit(); /// # } /// ``` @@ -2008,12 +2025,17 @@ impl<'a, C, A> RelyingpartyVerifyAssertionCall<'a, C, A> where C: BorrowMut<hype if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2022,7 +2044,7 @@ impl<'a, C, A> RelyingpartyVerifyAssertionCall<'a, C, A> where C: BorrowMut<hype Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2040,8 +2062,8 @@ impl<'a, C, A> RelyingpartyVerifyAssertionCall<'a, C, A> where C: BorrowMut<hype /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &IdentitytoolkitRelyingpartyVerifyAssertionRequest) -> RelyingpartyVerifyAssertionCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: IdentitytoolkitRelyingpartyVerifyAssertionRequest) -> RelyingpartyVerifyAssertionCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -2112,7 +2134,7 @@ impl<'a, C, A> RelyingpartyVerifyAssertionCall<'a, C, A> where C: BorrowMut<hype /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.relyingparty().upload_account(&req) +/// let result = hub.relyingparty().upload_account(req) /// .doit(); /// # } /// ``` @@ -2207,12 +2229,17 @@ impl<'a, C, A> RelyingpartyUploadAccountCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2221,7 +2248,7 @@ impl<'a, C, A> RelyingpartyUploadAccountCall<'a, C, A> where C: BorrowMut<hyper: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2239,8 +2266,8 @@ impl<'a, C, A> RelyingpartyUploadAccountCall<'a, C, A> where C: BorrowMut<hyper: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &IdentitytoolkitRelyingpartyUploadAccountRequest) -> RelyingpartyUploadAccountCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: IdentitytoolkitRelyingpartyUploadAccountRequest) -> RelyingpartyUploadAccountCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -2311,7 +2338,7 @@ impl<'a, C, A> RelyingpartyUploadAccountCall<'a, C, A> where C: BorrowMut<hyper: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.relyingparty().get_account_info(&req) +/// let result = hub.relyingparty().get_account_info(req) /// .doit(); /// # } /// ``` @@ -2406,12 +2433,17 @@ impl<'a, C, A> RelyingpartyGetAccountInfoCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2420,7 +2452,7 @@ impl<'a, C, A> RelyingpartyGetAccountInfoCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2438,8 +2470,8 @@ impl<'a, C, A> RelyingpartyGetAccountInfoCall<'a, C, A> where C: BorrowMut<hyper /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &IdentitytoolkitRelyingpartyGetAccountInfoRequest) -> RelyingpartyGetAccountInfoCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: IdentitytoolkitRelyingpartyGetAccountInfoRequest) -> RelyingpartyGetAccountInfoCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -2510,7 +2542,7 @@ impl<'a, C, A> RelyingpartyGetAccountInfoCall<'a, C, A> where C: BorrowMut<hyper /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.relyingparty().reset_password(&req) +/// let result = hub.relyingparty().reset_password(req) /// .doit(); /// # } /// ``` @@ -2605,12 +2637,17 @@ impl<'a, C, A> RelyingpartyResetPasswordCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2619,7 +2656,7 @@ impl<'a, C, A> RelyingpartyResetPasswordCall<'a, C, A> where C: BorrowMut<hyper: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2637,8 +2674,8 @@ impl<'a, C, A> RelyingpartyResetPasswordCall<'a, C, A> where C: BorrowMut<hyper: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &IdentitytoolkitRelyingpartyResetPasswordRequest) -> RelyingpartyResetPasswordCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: IdentitytoolkitRelyingpartyResetPasswordRequest) -> RelyingpartyResetPasswordCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -2709,7 +2746,7 @@ impl<'a, C, A> RelyingpartyResetPasswordCall<'a, C, A> where C: BorrowMut<hyper: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.relyingparty().download_account(&req) +/// let result = hub.relyingparty().download_account(req) /// .doit(); /// # } /// ``` @@ -2804,12 +2841,17 @@ impl<'a, C, A> RelyingpartyDownloadAccountCall<'a, C, A> where C: BorrowMut<hype if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2818,7 +2860,7 @@ impl<'a, C, A> RelyingpartyDownloadAccountCall<'a, C, A> where C: BorrowMut<hype Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2836,8 +2878,8 @@ impl<'a, C, A> RelyingpartyDownloadAccountCall<'a, C, A> where C: BorrowMut<hype /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &IdentitytoolkitRelyingpartyDownloadAccountRequest) -> RelyingpartyDownloadAccountCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: IdentitytoolkitRelyingpartyDownloadAccountRequest) -> RelyingpartyDownloadAccountCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -2908,7 +2950,7 @@ impl<'a, C, A> RelyingpartyDownloadAccountCall<'a, C, A> where C: BorrowMut<hype /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.relyingparty().set_account_info(&req) +/// let result = hub.relyingparty().set_account_info(req) /// .doit(); /// # } /// ``` @@ -3003,12 +3045,17 @@ impl<'a, C, A> RelyingpartySetAccountInfoCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3017,7 +3064,7 @@ impl<'a, C, A> RelyingpartySetAccountInfoCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3035,8 +3082,8 @@ impl<'a, C, A> RelyingpartySetAccountInfoCall<'a, C, A> where C: BorrowMut<hyper /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &IdentitytoolkitRelyingpartySetAccountInfoRequest) -> RelyingpartySetAccountInfoCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: IdentitytoolkitRelyingpartySetAccountInfoRequest) -> RelyingpartySetAccountInfoCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -3107,7 +3154,7 @@ impl<'a, C, A> RelyingpartySetAccountInfoCall<'a, C, A> where C: BorrowMut<hyper /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.relyingparty().delete_account(&req) +/// let result = hub.relyingparty().delete_account(req) /// .doit(); /// # } /// ``` @@ -3202,12 +3249,17 @@ impl<'a, C, A> RelyingpartyDeleteAccountCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3216,7 +3268,7 @@ impl<'a, C, A> RelyingpartyDeleteAccountCall<'a, C, A> where C: BorrowMut<hyper: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3234,8 +3286,8 @@ impl<'a, C, A> RelyingpartyDeleteAccountCall<'a, C, A> where C: BorrowMut<hyper: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &IdentitytoolkitRelyingpartyDeleteAccountRequest) -> RelyingpartyDeleteAccountCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: IdentitytoolkitRelyingpartyDeleteAccountRequest) -> RelyingpartyDeleteAccountCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -3386,12 +3438,17 @@ impl<'a, C, A> RelyingpartyGetRecaptchaParamCall<'a, C, A> where C: BorrowMut<hy if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3400,7 +3457,7 @@ impl<'a, C, A> RelyingpartyGetRecaptchaParamCall<'a, C, A> where C: BorrowMut<hy Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3481,7 +3538,7 @@ impl<'a, C, A> RelyingpartyGetRecaptchaParamCall<'a, C, A> where C: BorrowMut<hy /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.relyingparty().verify_password(&req) +/// let result = hub.relyingparty().verify_password(req) /// .doit(); /// # } /// ``` @@ -3576,12 +3633,17 @@ impl<'a, C, A> RelyingpartyVerifyPasswordCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3590,7 +3652,7 @@ impl<'a, C, A> RelyingpartyVerifyPasswordCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3608,8 +3670,8 @@ impl<'a, C, A> RelyingpartyVerifyPasswordCall<'a, C, A> where C: BorrowMut<hyper /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &IdentitytoolkitRelyingpartyVerifyPasswordRequest) -> RelyingpartyVerifyPasswordCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: IdentitytoolkitRelyingpartyVerifyPasswordRequest) -> RelyingpartyVerifyPasswordCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong diff --git a/gen/licensing1-cli/Cargo.toml b/gen/licensing1-cli/Cargo.toml index 20cce1b59d..bc5ae86f85 100644 --- a/gen/licensing1-cli/Cargo.toml +++ b/gen/licensing1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-licensing1-cli" -version = "0.0.1+20140122" +version = "0.1.0+20140122" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with licensing (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/licensing1-cli" diff --git a/gen/licensing1-cli/README.md b/gen/licensing1-cli/README.md index 151f81a044..b18703ddfa 100644 --- a/gen/licensing1-cli/README.md +++ b/gen/licensing1-cli/README.md @@ -1,4 +1,108 @@ -# HELLO LICENSING:V1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `licensing1` command-line interface *(CLI)* allows to use most features of the *Google licensing* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *licensing* API at revision *20140122*. The CLI is at version *0.1.0*. + +```bash + licensing1 [options] license-assignments delete <product-id> <sku-id> <user-id> [-p <v>...] + licensing1 [options] license-assignments get <product-id> <sku-id> <user-id> [-p <v>...] [-o <out>] + licensing1 [options] license-assignments insert <product-id> <sku-id> -r <kv>... [-p <v>...] [-o <out>] + licensing1 [options] license-assignments list-for-product <product-id> <customer-id> [-p <v>...] [-o <out>] + licensing1 [options] license-assignments list-for-product-and-sku <product-id> <sku-id> <customer-id> [-p <v>...] [-o <out>] + licensing1 [options] license-assignments patch <product-id> <sku-id> <user-id> -r <kv>... [-p <v>...] [-o <out>] + licensing1 [options] license-assignments update <product-id> <sku-id> <user-id> -r <kv>... [-p <v>...] [-o <out>] + licensing1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_licensing1_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `licensing1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/licensing1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/licensing1-secret.json`, assuming that the required *licensing* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `licensing1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/licensing1-cli/mkdocs.yml b/gen/licensing1-cli/mkdocs.yml index f8359a9795..0dc62eb6b1 100644 --- a/gen/licensing1-cli/mkdocs.yml +++ b/gen/licensing1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: licensing v0.0.1+20140122 +site_name: licensing v0.1.0+20140122 site_url: http://byron.github.io/google-apis-rs/google-licensing1-cli site_description: Write integrating applications with bcore diff --git a/gen/licensing1-cli/src/cmn.rs b/gen/licensing1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/licensing1-cli/src/cmn.rs +++ b/gen/licensing1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/licensing1-cli/src/main.rs b/gen/licensing1-cli/src/main.rs index a2d085e819..76574916d0 100644 --- a/gen/licensing1-cli/src/main.rs +++ b/gen/licensing1-cli/src/main.rs @@ -19,32 +19,33 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - licensing1 [options] license-assignments delete <product-id> <sku-id> <user-id> [-p <v>]... - licensing1 [options] license-assignments get <product-id> <sku-id> <user-id> [-p <v>]... [-o <out>] - licensing1 [options] license-assignments insert <product-id> <sku-id> -r <kv>... [-p <v>]... [-o <out>] - licensing1 [options] license-assignments list-for-product <product-id> <customer-id> [-p <v>]... [-o <out>] - licensing1 [options] license-assignments list-for-product-and-sku <product-id> <sku-id> <customer-id> [-p <v>]... [-o <out>] - licensing1 [options] license-assignments patch <product-id> <sku-id> <user-id> -r <kv>... [-p <v>]... [-o <out>] - licensing1 [options] license-assignments update <product-id> <sku-id> <user-id> -r <kv>... [-p <v>]... [-o <out>] + licensing1 [options] license-assignments delete <product-id> <sku-id> <user-id> [-p <v>...] + licensing1 [options] license-assignments get <product-id> <sku-id> <user-id> [-p <v>...] [-o <out>] + licensing1 [options] license-assignments insert <product-id> <sku-id> -r <kv>... [-p <v>...] [-o <out>] + licensing1 [options] license-assignments list-for-product <product-id> <customer-id> [-p <v>...] [-o <out>] + licensing1 [options] license-assignments list-for-product-and-sku <product-id> <sku-id> <customer-id> [-p <v>...] [-o <out>] + licensing1 [options] license-assignments patch <product-id> <sku-id> <user-id> -r <kv>... [-p <v>...] [-o <out>] + licensing1 [options] license-assignments update <product-id> <sku-id> <user-id> -r <kv>... [-p <v>...] [-o <out>] licensing1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_licensing1_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -93,6 +94,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -134,6 +138,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -150,8 +157,33 @@ impl Engine { fn _license_assignments_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::LicenseAssignmentInsert::default(); - let mut call = self.hub.license_assignments().insert(&request, &self.opt.arg_product_id, &self.opt.arg_sku_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "user-id" => { + request.user_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.license_assignments().insert(request, &self.opt.arg_product_id, &self.opt.arg_sku_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -173,27 +205,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "user-id" => { - request.user_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -243,6 +262,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -292,6 +314,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -308,8 +333,48 @@ impl Engine { fn _license_assignments_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::LicenseAssignment::default(); - let mut call = self.hub.license_assignments().patch(&request, &self.opt.arg_product_id, &self.opt.arg_sku_id, &self.opt.arg_user_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "sku-id" => { + request.sku_id = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "user-id" => { + request.user_id = Some(value.unwrap_or("").to_string()); + }, + "etags" => { + request.etags = Some(value.unwrap_or("").to_string()); + }, + "self-link" => { + request.self_link = Some(value.unwrap_or("").to_string()); + }, + "product-id" => { + request.product_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.license_assignments().patch(request, &self.opt.arg_product_id, &self.opt.arg_sku_id, &self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -331,42 +396,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "sku-id" => { - request.sku_id = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "user-id" => { - request.user_id = Some(value.unwrap_or("").to_string()); - }, - "etags" => { - request.etags = Some(value.unwrap_or("").to_string()); - }, - "self-link" => { - request.self_link = Some(value.unwrap_or("").to_string()); - }, - "product-id" => { - request.product_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -383,8 +420,48 @@ impl Engine { fn _license_assignments_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::LicenseAssignment::default(); - let mut call = self.hub.license_assignments().update(&request, &self.opt.arg_product_id, &self.opt.arg_sku_id, &self.opt.arg_user_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "sku-id" => { + request.sku_id = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "user-id" => { + request.user_id = Some(value.unwrap_or("").to_string()); + }, + "etags" => { + request.etags = Some(value.unwrap_or("").to_string()); + }, + "self-link" => { + request.self_link = Some(value.unwrap_or("").to_string()); + }, + "product-id" => { + request.product_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.license_assignments().update(request, &self.opt.arg_product_id, &self.opt.arg_sku_id, &self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -406,42 +483,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "sku-id" => { - request.sku_id = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "user-id" => { - request.user_id = Some(value.unwrap_or("").to_string()); - }, - "etags" => { - request.etags = Some(value.unwrap_or("").to_string()); - }, - "self-link" => { - request.self_link = Some(value.unwrap_or("").to_string()); - }, - "product-id" => { - request.product_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -547,6 +596,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -554,8 +604,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/licensing1/Cargo.toml b/gen/licensing1/Cargo.toml index e336d0683b..eead844319 100644 --- a/gen/licensing1/Cargo.toml +++ b/gen/licensing1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-licensing1" -version = "0.1.5+20140122" +version = "0.1.6+20140122" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with licensing (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/licensing1" diff --git a/gen/licensing1/README.md b/gen/licensing1/README.md index 3b91067b3c..a191f36a2e 100644 --- a/gen/licensing1/README.md +++ b/gen/licensing1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-licensing1` library allows access to all features of the *Google licensing* service. -This documentation was generated from *licensing* crate version *0.1.5+20140122*, where *20140122* is the exact revision of the *licensing:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *licensing* crate version *0.1.6+20140122*, where *20140122* is the exact revision of the *licensing:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *licensing* *v1* API can be found at the [official documentation site](https://developers.google.com/google-apps/licensing/). @@ -107,14 +107,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/licensing1/src/cmn.rs b/gen/licensing1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/licensing1/src/cmn.rs +++ b/gen/licensing1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/licensing1/src/lib.rs b/gen/licensing1/src/lib.rs index 01f374d12e..2a4ad91a64 100644 --- a/gen/licensing1/src/lib.rs +++ b/gen/licensing1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *licensing* crate version *0.1.5+20140122*, where *20140122* is the exact revision of the *licensing:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *licensing* crate version *0.1.6+20140122*, where *20140122* is the exact revision of the *licensing:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *licensing* *v1* API can be found at the //! [official documentation site](https://developers.google.com/google-apps/licensing/). @@ -108,14 +108,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -203,7 +204,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -279,14 +280,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -307,7 +309,7 @@ impl<'a, C, A> Licensing<C, A> Licensing { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -316,7 +318,7 @@ impl<'a, C, A> Licensing<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -554,10 +556,10 @@ impl<'a, C, A> LicenseAssignmentMethods<'a, C, A> { /// * `productId` - Name for product /// * `skuId` - Name for sku for which license would be revoked /// * `userId` - email id or unique Id of the user - pub fn update(&self, request: &LicenseAssignment, product_id: &str, sku_id: &str, user_id: &str) -> LicenseAssignmentUpdateCall<'a, C, A> { + pub fn update(&self, request: LicenseAssignment, product_id: &str, sku_id: &str, user_id: &str) -> LicenseAssignmentUpdateCall<'a, C, A> { LicenseAssignmentUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _product_id: product_id.to_string(), _sku_id: sku_id.to_string(), _user_id: user_id.to_string(), @@ -577,10 +579,10 @@ impl<'a, C, A> LicenseAssignmentMethods<'a, C, A> { /// * `productId` - Name for product /// * `skuId` - Name for sku for which license would be revoked /// * `userId` - email id or unique Id of the user - pub fn patch(&self, request: &LicenseAssignment, product_id: &str, sku_id: &str, user_id: &str) -> LicenseAssignmentPatchCall<'a, C, A> { + pub fn patch(&self, request: LicenseAssignment, product_id: &str, sku_id: &str, user_id: &str) -> LicenseAssignmentPatchCall<'a, C, A> { LicenseAssignmentPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _product_id: product_id.to_string(), _sku_id: sku_id.to_string(), _user_id: user_id.to_string(), @@ -599,10 +601,10 @@ impl<'a, C, A> LicenseAssignmentMethods<'a, C, A> { /// * `request` - No description provided. /// * `productId` - Name for product /// * `skuId` - Name for sku - pub fn insert(&self, request: &LicenseAssignmentInsert, product_id: &str, sku_id: &str) -> LicenseAssignmentInsertCall<'a, C, A> { + pub fn insert(&self, request: LicenseAssignmentInsert, product_id: &str, sku_id: &str) -> LicenseAssignmentInsertCall<'a, C, A> { LicenseAssignmentInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _product_id: product_id.to_string(), _sku_id: sku_id.to_string(), _delegate: Default::default(), @@ -768,12 +770,17 @@ impl<'a, C, A> LicenseAssignmentDeleteCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -1024,12 +1031,17 @@ impl<'a, C, A> LicenseAssignmentListForProductCall<'a, C, A> where C: BorrowMut< if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1038,7 +1050,7 @@ impl<'a, C, A> LicenseAssignmentListForProductCall<'a, C, A> where C: BorrowMut< Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1286,12 +1298,17 @@ impl<'a, C, A> LicenseAssignmentGetCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1300,7 +1317,7 @@ impl<'a, C, A> LicenseAssignmentGetCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1554,12 +1571,17 @@ impl<'a, C, A> LicenseAssignmentListForProductAndSkuCall<'a, C, A> where C: Borr if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1568,7 +1590,7 @@ impl<'a, C, A> LicenseAssignmentListForProductAndSkuCall<'a, C, A> where C: Borr Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1709,7 +1731,7 @@ impl<'a, C, A> LicenseAssignmentListForProductAndSkuCall<'a, C, A> where C: Borr /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.license_assignments().update(&req, "productId", "skuId", "userId") +/// let result = hub.license_assignments().update(req, "productId", "skuId", "userId") /// .doit(); /// # } /// ``` @@ -1841,12 +1863,17 @@ impl<'a, C, A> LicenseAssignmentUpdateCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1855,7 +1882,7 @@ impl<'a, C, A> LicenseAssignmentUpdateCall<'a, C, A> where C: BorrowMut<hyper::C Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1873,8 +1900,8 @@ impl<'a, C, A> LicenseAssignmentUpdateCall<'a, C, A> where C: BorrowMut<hyper::C /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &LicenseAssignment) -> LicenseAssignmentUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: LicenseAssignment) -> LicenseAssignmentUpdateCall<'a, C, A> { + self._request = new_value; self } /// Name for product @@ -1991,7 +2018,7 @@ impl<'a, C, A> LicenseAssignmentUpdateCall<'a, C, A> where C: BorrowMut<hyper::C /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.license_assignments().patch(&req, "productId", "skuId", "userId") +/// let result = hub.license_assignments().patch(req, "productId", "skuId", "userId") /// .doit(); /// # } /// ``` @@ -2123,12 +2150,17 @@ impl<'a, C, A> LicenseAssignmentPatchCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2137,7 +2169,7 @@ impl<'a, C, A> LicenseAssignmentPatchCall<'a, C, A> where C: BorrowMut<hyper::Cl Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2155,8 +2187,8 @@ impl<'a, C, A> LicenseAssignmentPatchCall<'a, C, A> where C: BorrowMut<hyper::Cl /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &LicenseAssignment) -> LicenseAssignmentPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: LicenseAssignment) -> LicenseAssignmentPatchCall<'a, C, A> { + self._request = new_value; self } /// Name for product @@ -2273,7 +2305,7 @@ impl<'a, C, A> LicenseAssignmentPatchCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.license_assignments().insert(&req, "productId", "skuId") +/// let result = hub.license_assignments().insert(req, "productId", "skuId") /// .doit(); /// # } /// ``` @@ -2403,12 +2435,17 @@ impl<'a, C, A> LicenseAssignmentInsertCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2417,7 +2454,7 @@ impl<'a, C, A> LicenseAssignmentInsertCall<'a, C, A> where C: BorrowMut<hyper::C Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2435,8 +2472,8 @@ impl<'a, C, A> LicenseAssignmentInsertCall<'a, C, A> where C: BorrowMut<hyper::C /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &LicenseAssignmentInsert) -> LicenseAssignmentInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: LicenseAssignmentInsert) -> LicenseAssignmentInsertCall<'a, C, A> { + self._request = new_value; self } /// Name for product diff --git a/gen/logging1_beta3-cli/Cargo.toml b/gen/logging1_beta3-cli/Cargo.toml index 768bbcf10d..dd03fc9d31 100644 --- a/gen/logging1_beta3-cli/Cargo.toml +++ b/gen/logging1_beta3-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-logging1_beta3-cli" -version = "0.0.1+20150326" +version = "0.1.0+20150326" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with logging (protocol v1beta3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/logging1_beta3-cli" diff --git a/gen/logging1_beta3-cli/README.md b/gen/logging1_beta3-cli/README.md index 205b79138c..a66499aaa5 100644 --- a/gen/logging1_beta3-cli/README.md +++ b/gen/logging1_beta3-cli/README.md @@ -1,4 +1,116 @@ -# HELLO LOGGING:V1BETA3 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `logging1-beta3` command-line interface *(CLI)* allows to use most features of the *Google logging* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *logging* API at revision *20150326*. The CLI is at version *0.1.0*. + +```bash + logging1-beta3 [options] projects log-services-indexes-list <projects-id> <log-services-id> [-p <v>...] [-o <out>] + logging1-beta3 [options] projects log-services-list <projects-id> [-p <v>...] [-o <out>] + logging1-beta3 [options] projects log-services-sinks-create <projects-id> <log-services-id> -r <kv>... [-p <v>...] [-o <out>] + logging1-beta3 [options] projects log-services-sinks-delete <projects-id> <log-services-id> <sinks-id> [-p <v>...] [-o <out>] + logging1-beta3 [options] projects log-services-sinks-get <projects-id> <log-services-id> <sinks-id> [-p <v>...] [-o <out>] + logging1-beta3 [options] projects log-services-sinks-list <projects-id> <log-services-id> [-p <v>...] [-o <out>] + logging1-beta3 [options] projects log-services-sinks-update <projects-id> <log-services-id> <sinks-id> -r <kv>... [-p <v>...] [-o <out>] + logging1-beta3 [options] projects logs-delete <projects-id> <logs-id> [-p <v>...] [-o <out>] + logging1-beta3 [options] projects logs-entries-write <projects-id> <logs-id> -r <kv>... [-p <v>...] [-o <out>] + logging1-beta3 [options] projects logs-list <projects-id> [-p <v>...] [-o <out>] + logging1-beta3 [options] projects logs-sinks-create <projects-id> <logs-id> -r <kv>... [-p <v>...] [-o <out>] + logging1-beta3 [options] projects logs-sinks-delete <projects-id> <logs-id> <sinks-id> [-p <v>...] [-o <out>] + logging1-beta3 [options] projects logs-sinks-get <projects-id> <logs-id> <sinks-id> [-p <v>...] [-o <out>] + logging1-beta3 [options] projects logs-sinks-list <projects-id> <logs-id> [-p <v>...] [-o <out>] + logging1-beta3 [options] projects logs-sinks-update <projects-id> <logs-id> <sinks-id> -r <kv>... [-p <v>...] [-o <out>] + logging1-beta3 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_logging1_beta3_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `logging1-beta3-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/logging1-beta3-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/logging1-beta3-secret.json`, assuming that the required *logging* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `logging1-beta3 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/logging1_beta3-cli/mkdocs.yml b/gen/logging1_beta3-cli/mkdocs.yml index 942f91e6da..596283d2b5 100644 --- a/gen/logging1_beta3-cli/mkdocs.yml +++ b/gen/logging1_beta3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: logging v0.0.1+20150326 +site_name: logging v0.1.0+20150326 site_url: http://byron.github.io/google-apis-rs/google-logging1_beta3-cli site_description: Write integrating applications with bcore diff --git a/gen/logging1_beta3-cli/src/cmn.rs b/gen/logging1_beta3-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/logging1_beta3-cli/src/cmn.rs +++ b/gen/logging1_beta3-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/logging1_beta3-cli/src/main.rs b/gen/logging1_beta3-cli/src/main.rs index 90723e6595..2d42401238 100644 --- a/gen/logging1_beta3-cli/src/main.rs +++ b/gen/logging1_beta3-cli/src/main.rs @@ -19,40 +19,41 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - logging1-beta3 [options] projects log-services-indexes-list <projects-id> <log-services-id> [-p <v>]... [-o <out>] - logging1-beta3 [options] projects log-services-list <projects-id> [-p <v>]... [-o <out>] - logging1-beta3 [options] projects log-services-sinks-create <projects-id> <log-services-id> -r <kv>... [-p <v>]... [-o <out>] - logging1-beta3 [options] projects log-services-sinks-delete <projects-id> <log-services-id> <sinks-id> [-p <v>]... [-o <out>] - logging1-beta3 [options] projects log-services-sinks-get <projects-id> <log-services-id> <sinks-id> [-p <v>]... [-o <out>] - logging1-beta3 [options] projects log-services-sinks-list <projects-id> <log-services-id> [-p <v>]... [-o <out>] - logging1-beta3 [options] projects log-services-sinks-update <projects-id> <log-services-id> <sinks-id> -r <kv>... [-p <v>]... [-o <out>] - logging1-beta3 [options] projects logs-delete <projects-id> <logs-id> [-p <v>]... [-o <out>] - logging1-beta3 [options] projects logs-entries-write <projects-id> <logs-id> -r <kv>... [-p <v>]... [-o <out>] - logging1-beta3 [options] projects logs-list <projects-id> [-p <v>]... [-o <out>] - logging1-beta3 [options] projects logs-sinks-create <projects-id> <logs-id> -r <kv>... [-p <v>]... [-o <out>] - logging1-beta3 [options] projects logs-sinks-delete <projects-id> <logs-id> <sinks-id> [-p <v>]... [-o <out>] - logging1-beta3 [options] projects logs-sinks-get <projects-id> <logs-id> <sinks-id> [-p <v>]... [-o <out>] - logging1-beta3 [options] projects logs-sinks-list <projects-id> <logs-id> [-p <v>]... [-o <out>] - logging1-beta3 [options] projects logs-sinks-update <projects-id> <logs-id> <sinks-id> -r <kv>... [-p <v>]... [-o <out>] + logging1-beta3 [options] projects log-services-indexes-list <projects-id> <log-services-id> [-p <v>...] [-o <out>] + logging1-beta3 [options] projects log-services-list <projects-id> [-p <v>...] [-o <out>] + logging1-beta3 [options] projects log-services-sinks-create <projects-id> <log-services-id> -r <kv>... [-p <v>...] [-o <out>] + logging1-beta3 [options] projects log-services-sinks-delete <projects-id> <log-services-id> <sinks-id> [-p <v>...] [-o <out>] + logging1-beta3 [options] projects log-services-sinks-get <projects-id> <log-services-id> <sinks-id> [-p <v>...] [-o <out>] + logging1-beta3 [options] projects log-services-sinks-list <projects-id> <log-services-id> [-p <v>...] [-o <out>] + logging1-beta3 [options] projects log-services-sinks-update <projects-id> <log-services-id> <sinks-id> -r <kv>... [-p <v>...] [-o <out>] + logging1-beta3 [options] projects logs-delete <projects-id> <logs-id> [-p <v>...] [-o <out>] + logging1-beta3 [options] projects logs-entries-write <projects-id> <logs-id> -r <kv>... [-p <v>...] [-o <out>] + logging1-beta3 [options] projects logs-list <projects-id> [-p <v>...] [-o <out>] + logging1-beta3 [options] projects logs-sinks-create <projects-id> <logs-id> -r <kv>... [-p <v>...] [-o <out>] + logging1-beta3 [options] projects logs-sinks-delete <projects-id> <logs-id> <sinks-id> [-p <v>...] [-o <out>] + logging1-beta3 [options] projects logs-sinks-get <projects-id> <logs-id> <sinks-id> [-p <v>...] [-o <out>] + logging1-beta3 [options] projects logs-sinks-list <projects-id> <logs-id> [-p <v>...] [-o <out>] + logging1-beta3 [options] projects logs-sinks-update <projects-id> <logs-id> <sinks-id> -r <kv>... [-p <v>...] [-o <out>] logging1-beta3 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_logging1_beta3_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -122,6 +123,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -180,6 +184,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -196,8 +203,36 @@ impl Engine { fn _projects_log_services_sinks_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::LogSink::default(); - let mut call = self.hub.projects().log_services_sinks_create(&request, &self.opt.arg_projects_id, &self.opt.arg_log_services_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "destination" => { + request.destination = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.projects().log_services_sinks_create(request, &self.opt.arg_projects_id, &self.opt.arg_log_services_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -225,30 +260,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "destination" => { - request.destination = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -298,6 +317,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -347,6 +369,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -396,6 +421,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -412,8 +440,36 @@ impl Engine { fn _projects_log_services_sinks_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::LogSink::default(); - let mut call = self.hub.projects().log_services_sinks_update(&request, &self.opt.arg_projects_id, &self.opt.arg_log_services_id, &self.opt.arg_sinks_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "destination" => { + request.destination = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.projects().log_services_sinks_update(request, &self.opt.arg_projects_id, &self.opt.arg_log_services_id, &self.opt.arg_sinks_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -441,30 +497,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "destination" => { - request.destination = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -514,6 +554,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -530,8 +573,37 @@ impl Engine { fn _projects_logs_entries_write(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::WriteLogEntriesRequest::default(); - let mut call = self.hub.projects().logs_entries_write(&request, &self.opt.arg_projects_id, &self.opt.arg_logs_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "common-labels" => { + if request.common_labels.is_none() { + request.common_labels = Some(Default::default()); + } + let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); + request.common_labels.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.projects().logs_entries_write(request, &self.opt.arg_projects_id, &self.opt.arg_logs_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -559,31 +631,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "common-labels" => { - if request.common_labels.is_none() { - request.common_labels = Some(Default::default()); - } - let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); - request.common_labels.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -645,6 +700,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -661,8 +719,36 @@ impl Engine { fn _projects_logs_sinks_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::LogSink::default(); - let mut call = self.hub.projects().logs_sinks_create(&request, &self.opt.arg_projects_id, &self.opt.arg_logs_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "destination" => { + request.destination = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.projects().logs_sinks_create(request, &self.opt.arg_projects_id, &self.opt.arg_logs_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -690,30 +776,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "destination" => { - request.destination = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -763,6 +833,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -812,6 +885,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -861,6 +937,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -877,8 +956,36 @@ impl Engine { fn _projects_logs_sinks_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::LogSink::default(); - let mut call = self.hub.projects().logs_sinks_update(&request, &self.opt.arg_projects_id, &self.opt.arg_logs_id, &self.opt.arg_sinks_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "destination" => { + request.destination = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.projects().logs_sinks_update(request, &self.opt.arg_projects_id, &self.opt.arg_logs_id, &self.opt.arg_sinks_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -906,30 +1013,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "destination" => { - request.destination = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1051,6 +1142,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -1058,8 +1150,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/logging1_beta3/Cargo.toml b/gen/logging1_beta3/Cargo.toml index 86c8dc7a6d..5cde36102d 100644 --- a/gen/logging1_beta3/Cargo.toml +++ b/gen/logging1_beta3/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-logging1_beta3" -version = "0.1.5+20150326" +version = "0.1.6+20150326" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with logging (protocol v1beta3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/logging1_beta3" diff --git a/gen/logging1_beta3/README.md b/gen/logging1_beta3/README.md index 4f6ab7503c..97cfcd6d8a 100644 --- a/gen/logging1_beta3/README.md +++ b/gen/logging1_beta3/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-logging1_beta3` library allows access to all features of the *Google logging* service. -This documentation was generated from *logging* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *logging:v1beta3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *logging* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *logging:v1beta3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. # Features Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_logging1_beta3/struct.Logging.html) ... @@ -100,21 +100,22 @@ let mut req = LogSink::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.projects().log_services_sinks_update(&req, "projectsId", "logServicesId", "sinksId") +let result = hub.projects().log_services_sinks_update(req, "projectsId", "logServicesId", "sinksId") .doit(); match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/logging1_beta3/src/cmn.rs b/gen/logging1_beta3/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/logging1_beta3/src/cmn.rs +++ b/gen/logging1_beta3/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/logging1_beta3/src/lib.rs b/gen/logging1_beta3/src/lib.rs index d4107a7561..fd3fcda196 100644 --- a/gen/logging1_beta3/src/lib.rs +++ b/gen/logging1_beta3/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *logging* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *logging:v1beta3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *logging* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *logging:v1beta3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/logging1_beta3). //! # Features //! @@ -101,21 +101,22 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.projects().log_services_sinks_update(&req, "projectsId", "logServicesId", "sinksId") +//! let result = hub.projects().log_services_sinks_update(req, "projectsId", "logServicesId", "sinksId") //! .doit(); //! //! match result { //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -203,7 +204,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -276,21 +277,22 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.projects().log_services_sinks_update(&req, "projectsId", "logServicesId", "sinksId") +/// let result = hub.projects().log_services_sinks_update(req, "projectsId", "logServicesId", "sinksId") /// .doit(); /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -311,7 +313,7 @@ impl<'a, C, A> Logging<C, A> Logging { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -320,7 +322,7 @@ impl<'a, C, A> Logging<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -758,10 +760,10 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// * `projectsId` - Part of `sinkName`. The name of the sink to update. /// * `logServicesId` - Part of `sinkName`. See documentation of `projectsId`. /// * `sinksId` - Part of `sinkName`. See documentation of `projectsId`. - pub fn log_services_sinks_update(&self, request: &LogSink, projects_id: &str, log_services_id: &str, sinks_id: &str) -> ProjectLogServiceSinkUpdateCall<'a, C, A> { + pub fn log_services_sinks_update(&self, request: LogSink, projects_id: &str, log_services_id: &str, sinks_id: &str) -> ProjectLogServiceSinkUpdateCall<'a, C, A> { ProjectLogServiceSinkUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _projects_id: projects_id.to_string(), _log_services_id: log_services_id.to_string(), _sinks_id: sinks_id.to_string(), @@ -780,10 +782,10 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// * `request` - No description provided. /// * `projectsId` - Part of `logName`. The name of the log resource into which to insert the log entries. /// * `logsId` - Part of `logName`. See documentation of `projectsId`. - pub fn logs_entries_write(&self, request: &WriteLogEntriesRequest, projects_id: &str, logs_id: &str) -> ProjectLogEntryWriteCall<'a, C, A> { + pub fn logs_entries_write(&self, request: WriteLogEntriesRequest, projects_id: &str, logs_id: &str) -> ProjectLogEntryWriteCall<'a, C, A> { ProjectLogEntryWriteCall { hub: self.hub, - _request: request.clone(), + _request: request, _projects_id: projects_id.to_string(), _logs_id: logs_id.to_string(), _delegate: Default::default(), @@ -866,10 +868,10 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// * `projectsId` - Part of `sinkName`. The name of the sink to update. /// * `logsId` - Part of `sinkName`. See documentation of `projectsId`. /// * `sinksId` - Part of `sinkName`. See documentation of `projectsId`. - pub fn logs_sinks_update(&self, request: &LogSink, projects_id: &str, logs_id: &str, sinks_id: &str) -> ProjectLogSinkUpdateCall<'a, C, A> { + pub fn logs_sinks_update(&self, request: LogSink, projects_id: &str, logs_id: &str, sinks_id: &str) -> ProjectLogSinkUpdateCall<'a, C, A> { ProjectLogSinkUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _projects_id: projects_id.to_string(), _logs_id: logs_id.to_string(), _sinks_id: sinks_id.to_string(), @@ -888,10 +890,10 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// * `request` - No description provided. /// * `projectsId` - Part of `serviceName`. The name of the service in which to create a sink. /// * `logServicesId` - Part of `serviceName`. See documentation of `projectsId`. - pub fn log_services_sinks_create(&self, request: &LogSink, projects_id: &str, log_services_id: &str) -> ProjectLogServiceSinkCreateCall<'a, C, A> { + pub fn log_services_sinks_create(&self, request: LogSink, projects_id: &str, log_services_id: &str) -> ProjectLogServiceSinkCreateCall<'a, C, A> { ProjectLogServiceSinkCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _projects_id: projects_id.to_string(), _log_services_id: log_services_id.to_string(), _delegate: Default::default(), @@ -930,10 +932,10 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// * `request` - No description provided. /// * `projectsId` - Part of `logName`. The log in which to create a sink resource. /// * `logsId` - Part of `logName`. See documentation of `projectsId`. - pub fn logs_sinks_create(&self, request: &LogSink, projects_id: &str, logs_id: &str) -> ProjectLogSinkCreateCall<'a, C, A> { + pub fn logs_sinks_create(&self, request: LogSink, projects_id: &str, logs_id: &str) -> ProjectLogSinkCreateCall<'a, C, A> { ProjectLogSinkCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _projects_id: projects_id.to_string(), _logs_id: logs_id.to_string(), _delegate: Default::default(), @@ -1170,12 +1172,17 @@ impl<'a, C, A> ProjectLogServiceListCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1184,7 +1191,7 @@ impl<'a, C, A> ProjectLogServiceListCall<'a, C, A> where C: BorrowMut<hyper::Cli Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1449,12 +1456,17 @@ impl<'a, C, A> ProjectLogListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1463,7 +1475,7 @@ impl<'a, C, A> ProjectLogListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1719,12 +1731,17 @@ impl<'a, C, A> ProjectLogSinkGetCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1733,7 +1750,7 @@ impl<'a, C, A> ProjectLogSinkGetCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1864,7 +1881,7 @@ impl<'a, C, A> ProjectLogSinkGetCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.projects().log_services_sinks_update(&req, "projectsId", "logServicesId", "sinksId") +/// let result = hub.projects().log_services_sinks_update(req, "projectsId", "logServicesId", "sinksId") /// .doit(); /// # } /// ``` @@ -1996,12 +2013,17 @@ impl<'a, C, A> ProjectLogServiceSinkUpdateCall<'a, C, A> where C: BorrowMut<hype if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2010,7 +2032,7 @@ impl<'a, C, A> ProjectLogServiceSinkUpdateCall<'a, C, A> where C: BorrowMut<hype Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2028,8 +2050,8 @@ impl<'a, C, A> ProjectLogServiceSinkUpdateCall<'a, C, A> where C: BorrowMut<hype /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &LogSink) -> ProjectLogServiceSinkUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: LogSink) -> ProjectLogServiceSinkUpdateCall<'a, C, A> { + self._request = new_value; self } /// Part of `sinkName`. The name of the sink to update. @@ -2150,7 +2172,7 @@ impl<'a, C, A> ProjectLogServiceSinkUpdateCall<'a, C, A> where C: BorrowMut<hype /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.projects().logs_entries_write(&req, "projectsId", "logsId") +/// let result = hub.projects().logs_entries_write(req, "projectsId", "logsId") /// .doit(); /// # } /// ``` @@ -2280,12 +2302,17 @@ impl<'a, C, A> ProjectLogEntryWriteCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2294,7 +2321,7 @@ impl<'a, C, A> ProjectLogEntryWriteCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2312,8 +2339,8 @@ impl<'a, C, A> ProjectLogEntryWriteCall<'a, C, A> where C: BorrowMut<hyper::Clie /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &WriteLogEntriesRequest) -> ProjectLogEntryWriteCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: WriteLogEntriesRequest) -> ProjectLogEntryWriteCall<'a, C, A> { + self._request = new_value; self } /// Part of `logName`. The name of the log resource into which to insert the log entries. @@ -2541,12 +2568,17 @@ impl<'a, C, A> ProjectLogServiceSinkDeleteCall<'a, C, A> where C: BorrowMut<hype if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2555,7 +2587,7 @@ impl<'a, C, A> ProjectLogServiceSinkDeleteCall<'a, C, A> where C: BorrowMut<hype Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2826,12 +2858,17 @@ impl<'a, C, A> ProjectLogServiceIndexeListCall<'a, C, A> where C: BorrowMut<hype if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2840,7 +2877,7 @@ impl<'a, C, A> ProjectLogServiceIndexeListCall<'a, C, A> where C: BorrowMut<hype Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3111,12 +3148,17 @@ impl<'a, C, A> ProjectLogSinkListCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3125,7 +3167,7 @@ impl<'a, C, A> ProjectLogSinkListCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3246,7 +3288,7 @@ impl<'a, C, A> ProjectLogSinkListCall<'a, C, A> where C: BorrowMut<hyper::Client /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.projects().logs_sinks_update(&req, "projectsId", "logsId", "sinksId") +/// let result = hub.projects().logs_sinks_update(req, "projectsId", "logsId", "sinksId") /// .doit(); /// # } /// ``` @@ -3378,12 +3420,17 @@ impl<'a, C, A> ProjectLogSinkUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3392,7 +3439,7 @@ impl<'a, C, A> ProjectLogSinkUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3410,8 +3457,8 @@ impl<'a, C, A> ProjectLogSinkUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clie /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &LogSink) -> ProjectLogSinkUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: LogSink) -> ProjectLogSinkUpdateCall<'a, C, A> { + self._request = new_value; self } /// Part of `sinkName`. The name of the sink to update. @@ -3532,7 +3579,7 @@ impl<'a, C, A> ProjectLogSinkUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.projects().log_services_sinks_create(&req, "projectsId", "logServicesId") +/// let result = hub.projects().log_services_sinks_create(req, "projectsId", "logServicesId") /// .doit(); /// # } /// ``` @@ -3662,12 +3709,17 @@ impl<'a, C, A> ProjectLogServiceSinkCreateCall<'a, C, A> where C: BorrowMut<hype if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3676,7 +3728,7 @@ impl<'a, C, A> ProjectLogServiceSinkCreateCall<'a, C, A> where C: BorrowMut<hype Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3694,8 +3746,8 @@ impl<'a, C, A> ProjectLogServiceSinkCreateCall<'a, C, A> where C: BorrowMut<hype /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &LogSink) -> ProjectLogServiceSinkCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: LogSink) -> ProjectLogServiceSinkCreateCall<'a, C, A> { + self._request = new_value; self } /// Part of `serviceName`. The name of the service in which to create a sink. @@ -3923,12 +3975,17 @@ impl<'a, C, A> ProjectLogSinkDeleteCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3937,7 +3994,7 @@ impl<'a, C, A> ProjectLogSinkDeleteCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4068,7 +4125,7 @@ impl<'a, C, A> ProjectLogSinkDeleteCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.projects().logs_sinks_create(&req, "projectsId", "logsId") +/// let result = hub.projects().logs_sinks_create(req, "projectsId", "logsId") /// .doit(); /// # } /// ``` @@ -4198,12 +4255,17 @@ impl<'a, C, A> ProjectLogSinkCreateCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4212,7 +4274,7 @@ impl<'a, C, A> ProjectLogSinkCreateCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4230,8 +4292,8 @@ impl<'a, C, A> ProjectLogSinkCreateCall<'a, C, A> where C: BorrowMut<hyper::Clie /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &LogSink) -> ProjectLogSinkCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: LogSink) -> ProjectLogSinkCreateCall<'a, C, A> { + self._request = new_value; self } /// Part of `logName`. The log in which to create a sink resource. @@ -4459,12 +4521,17 @@ impl<'a, C, A> ProjectLogServiceSinkGetCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4473,7 +4540,7 @@ impl<'a, C, A> ProjectLogServiceSinkGetCall<'a, C, A> where C: BorrowMut<hyper:: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4719,12 +4786,17 @@ impl<'a, C, A> ProjectLogServiceSinkListCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4733,7 +4805,7 @@ impl<'a, C, A> ProjectLogServiceSinkListCall<'a, C, A> where C: BorrowMut<hyper: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4969,12 +5041,17 @@ impl<'a, C, A> ProjectLogDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4983,7 +5060,7 @@ impl<'a, C, A> ProjectLogDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/manager1_beta2-cli/Cargo.toml b/gen/manager1_beta2-cli/Cargo.toml index 134b17c3ee..0ae0261cae 100644 --- a/gen/manager1_beta2-cli/Cargo.toml +++ b/gen/manager1_beta2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-manager1_beta2-cli" -version = "0.0.1+20140915" +version = "0.1.0+20140915" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with manager (protocol v1beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/manager1_beta2-cli" diff --git a/gen/manager1_beta2-cli/README.md b/gen/manager1_beta2-cli/README.md index 25434a8dd8..d46ba0bb72 100644 --- a/gen/manager1_beta2-cli/README.md +++ b/gen/manager1_beta2-cli/README.md @@ -1,4 +1,109 @@ -# HELLO MANAGER:V1BETA2 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `manager1-beta2` command-line interface *(CLI)* allows to use most features of the *Google manager* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *manager* API at revision *20140915*. The CLI is at version *0.1.0*. + +```bash + manager1-beta2 [options] deployments delete <project-id> <region> <deployment-name> [-p <v>...] + manager1-beta2 [options] deployments get <project-id> <region> <deployment-name> [-p <v>...] [-o <out>] + manager1-beta2 [options] deployments insert <project-id> <region> -r <kv>... [-p <v>...] [-o <out>] + manager1-beta2 [options] deployments list <project-id> <region> [-p <v>...] [-o <out>] + manager1-beta2 [options] templates delete <project-id> <template-name> [-p <v>...] + manager1-beta2 [options] templates get <project-id> <template-name> [-p <v>...] [-o <out>] + manager1-beta2 [options] templates insert <project-id> -r <kv>... [-p <v>...] [-o <out>] + manager1-beta2 [options] templates list <project-id> [-p <v>...] [-o <out>] + manager1-beta2 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_manager1_beta2_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `manager1-beta2-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/manager1-beta2-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/manager1-beta2-secret.json`, assuming that the required *manager* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `manager1-beta2 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/manager1_beta2-cli/mkdocs.yml b/gen/manager1_beta2-cli/mkdocs.yml index d58d25a950..b44622c309 100644 --- a/gen/manager1_beta2-cli/mkdocs.yml +++ b/gen/manager1_beta2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: manager v0.0.1+20140915 +site_name: manager v0.1.0+20140915 site_url: http://byron.github.io/google-apis-rs/google-manager1_beta2-cli site_description: Write integrating applications with bcore diff --git a/gen/manager1_beta2-cli/src/cmn.rs b/gen/manager1_beta2-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/manager1_beta2-cli/src/cmn.rs +++ b/gen/manager1_beta2-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/manager1_beta2-cli/src/main.rs b/gen/manager1_beta2-cli/src/main.rs index 66490a2e60..d16c71afdc 100644 --- a/gen/manager1_beta2-cli/src/main.rs +++ b/gen/manager1_beta2-cli/src/main.rs @@ -19,33 +19,34 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - manager1-beta2 [options] deployments delete <project-id> <region> <deployment-name> [-p <v>]... - manager1-beta2 [options] deployments get <project-id> <region> <deployment-name> [-p <v>]... [-o <out>] - manager1-beta2 [options] deployments insert <project-id> <region> -r <kv>... [-p <v>]... [-o <out>] - manager1-beta2 [options] deployments list <project-id> <region> [-p <v>]... [-o <out>] - manager1-beta2 [options] templates delete <project-id> <template-name> [-p <v>]... - manager1-beta2 [options] templates get <project-id> <template-name> [-p <v>]... [-o <out>] - manager1-beta2 [options] templates insert <project-id> -r <kv>... [-p <v>]... [-o <out>] - manager1-beta2 [options] templates list <project-id> [-p <v>]... [-o <out>] + manager1-beta2 [options] deployments delete <project-id> <region> <deployment-name> [-p <v>...] + manager1-beta2 [options] deployments get <project-id> <region> <deployment-name> [-p <v>...] [-o <out>] + manager1-beta2 [options] deployments insert <project-id> <region> -r <kv>... [-p <v>...] [-o <out>] + manager1-beta2 [options] deployments list <project-id> <region> [-p <v>...] [-o <out>] + manager1-beta2 [options] templates delete <project-id> <template-name> [-p <v>...] + manager1-beta2 [options] templates get <project-id> <template-name> [-p <v>...] [-o <out>] + manager1-beta2 [options] templates insert <project-id> -r <kv>... [-p <v>...] [-o <out>] + manager1-beta2 [options] templates list <project-id> [-p <v>...] [-o <out>] manager1-beta2 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_manager1_beta2_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -94,6 +95,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -135,6 +139,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -151,43 +158,30 @@ impl Engine { fn _deployments_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Deployment::default(); - let mut call = self.hub.deployments().insert(&request, &self.opt.arg_project_id, &self.opt.arg_region); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Deployment::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_state_init(request: &mut api::Deployment) { if request.state.is_none() { request.state = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "state.status" => { request_state_init(&mut request); request.state.as_mut().unwrap().status = Some(value.unwrap_or("").to_string()); @@ -213,15 +207,40 @@ impl Engine { request.template_name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.deployments().insert(request, &self.opt.arg_project_id, &self.opt.arg_region); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -271,6 +290,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -314,6 +336,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -355,6 +380,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -371,8 +399,36 @@ impl Engine { fn _templates_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Template::default(); - let mut call = self.hub.templates().insert(&request, &self.opt.arg_project_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "description" => { + request.description = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.templates().insert(request, &self.opt.arg_project_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -394,30 +450,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "description" => { - request.description = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -467,6 +507,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -579,6 +622,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -586,8 +630,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/manager1_beta2/Cargo.toml b/gen/manager1_beta2/Cargo.toml index ff33a67d6a..c743a90c03 100644 --- a/gen/manager1_beta2/Cargo.toml +++ b/gen/manager1_beta2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-manager1_beta2" -version = "0.1.5+20140915" +version = "0.1.6+20140915" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with manager (protocol v1beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/manager1_beta2" diff --git a/gen/manager1_beta2/README.md b/gen/manager1_beta2/README.md index bd06a3dcb6..2c3689757b 100644 --- a/gen/manager1_beta2/README.md +++ b/gen/manager1_beta2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-manager1_beta2` library allows access to all features of the *Google manager* service. -This documentation was generated from *manager* crate version *0.1.5+20140915*, where *20140915* is the exact revision of the *manager:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *manager* crate version *0.1.6+20140915*, where *20140915* is the exact revision of the *manager:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *manager* *v1_beta2* API can be found at the [official documentation site](https://developers.google.com/deployment-manager/). @@ -106,14 +106,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/manager1_beta2/src/cmn.rs b/gen/manager1_beta2/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/manager1_beta2/src/cmn.rs +++ b/gen/manager1_beta2/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/manager1_beta2/src/lib.rs b/gen/manager1_beta2/src/lib.rs index 51a0992bcd..bc174d4f81 100644 --- a/gen/manager1_beta2/src/lib.rs +++ b/gen/manager1_beta2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *manager* crate version *0.1.5+20140915*, where *20140915* is the exact revision of the *manager:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *manager* crate version *0.1.6+20140915*, where *20140915* is the exact revision of the *manager:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *manager* *v1_beta2* API can be found at the //! [official documentation site](https://developers.google.com/deployment-manager/). @@ -107,14 +107,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -202,7 +203,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -298,14 +299,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -326,7 +328,7 @@ impl<'a, C, A> Manager<C, A> Manager { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -338,7 +340,7 @@ impl<'a, C, A> Manager<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -1189,10 +1191,10 @@ impl<'a, C, A> TemplateMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `projectId` - No description provided. - pub fn insert(&self, request: &Template, project_id: &str) -> TemplateInsertCall<'a, C, A> { + pub fn insert(&self, request: Template, project_id: &str) -> TemplateInsertCall<'a, C, A> { TemplateInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project_id: project_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1269,10 +1271,10 @@ impl<'a, C, A> DeploymentMethods<'a, C, A> { /// * `request` - No description provided. /// * `projectId` - No description provided. /// * `region` - No description provided. - pub fn insert(&self, request: &Deployment, project_id: &str, region: &str) -> DeploymentInsertCall<'a, C, A> { + pub fn insert(&self, request: Deployment, project_id: &str, region: &str) -> DeploymentInsertCall<'a, C, A> { DeploymentInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project_id: project_id.to_string(), _region: region.to_string(), _delegate: Default::default(), @@ -1508,12 +1510,17 @@ impl<'a, C, A> TemplateListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1522,7 +1529,7 @@ impl<'a, C, A> TemplateListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1756,12 +1763,17 @@ impl<'a, C, A> TemplateDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -1875,7 +1887,7 @@ impl<'a, C, A> TemplateDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.templates().insert(&req, "projectId") +/// let result = hub.templates().insert(req, "projectId") /// .doit(); /// # } /// ``` @@ -2003,12 +2015,17 @@ impl<'a, C, A> TemplateInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2017,7 +2034,7 @@ impl<'a, C, A> TemplateInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2035,8 +2052,8 @@ impl<'a, C, A> TemplateInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Template) -> TemplateInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Template) -> TemplateInsertCall<'a, C, A> { + self._request = new_value; self } /// @@ -2247,12 +2264,17 @@ impl<'a, C, A> TemplateGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2261,7 +2283,7 @@ impl<'a, C, A> TemplateGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2376,7 +2398,7 @@ impl<'a, C, A> TemplateGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.deployments().insert(&req, "projectId", "region") +/// let result = hub.deployments().insert(req, "projectId", "region") /// .doit(); /// # } /// ``` @@ -2506,12 +2528,17 @@ impl<'a, C, A> DeploymentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2520,7 +2547,7 @@ impl<'a, C, A> DeploymentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2538,8 +2565,8 @@ impl<'a, C, A> DeploymentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Deployment) -> DeploymentInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Deployment) -> DeploymentInsertCall<'a, C, A> { + self._request = new_value; self } /// @@ -2761,12 +2788,17 @@ impl<'a, C, A> DeploymentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2775,7 +2807,7 @@ impl<'a, C, A> DeploymentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3024,12 +3056,17 @@ impl<'a, C, A> DeploymentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3038,7 +3075,7 @@ impl<'a, C, A> DeploymentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3283,12 +3320,17 @@ impl<'a, C, A> DeploymentDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; diff --git a/gen/mapsengine1-cli/Cargo.toml b/gen/mapsengine1-cli/Cargo.toml index fba749cdfe..5fc0b620be 100644 --- a/gen/mapsengine1-cli/Cargo.toml +++ b/gen/mapsengine1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-mapsengine1-cli" -version = "0.0.1+20150414" +version = "0.1.0+20150414" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with Maps Engine (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/mapsengine1-cli" diff --git a/gen/mapsengine1-cli/README.md b/gen/mapsengine1-cli/README.md index 05db334991..d20bd018c2 100644 --- a/gen/mapsengine1-cli/README.md +++ b/gen/mapsengine1-cli/README.md @@ -1,4 +1,178 @@ -# HELLO MAPSENGINE:V1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `mapsengine1` command-line interface *(CLI)* allows to use most features of the *Google Maps Engine* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *Maps Engine* API at revision *20150414*. The CLI is at version *0.1.0*. + +```bash + mapsengine1 [options] assets get <id> [-p <v>...] [-o <out>] + mapsengine1 [options] assets list [-p <v>...] [-o <out>] + mapsengine1 [options] assets parents-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] assets permissions-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] layers cancel-processing <id> [-p <v>...] [-o <out>] + mapsengine1 [options] layers create -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] layers delete <id> [-p <v>...] + mapsengine1 [options] layers get <id> [-p <v>...] [-o <out>] + mapsengine1 [options] layers get-published <id> [-p <v>...] [-o <out>] + mapsengine1 [options] layers list [-p <v>...] [-o <out>] + mapsengine1 [options] layers list-published [-p <v>...] [-o <out>] + mapsengine1 [options] layers parents-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] layers patch <id> -r <kv>... [-p <v>...] + mapsengine1 [options] layers permissions-batch-delete <id> -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] layers permissions-batch-update <id> -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] layers permissions-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] layers process <id> [-p <v>...] [-o <out>] + mapsengine1 [options] layers publish <id> [-p <v>...] [-o <out>] + mapsengine1 [options] layers unpublish <id> [-p <v>...] [-o <out>] + mapsengine1 [options] maps create -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] maps delete <id> [-p <v>...] + mapsengine1 [options] maps get <id> [-p <v>...] [-o <out>] + mapsengine1 [options] maps get-published <id> [-p <v>...] [-o <out>] + mapsengine1 [options] maps list [-p <v>...] [-o <out>] + mapsengine1 [options] maps list-published [-p <v>...] [-o <out>] + mapsengine1 [options] maps patch <id> -r <kv>... [-p <v>...] + mapsengine1 [options] maps permissions-batch-delete <id> -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] maps permissions-batch-update <id> -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] maps permissions-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] maps publish <id> [-p <v>...] [-o <out>] + mapsengine1 [options] maps unpublish <id> [-p <v>...] [-o <out>] + mapsengine1 [options] projects icons-create <project-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + mapsengine1 [options] projects icons-get <project-id> <id> [-p <v>...] [-o <out>] + mapsengine1 [options] projects icons-list <project-id> [-p <v>...] [-o <out>] + mapsengine1 [options] projects list [-p <v>...] [-o <out>] + mapsengine1 [options] raster-collections cancel-processing <id> [-p <v>...] [-o <out>] + mapsengine1 [options] raster-collections create -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] raster-collections delete <id> [-p <v>...] + mapsengine1 [options] raster-collections get <id> [-p <v>...] [-o <out>] + mapsengine1 [options] raster-collections list [-p <v>...] [-o <out>] + mapsengine1 [options] raster-collections parents-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] raster-collections patch <id> -r <kv>... [-p <v>...] + mapsengine1 [options] raster-collections permissions-batch-delete <id> -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] raster-collections permissions-batch-update <id> -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] raster-collections permissions-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] raster-collections process <id> [-p <v>...] [-o <out>] + mapsengine1 [options] raster-collections rasters-batch-delete <id> -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] raster-collections rasters-batch-insert <id> -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] raster-collections rasters-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] rasters delete <id> [-p <v>...] + mapsengine1 [options] rasters files-insert <id> <filename> -u (simple|resumable) <file> <mime> [-p <v>...] + mapsengine1 [options] rasters get <id> [-p <v>...] [-o <out>] + mapsengine1 [options] rasters list <project-id> [-p <v>...] [-o <out>] + mapsengine1 [options] rasters parents-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] rasters patch <id> -r <kv>... [-p <v>...] + mapsengine1 [options] rasters permissions-batch-delete <id> -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] rasters permissions-batch-update <id> -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] rasters permissions-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] rasters process <id> [-p <v>...] [-o <out>] + mapsengine1 [options] rasters upload -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] tables create -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] tables delete <id> [-p <v>...] + mapsengine1 [options] tables features-batch-delete <id> -r <kv>... [-p <v>...] + mapsengine1 [options] tables features-batch-insert <id> -r <kv>... [-p <v>...] + mapsengine1 [options] tables features-batch-patch <id> -r <kv>... [-p <v>...] + mapsengine1 [options] tables features-get <table-id> <id> [-p <v>...] [-o <out>] + mapsengine1 [options] tables features-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] tables files-insert <id> <filename> -u (simple|resumable) <file> <mime> [-p <v>...] + mapsengine1 [options] tables get <id> [-p <v>...] [-o <out>] + mapsengine1 [options] tables list [-p <v>...] [-o <out>] + mapsengine1 [options] tables parents-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] tables patch <id> -r <kv>... [-p <v>...] + mapsengine1 [options] tables permissions-batch-delete <id> -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] tables permissions-batch-update <id> -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] tables permissions-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] tables process <id> [-p <v>...] [-o <out>] + mapsengine1 [options] tables upload -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_mapsengine1_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `mapsengine1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/mapsengine1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/mapsengine1-secret.json`, assuming that the required *mapsengine* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `mapsengine1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/mapsengine1-cli/mkdocs.yml b/gen/mapsengine1-cli/mkdocs.yml index 9d65a5c3d0..35438dfabd 100644 --- a/gen/mapsengine1-cli/mkdocs.yml +++ b/gen/mapsengine1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Maps Engine v0.0.1+20150414 +site_name: Maps Engine v0.1.0+20150414 site_url: http://byron.github.io/google-apis-rs/google-mapsengine1-cli site_description: Write integrating applications with bcore diff --git a/gen/mapsengine1-cli/src/cmn.rs b/gen/mapsengine1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/mapsengine1-cli/src/cmn.rs +++ b/gen/mapsengine1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/mapsengine1-cli/src/main.rs b/gen/mapsengine1-cli/src/main.rs index f23f5248ee..f2318a27b2 100644 --- a/gen/mapsengine1-cli/src/main.rs +++ b/gen/mapsengine1-cli/src/main.rs @@ -19,102 +19,103 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - mapsengine1 [options] assets get <id> [-p <v>]... [-o <out>] - mapsengine1 [options] assets list [-p <v>]... [-o <out>] - mapsengine1 [options] assets parents-list <id> [-p <v>]... [-o <out>] - mapsengine1 [options] assets permissions-list <id> [-p <v>]... [-o <out>] - mapsengine1 [options] layers cancel-processing <id> [-p <v>]... [-o <out>] - mapsengine1 [options] layers create -r <kv>... [-p <v>]... [-o <out>] - mapsengine1 [options] layers delete <id> [-p <v>]... - mapsengine1 [options] layers get <id> [-p <v>]... [-o <out>] - mapsengine1 [options] layers get-published <id> [-p <v>]... [-o <out>] - mapsengine1 [options] layers list [-p <v>]... [-o <out>] - mapsengine1 [options] layers list-published [-p <v>]... [-o <out>] - mapsengine1 [options] layers parents-list <id> [-p <v>]... [-o <out>] - mapsengine1 [options] layers patch <id> -r <kv>... [-p <v>]... - mapsengine1 [options] layers permissions-batch-delete <id> -r <kv>... [-p <v>]... [-o <out>] - mapsengine1 [options] layers permissions-batch-update <id> -r <kv>... [-p <v>]... [-o <out>] - mapsengine1 [options] layers permissions-list <id> [-p <v>]... [-o <out>] - mapsengine1 [options] layers process <id> [-p <v>]... [-o <out>] - mapsengine1 [options] layers publish <id> [-p <v>]... [-o <out>] - mapsengine1 [options] layers unpublish <id> [-p <v>]... [-o <out>] - mapsengine1 [options] maps create -r <kv>... [-p <v>]... [-o <out>] - mapsengine1 [options] maps delete <id> [-p <v>]... - mapsengine1 [options] maps get <id> [-p <v>]... [-o <out>] - mapsengine1 [options] maps get-published <id> [-p <v>]... [-o <out>] - mapsengine1 [options] maps list [-p <v>]... [-o <out>] - mapsengine1 [options] maps list-published [-p <v>]... [-o <out>] - mapsengine1 [options] maps patch <id> -r <kv>... [-p <v>]... - mapsengine1 [options] maps permissions-batch-delete <id> -r <kv>... [-p <v>]... [-o <out>] - mapsengine1 [options] maps permissions-batch-update <id> -r <kv>... [-p <v>]... [-o <out>] - mapsengine1 [options] maps permissions-list <id> [-p <v>]... [-o <out>] - mapsengine1 [options] maps publish <id> [-p <v>]... [-o <out>] - mapsengine1 [options] maps unpublish <id> [-p <v>]... [-o <out>] - mapsengine1 [options] projects icons-create <project-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] - mapsengine1 [options] projects icons-get <project-id> <id> [-p <v>]... [-o <out>] - mapsengine1 [options] projects icons-list <project-id> [-p <v>]... [-o <out>] - mapsengine1 [options] projects list [-p <v>]... [-o <out>] - mapsengine1 [options] raster-collections cancel-processing <id> [-p <v>]... [-o <out>] - mapsengine1 [options] raster-collections create -r <kv>... [-p <v>]... [-o <out>] - mapsengine1 [options] raster-collections delete <id> [-p <v>]... - mapsengine1 [options] raster-collections get <id> [-p <v>]... [-o <out>] - mapsengine1 [options] raster-collections list [-p <v>]... [-o <out>] - mapsengine1 [options] raster-collections parents-list <id> [-p <v>]... [-o <out>] - mapsengine1 [options] raster-collections patch <id> -r <kv>... [-p <v>]... - mapsengine1 [options] raster-collections permissions-batch-delete <id> -r <kv>... [-p <v>]... [-o <out>] - mapsengine1 [options] raster-collections permissions-batch-update <id> -r <kv>... [-p <v>]... [-o <out>] - mapsengine1 [options] raster-collections permissions-list <id> [-p <v>]... [-o <out>] - mapsengine1 [options] raster-collections process <id> [-p <v>]... [-o <out>] - mapsengine1 [options] raster-collections rasters-batch-delete <id> -r <kv>... [-p <v>]... [-o <out>] - mapsengine1 [options] raster-collections rasters-batch-insert <id> -r <kv>... [-p <v>]... [-o <out>] - mapsengine1 [options] raster-collections rasters-list <id> [-p <v>]... [-o <out>] - mapsengine1 [options] rasters delete <id> [-p <v>]... - mapsengine1 [options] rasters files-insert <id> <filename> -u (simple|resumable) <file> <mime> [-p <v>]... - mapsengine1 [options] rasters get <id> [-p <v>]... [-o <out>] - mapsengine1 [options] rasters list <project-id> [-p <v>]... [-o <out>] - mapsengine1 [options] rasters parents-list <id> [-p <v>]... [-o <out>] - mapsengine1 [options] rasters patch <id> -r <kv>... [-p <v>]... - mapsengine1 [options] rasters permissions-batch-delete <id> -r <kv>... [-p <v>]... [-o <out>] - mapsengine1 [options] rasters permissions-batch-update <id> -r <kv>... [-p <v>]... [-o <out>] - mapsengine1 [options] rasters permissions-list <id> [-p <v>]... [-o <out>] - mapsengine1 [options] rasters process <id> [-p <v>]... [-o <out>] - mapsengine1 [options] rasters upload -r <kv>... [-p <v>]... [-o <out>] - mapsengine1 [options] tables create -r <kv>... [-p <v>]... [-o <out>] - mapsengine1 [options] tables delete <id> [-p <v>]... - mapsengine1 [options] tables features-batch-delete <id> -r <kv>... [-p <v>]... - mapsengine1 [options] tables features-batch-insert <id> -r <kv>... [-p <v>]... - mapsengine1 [options] tables features-batch-patch <id> -r <kv>... [-p <v>]... - mapsengine1 [options] tables features-get <table-id> <id> [-p <v>]... [-o <out>] - mapsengine1 [options] tables features-list <id> [-p <v>]... [-o <out>] - mapsengine1 [options] tables files-insert <id> <filename> -u (simple|resumable) <file> <mime> [-p <v>]... - mapsengine1 [options] tables get <id> [-p <v>]... [-o <out>] - mapsengine1 [options] tables list [-p <v>]... [-o <out>] - mapsengine1 [options] tables parents-list <id> [-p <v>]... [-o <out>] - mapsengine1 [options] tables patch <id> -r <kv>... [-p <v>]... - mapsengine1 [options] tables permissions-batch-delete <id> -r <kv>... [-p <v>]... [-o <out>] - mapsengine1 [options] tables permissions-batch-update <id> -r <kv>... [-p <v>]... [-o <out>] - mapsengine1 [options] tables permissions-list <id> [-p <v>]... [-o <out>] - mapsengine1 [options] tables process <id> [-p <v>]... [-o <out>] - mapsengine1 [options] tables upload -r <kv>... [-p <v>]... [-o <out>] + mapsengine1 [options] assets get <id> [-p <v>...] [-o <out>] + mapsengine1 [options] assets list [-p <v>...] [-o <out>] + mapsengine1 [options] assets parents-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] assets permissions-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] layers cancel-processing <id> [-p <v>...] [-o <out>] + mapsengine1 [options] layers create -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] layers delete <id> [-p <v>...] + mapsengine1 [options] layers get <id> [-p <v>...] [-o <out>] + mapsengine1 [options] layers get-published <id> [-p <v>...] [-o <out>] + mapsengine1 [options] layers list [-p <v>...] [-o <out>] + mapsengine1 [options] layers list-published [-p <v>...] [-o <out>] + mapsengine1 [options] layers parents-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] layers patch <id> -r <kv>... [-p <v>...] + mapsengine1 [options] layers permissions-batch-delete <id> -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] layers permissions-batch-update <id> -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] layers permissions-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] layers process <id> [-p <v>...] [-o <out>] + mapsengine1 [options] layers publish <id> [-p <v>...] [-o <out>] + mapsengine1 [options] layers unpublish <id> [-p <v>...] [-o <out>] + mapsengine1 [options] maps create -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] maps delete <id> [-p <v>...] + mapsengine1 [options] maps get <id> [-p <v>...] [-o <out>] + mapsengine1 [options] maps get-published <id> [-p <v>...] [-o <out>] + mapsengine1 [options] maps list [-p <v>...] [-o <out>] + mapsengine1 [options] maps list-published [-p <v>...] [-o <out>] + mapsengine1 [options] maps patch <id> -r <kv>... [-p <v>...] + mapsengine1 [options] maps permissions-batch-delete <id> -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] maps permissions-batch-update <id> -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] maps permissions-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] maps publish <id> [-p <v>...] [-o <out>] + mapsengine1 [options] maps unpublish <id> [-p <v>...] [-o <out>] + mapsengine1 [options] projects icons-create <project-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + mapsengine1 [options] projects icons-get <project-id> <id> [-p <v>...] [-o <out>] + mapsengine1 [options] projects icons-list <project-id> [-p <v>...] [-o <out>] + mapsengine1 [options] projects list [-p <v>...] [-o <out>] + mapsengine1 [options] raster-collections cancel-processing <id> [-p <v>...] [-o <out>] + mapsengine1 [options] raster-collections create -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] raster-collections delete <id> [-p <v>...] + mapsengine1 [options] raster-collections get <id> [-p <v>...] [-o <out>] + mapsengine1 [options] raster-collections list [-p <v>...] [-o <out>] + mapsengine1 [options] raster-collections parents-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] raster-collections patch <id> -r <kv>... [-p <v>...] + mapsengine1 [options] raster-collections permissions-batch-delete <id> -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] raster-collections permissions-batch-update <id> -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] raster-collections permissions-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] raster-collections process <id> [-p <v>...] [-o <out>] + mapsengine1 [options] raster-collections rasters-batch-delete <id> -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] raster-collections rasters-batch-insert <id> -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] raster-collections rasters-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] rasters delete <id> [-p <v>...] + mapsengine1 [options] rasters files-insert <id> <filename> -u (simple|resumable) <file> <mime> [-p <v>...] + mapsengine1 [options] rasters get <id> [-p <v>...] [-o <out>] + mapsengine1 [options] rasters list <project-id> [-p <v>...] [-o <out>] + mapsengine1 [options] rasters parents-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] rasters patch <id> -r <kv>... [-p <v>...] + mapsengine1 [options] rasters permissions-batch-delete <id> -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] rasters permissions-batch-update <id> -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] rasters permissions-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] rasters process <id> [-p <v>...] [-o <out>] + mapsengine1 [options] rasters upload -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] tables create -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] tables delete <id> [-p <v>...] + mapsengine1 [options] tables features-batch-delete <id> -r <kv>... [-p <v>...] + mapsengine1 [options] tables features-batch-insert <id> -r <kv>... [-p <v>...] + mapsengine1 [options] tables features-batch-patch <id> -r <kv>... [-p <v>...] + mapsengine1 [options] tables features-get <table-id> <id> [-p <v>...] [-o <out>] + mapsengine1 [options] tables features-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] tables files-insert <id> <filename> -u (simple|resumable) <file> <mime> [-p <v>...] + mapsengine1 [options] tables get <id> [-p <v>...] [-o <out>] + mapsengine1 [options] tables list [-p <v>...] [-o <out>] + mapsengine1 [options] tables parents-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] tables patch <id> -r <kv>... [-p <v>...] + mapsengine1 [options] tables permissions-batch-delete <id> -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] tables permissions-batch-update <id> -r <kv>... [-p <v>...] [-o <out>] + mapsengine1 [options] tables permissions-list <id> [-p <v>...] [-o <out>] + mapsengine1 [options] tables process <id> [-p <v>...] [-o <out>] + mapsengine1 [options] tables upload -r <kv>... [-p <v>...] [-o <out>] mapsengine1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_mapsengine1_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -163,6 +164,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -245,6 +249,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -294,6 +301,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -337,6 +347,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -380,6 +393,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -396,39 +412,23 @@ impl Engine { fn _layers_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Layer::default(); - let mut call = self.hub.layers().create(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "process" => { - call = call.process(arg_from_str(value.unwrap_or("false"), err, "process", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Layer::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_style_feature_info_init(request: &mut api::Layer) { request_style_init(request); if request.style.as_mut().unwrap().feature_info.is_none() { @@ -442,7 +442,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "style.feature-info.content" => { request_style_feature_info_init(&mut request); request.style.as_mut().unwrap().feature_info.as_mut().unwrap().content = Some(value.unwrap_or("").to_string()); @@ -523,15 +523,43 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.layers().create(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "process" => { + call = call.process(arg_from_str(value.unwrap_or("false"), err, "process", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -575,6 +603,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -619,6 +650,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -662,6 +696,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -744,6 +781,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -796,6 +836,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -845,6 +888,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -861,36 +907,23 @@ impl Engine { fn _layers_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Layer::default(); - let mut call = self.hub.layers().patch(&request, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Layer::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_style_feature_info_init(request: &mut api::Layer) { request_style_init(request); if request.style.as_mut().unwrap().feature_info.is_none() { @@ -904,7 +937,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "style.feature-info.content" => { request_style_feature_info_init(&mut request); request.style.as_mut().unwrap().feature_info.as_mut().unwrap().content = Some(value.unwrap_or("").to_string()); @@ -985,31 +1018,11 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok(mut response) => { - None - } - } - } - } - - fn _layers_permissions_batch_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::PermissionsBatchDeleteRequest::default(); - let mut call = self.hub.layers().permissions_batch_delete(&request, &self.opt.arg_id); + let mut call = self.hub.layers().patch(request, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1031,14 +1044,46 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok(mut response) => { + None + } + } + } + } + + fn _layers_permissions_batch_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::PermissionsBatchDeleteRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "ids" => { if request.ids.is_none() { request.ids = Some(Default::default()); @@ -1046,15 +1091,40 @@ impl Engine { request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.layers().permissions_batch_delete(request, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1071,8 +1141,30 @@ impl Engine { fn _layers_permissions_batch_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::PermissionsBatchUpdateRequest::default(); - let mut call = self.hub.layers().permissions_batch_update(&request, &self.opt.arg_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.layers().permissions_batch_update(request, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1094,24 +1186,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1155,6 +1237,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1198,6 +1283,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1244,6 +1332,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1287,6 +1378,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1303,37 +1397,24 @@ impl Engine { fn _maps_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Map::default(); - let mut call = self.hub.maps().create(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Map::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "description" => { request.description = Some(value.unwrap_or("").to_string()); }, @@ -1389,15 +1470,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.maps().create(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1441,6 +1547,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1485,6 +1594,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1528,6 +1640,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1610,6 +1725,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1662,6 +1780,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1678,37 +1799,24 @@ impl Engine { fn _maps_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Map::default(); - let mut call = self.hub.maps().patch(&request, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Map::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "description" => { request.description = Some(value.unwrap_or("").to_string()); }, @@ -1764,31 +1872,11 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok(mut response) => { - None - } - } - } - } - - fn _maps_permissions_batch_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::PermissionsBatchDeleteRequest::default(); - let mut call = self.hub.maps().permissions_batch_delete(&request, &self.opt.arg_id); + let mut call = self.hub.maps().patch(request, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1810,14 +1898,46 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok(mut response) => { + None + } + } + } + } + + fn _maps_permissions_batch_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::PermissionsBatchDeleteRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "ids" => { if request.ids.is_none() { request.ids = Some(Default::default()); @@ -1825,15 +1945,40 @@ impl Engine { request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.maps().permissions_batch_delete(request, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1850,8 +1995,30 @@ impl Engine { fn _maps_permissions_batch_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::PermissionsBatchUpdateRequest::default(); - let mut call = self.hub.maps().permissions_batch_update(&request, &self.opt.arg_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.maps().permissions_batch_update(request, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1873,24 +2040,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1934,6 +2091,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1980,6 +2140,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2023,6 +2186,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2039,8 +2205,39 @@ impl Engine { fn _projects_icons_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Icon::default(); - let mut call = self.hub.projects().icons_create(&request, &self.opt.arg_project_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "description" => { + request.description = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.projects().icons_create(request, &self.opt.arg_project_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2062,28 +2259,6 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "description" => { - request.description = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = if self.opt.cmd_simple { "simple" @@ -2098,6 +2273,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -2146,6 +2324,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2199,6 +2380,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2242,6 +2426,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2285,6 +2472,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2301,37 +2491,24 @@ impl Engine { fn _raster_collections_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::RasterCollection::default(); - let mut call = self.hub.raster_collections().create(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::RasterCollection::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "attribution" => { request.attribution = Some(value.unwrap_or("").to_string()); }, @@ -2384,15 +2561,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.raster_collections().create(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2436,6 +2638,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2477,6 +2682,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2559,6 +2767,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2608,6 +2819,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2624,37 +2838,24 @@ impl Engine { fn _raster_collections_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::RasterCollection::default(); - let mut call = self.hub.raster_collections().patch(&request, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::RasterCollection::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "attribution" => { request.attribution = Some(value.unwrap_or("").to_string()); }, @@ -2707,31 +2908,11 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok(mut response) => { - None - } - } - } - } - - fn _raster_collections_permissions_batch_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::PermissionsBatchDeleteRequest::default(); - let mut call = self.hub.raster_collections().permissions_batch_delete(&request, &self.opt.arg_id); + let mut call = self.hub.raster_collections().patch(request, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2753,14 +2934,46 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok(mut response) => { + None + } + } + } + } + + fn _raster_collections_permissions_batch_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::PermissionsBatchDeleteRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "ids" => { if request.ids.is_none() { request.ids = Some(Default::default()); @@ -2768,15 +2981,40 @@ impl Engine { request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.raster_collections().permissions_batch_delete(request, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2793,8 +3031,30 @@ impl Engine { fn _raster_collections_permissions_batch_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::PermissionsBatchUpdateRequest::default(); - let mut call = self.hub.raster_collections().permissions_batch_update(&request, &self.opt.arg_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.raster_collections().permissions_batch_update(request, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2816,24 +3076,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2877,6 +3127,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2920,6 +3173,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2936,8 +3192,36 @@ impl Engine { fn _raster_collections_rasters_batch_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::RasterCollectionsRasterBatchDeleteRequest::default(); - let mut call = self.hub.raster_collections().rasters_batch_delete(&request, &self.opt.arg_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "ids" => { + if request.ids.is_none() { + request.ids = Some(Default::default()); + } + request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.raster_collections().rasters_batch_delete(request, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2959,30 +3243,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "ids" => { - if request.ids.is_none() { - request.ids = Some(Default::default()); - } - request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2999,8 +3267,36 @@ impl Engine { fn _raster_collections_rasters_batch_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::RasterCollectionsRastersBatchInsertRequest::default(); - let mut call = self.hub.raster_collections().rasters_batch_insert(&request, &self.opt.arg_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "ids" => { + if request.ids.is_none() { + request.ids = Some(Default::default()); + } + request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.raster_collections().rasters_batch_insert(request, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -3022,30 +3318,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "ids" => { - if request.ids.is_none() { - request.ids = Some(Default::default()); - } - request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3122,6 +3402,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3165,6 +3448,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -3215,6 +3501,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), "resumable" => call.upload_resumable(input_file.unwrap(), mime_type.unwrap()), @@ -3257,6 +3546,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3336,6 +3628,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3385,6 +3680,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3401,43 +3699,30 @@ impl Engine { fn _rasters_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Raster::default(); - let mut call = self.hub.rasters().patch(&request, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Raster::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_acquisition_time_init(request: &mut api::Raster) { if request.acquisition_time.is_none() { request.acquisition_time = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "acquisition-time.start" => { request_acquisition_time_init(&mut request); request.acquisition_time.as_mut().unwrap().start = Some(value.unwrap_or("").to_string()); @@ -3518,31 +3803,11 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok(mut response) => { - None - } - } - } - } - - fn _rasters_permissions_batch_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::PermissionsBatchDeleteRequest::default(); - let mut call = self.hub.rasters().permissions_batch_delete(&request, &self.opt.arg_id); + let mut call = self.hub.rasters().patch(request, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -3564,14 +3829,46 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok(mut response) => { + None + } + } + } + } + + fn _rasters_permissions_batch_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::PermissionsBatchDeleteRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "ids" => { if request.ids.is_none() { request.ids = Some(Default::default()); @@ -3579,15 +3876,40 @@ impl Engine { request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.rasters().permissions_batch_delete(request, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3604,8 +3926,30 @@ impl Engine { fn _rasters_permissions_batch_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::PermissionsBatchUpdateRequest::default(); - let mut call = self.hub.rasters().permissions_batch_update(&request, &self.opt.arg_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.rasters().permissions_batch_update(request, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -3627,24 +3971,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3688,6 +4022,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3731,6 +4068,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3747,43 +4087,30 @@ impl Engine { fn _rasters_upload(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Raster::default(); - let mut call = self.hub.rasters().upload(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Raster::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_acquisition_time_init(request: &mut api::Raster) { if request.acquisition_time.is_none() { request.acquisition_time = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "acquisition-time.start" => { request_acquisition_time_init(&mut request); request.acquisition_time.as_mut().unwrap().start = Some(value.unwrap_or("").to_string()); @@ -3864,33 +4191,11 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _tables_create(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::Table::default(); - let mut call = self.hub.tables().create(&request); + let mut call = self.hub.rasters().upload(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -3912,20 +4217,54 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _tables_create(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::Table::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_schema_init(request: &mut api::Table) { if request.schema.is_none() { request.schema = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "schema.primary-geometry" => { request_schema_init(&mut request); request.schema.as_mut().unwrap().primary_geometry = Some(value.unwrap_or("").to_string()); @@ -3998,15 +4337,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.tables().create(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4050,6 +4414,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -4064,8 +4431,42 @@ impl Engine { fn _tables_features_batch_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::FeaturesBatchDeleteRequest::default(); - let mut call = self.hub.tables().features_batch_delete(&request, &self.opt.arg_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "gx-ids" => { + if request.gx_ids.is_none() { + request.gx_ids = Some(Default::default()); + } + request.gx_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "primary-keys" => { + if request.primary_keys.is_none() { + request.primary_keys = Some(Default::default()); + } + request.primary_keys.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.tables().features_batch_delete(request, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -4087,36 +4488,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "gx-ids" => { - if request.gx_ids.is_none() { - request.gx_ids = Some(Default::default()); - } - request.gx_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "primary-keys" => { - if request.primary_keys.is_none() { - request.primary_keys = Some(Default::default()); - } - request.primary_keys.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -4131,8 +4510,33 @@ impl Engine { fn _tables_features_batch_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::FeaturesBatchInsertRequest::default(); - let mut call = self.hub.tables().features_batch_insert(&request, &self.opt.arg_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "normalize-geometries" => { + request.normalize_geometries = Some(arg_from_str(value.unwrap_or("false"), err, "normalize-geometries", "boolean")); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.tables().features_batch_insert(request, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -4154,27 +4558,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "normalize-geometries" => { - request.normalize_geometries = Some(arg_from_str(value.unwrap_or("false"), err, "normalize-geometries", "boolean")); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -4189,8 +4580,33 @@ impl Engine { fn _tables_features_batch_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::FeaturesBatchPatchRequest::default(); - let mut call = self.hub.tables().features_batch_patch(&request, &self.opt.arg_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "normalize-geometries" => { + request.normalize_geometries = Some(arg_from_str(value.unwrap_or("false"), err, "normalize-geometries", "boolean")); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.tables().features_batch_patch(request, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -4212,27 +4628,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "normalize-geometries" => { - request.normalize_geometries = Some(arg_from_str(value.unwrap_or("false"), err, "normalize-geometries", "boolean")); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -4280,6 +4683,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4350,6 +4756,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4402,6 +4811,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), "resumable" => call.upload_resumable(input_file.unwrap(), mime_type.unwrap()), @@ -4447,6 +4859,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4529,6 +4944,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4578,6 +4996,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4594,43 +5015,30 @@ impl Engine { fn _tables_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Table::default(); - let mut call = self.hub.tables().patch(&request, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Table::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_schema_init(request: &mut api::Table) { if request.schema.is_none() { request.schema = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "schema.primary-geometry" => { request_schema_init(&mut request); request.schema.as_mut().unwrap().primary_geometry = Some(value.unwrap_or("").to_string()); @@ -4703,31 +5111,11 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok(mut response) => { - None - } - } - } - } - - fn _tables_permissions_batch_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::PermissionsBatchDeleteRequest::default(); - let mut call = self.hub.tables().permissions_batch_delete(&request, &self.opt.arg_id); + let mut call = self.hub.tables().patch(request, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -4749,14 +5137,46 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok(mut response) => { + None + } + } + } + } + + fn _tables_permissions_batch_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::PermissionsBatchDeleteRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "ids" => { if request.ids.is_none() { request.ids = Some(Default::default()); @@ -4764,15 +5184,40 @@ impl Engine { request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.tables().permissions_batch_delete(request, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4789,8 +5234,30 @@ impl Engine { fn _tables_permissions_batch_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::PermissionsBatchUpdateRequest::default(); - let mut call = self.hub.tables().permissions_batch_update(&request, &self.opt.arg_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.tables().permissions_batch_update(request, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -4812,24 +5279,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4873,6 +5330,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4916,6 +5376,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4932,43 +5395,30 @@ impl Engine { fn _tables_upload(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Table::default(); - let mut call = self.hub.tables().upload(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Table::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_schema_init(request: &mut api::Table) { if request.schema.is_none() { request.schema = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "schema.primary-geometry" => { request_schema_init(&mut request); request.schema.as_mut().unwrap().primary_geometry = Some(value.unwrap_or("").to_string()); @@ -5041,15 +5491,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.tables().upload(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5325,6 +5800,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -5332,8 +5808,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/mapsengine1/Cargo.toml b/gen/mapsengine1/Cargo.toml index 10ba781eda..b6d8033a90 100644 --- a/gen/mapsengine1/Cargo.toml +++ b/gen/mapsengine1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-mapsengine1" -version = "0.1.5+20150414" +version = "0.1.6+20150414" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with Maps Engine (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/mapsengine1" diff --git a/gen/mapsengine1/README.md b/gen/mapsengine1/README.md index 4067e4db4e..2738129811 100644 --- a/gen/mapsengine1/README.md +++ b/gen/mapsengine1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-mapsengine1` library allows access to all features of the *Google Maps Engine* service. -This documentation was generated from *Maps Engine* crate version *0.1.5+20150414*, where *20150414* is the exact revision of the *mapsengine:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *Maps Engine* crate version *0.1.6+20150414*, where *20150414* is the exact revision of the *mapsengine:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *Maps Engine* *v1* API can be found at the [official documentation site](https://developers.google.com/maps-engine/). @@ -150,14 +150,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/mapsengine1/src/cmn.rs b/gen/mapsengine1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/mapsengine1/src/cmn.rs +++ b/gen/mapsengine1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/mapsengine1/src/lib.rs b/gen/mapsengine1/src/lib.rs index 9ae89c4829..9aa2863ad8 100644 --- a/gen/mapsengine1/src/lib.rs +++ b/gen/mapsengine1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Maps Engine* crate version *0.1.5+20150414*, where *20150414* is the exact revision of the *mapsengine:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *Maps Engine* crate version *0.1.6+20150414*, where *20150414* is the exact revision of the *mapsengine:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *Maps Engine* *v1* API can be found at the //! [official documentation site](https://developers.google.com/maps-engine/). @@ -151,14 +151,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -246,7 +247,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -337,14 +338,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -365,7 +367,7 @@ impl<'a, C, A> MapsEngine<C, A> MapsEngine { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -392,7 +394,7 @@ impl<'a, C, A> MapsEngine<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -2413,10 +2415,10 @@ impl<'a, C, A> LayerMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn create(&self, request: &Layer) -> LayerCreateCall<'a, C, A> { + pub fn create(&self, request: Layer) -> LayerCreateCall<'a, C, A> { LayerCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _process: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -2484,10 +2486,10 @@ impl<'a, C, A> LayerMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The ID of the asset from which permissions will be removed. - pub fn permissions_batch_delete(&self, request: &PermissionsBatchDeleteRequest, id: &str) -> LayerPermissionBatchDeleteCall<'a, C, A> { + pub fn permissions_batch_delete(&self, request: PermissionsBatchDeleteRequest, id: &str) -> LayerPermissionBatchDeleteCall<'a, C, A> { LayerPermissionBatchDeleteCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2505,10 +2507,10 @@ impl<'a, C, A> LayerMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The ID of the asset to which permissions will be added. - pub fn permissions_batch_update(&self, request: &PermissionsBatchUpdateRequest, id: &str) -> LayerPermissionBatchUpdateCall<'a, C, A> { + pub fn permissions_batch_update(&self, request: PermissionsBatchUpdateRequest, id: &str) -> LayerPermissionBatchUpdateCall<'a, C, A> { LayerPermissionBatchUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2585,10 +2587,10 @@ impl<'a, C, A> LayerMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The ID of the layer. - pub fn patch(&self, request: &Layer, id: &str) -> LayerPatchCall<'a, C, A> { + pub fn patch(&self, request: Layer, id: &str) -> LayerPatchCall<'a, C, A> { LayerPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2681,10 +2683,10 @@ impl<'a, C, A> RasterMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The ID of the asset to which permissions will be added. - pub fn permissions_batch_update(&self, request: &PermissionsBatchUpdateRequest, id: &str) -> RasterPermissionBatchUpdateCall<'a, C, A> { + pub fn permissions_batch_update(&self, request: PermissionsBatchUpdateRequest, id: &str) -> RasterPermissionBatchUpdateCall<'a, C, A> { RasterPermissionBatchUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2700,10 +2702,10 @@ impl<'a, C, A> RasterMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The ID of the raster. - pub fn patch(&self, request: &Raster, id: &str) -> RasterPatchCall<'a, C, A> { + pub fn patch(&self, request: Raster, id: &str) -> RasterPatchCall<'a, C, A> { RasterPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2753,10 +2755,10 @@ impl<'a, C, A> RasterMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The ID of the asset from which permissions will be removed. - pub fn permissions_batch_delete(&self, request: &PermissionsBatchDeleteRequest, id: &str) -> RasterPermissionBatchDeleteCall<'a, C, A> { + pub fn permissions_batch_delete(&self, request: PermissionsBatchDeleteRequest, id: &str) -> RasterPermissionBatchDeleteCall<'a, C, A> { RasterPermissionBatchDeleteCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2853,10 +2855,10 @@ impl<'a, C, A> RasterMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn upload(&self, request: &Raster) -> RasterUploadCall<'a, C, A> { + pub fn upload(&self, request: Raster) -> RasterUploadCall<'a, C, A> { RasterUploadCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3095,10 +3097,10 @@ impl<'a, C, A> TableMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The ID of the table to append the features to. - pub fn features_batch_insert(&self, request: &FeaturesBatchInsertRequest, id: &str) -> TableFeatureBatchInsertCall<'a, C, A> { + pub fn features_batch_insert(&self, request: FeaturesBatchInsertRequest, id: &str) -> TableFeatureBatchInsertCall<'a, C, A> { TableFeatureBatchInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3157,10 +3159,10 @@ impl<'a, C, A> TableMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The ID of the table that contains the features to be deleted. - pub fn features_batch_delete(&self, request: &FeaturesBatchDeleteRequest, id: &str) -> TableFeatureBatchDeleteCall<'a, C, A> { + pub fn features_batch_delete(&self, request: FeaturesBatchDeleteRequest, id: &str) -> TableFeatureBatchDeleteCall<'a, C, A> { TableFeatureBatchDeleteCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3240,10 +3242,10 @@ impl<'a, C, A> TableMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The ID of the asset to which permissions will be added. - pub fn permissions_batch_update(&self, request: &PermissionsBatchUpdateRequest, id: &str) -> TablePermissionBatchUpdateCall<'a, C, A> { + pub fn permissions_batch_update(&self, request: PermissionsBatchUpdateRequest, id: &str) -> TablePermissionBatchUpdateCall<'a, C, A> { TablePermissionBatchUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3260,10 +3262,10 @@ impl<'a, C, A> TableMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn upload(&self, request: &Table) -> TableUploadCall<'a, C, A> { + pub fn upload(&self, request: Table) -> TableUploadCall<'a, C, A> { TableUploadCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3292,10 +3294,10 @@ impl<'a, C, A> TableMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The ID of the table containing the features to be patched. - pub fn features_batch_patch(&self, request: &FeaturesBatchPatchRequest, id: &str) -> TableFeatureBatchPatchCall<'a, C, A> { + pub fn features_batch_patch(&self, request: FeaturesBatchPatchRequest, id: &str) -> TableFeatureBatchPatchCall<'a, C, A> { TableFeatureBatchPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3311,10 +3313,10 @@ impl<'a, C, A> TableMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The ID of the table. - pub fn patch(&self, request: &Table, id: &str) -> TablePatchCall<'a, C, A> { + pub fn patch(&self, request: Table, id: &str) -> TablePatchCall<'a, C, A> { TablePatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3330,10 +3332,10 @@ impl<'a, C, A> TableMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The ID of the asset from which permissions will be removed. - pub fn permissions_batch_delete(&self, request: &PermissionsBatchDeleteRequest, id: &str) -> TablePermissionBatchDeleteCall<'a, C, A> { + pub fn permissions_batch_delete(&self, request: PermissionsBatchDeleteRequest, id: &str) -> TablePermissionBatchDeleteCall<'a, C, A> { TablePermissionBatchDeleteCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3348,10 +3350,10 @@ impl<'a, C, A> TableMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn create(&self, request: &Table) -> TableCreateCall<'a, C, A> { + pub fn create(&self, request: Table) -> TableCreateCall<'a, C, A> { TableCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3485,10 +3487,10 @@ impl<'a, C, A> MapMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The ID of the map. - pub fn patch(&self, request: &Map, id: &str) -> MapPatchCall<'a, C, A> { + pub fn patch(&self, request: Map, id: &str) -> MapPatchCall<'a, C, A> { MapPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3506,10 +3508,10 @@ impl<'a, C, A> MapMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The ID of the asset to which permissions will be added. - pub fn permissions_batch_update(&self, request: &PermissionsBatchUpdateRequest, id: &str) -> MapPermissionBatchUpdateCall<'a, C, A> { + pub fn permissions_batch_update(&self, request: PermissionsBatchUpdateRequest, id: &str) -> MapPermissionBatchUpdateCall<'a, C, A> { MapPermissionBatchUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3593,10 +3595,10 @@ impl<'a, C, A> MapMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn create(&self, request: &Map) -> MapCreateCall<'a, C, A> { + pub fn create(&self, request: Map) -> MapCreateCall<'a, C, A> { MapCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3646,10 +3648,10 @@ impl<'a, C, A> MapMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The ID of the asset from which permissions will be removed. - pub fn permissions_batch_delete(&self, request: &PermissionsBatchDeleteRequest, id: &str) -> MapPermissionBatchDeleteCall<'a, C, A> { + pub fn permissions_batch_delete(&self, request: PermissionsBatchDeleteRequest, id: &str) -> MapPermissionBatchDeleteCall<'a, C, A> { MapPermissionBatchDeleteCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3705,10 +3707,10 @@ impl<'a, C, A> RasterCollectionMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn create(&self, request: &RasterCollection) -> RasterCollectionCreateCall<'a, C, A> { + pub fn create(&self, request: RasterCollection) -> RasterCollectionCreateCall<'a, C, A> { RasterCollectionCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3723,10 +3725,10 @@ impl<'a, C, A> RasterCollectionMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The ID of the asset from which permissions will be removed. - pub fn permissions_batch_delete(&self, request: &PermissionsBatchDeleteRequest, id: &str) -> RasterCollectionPermissionBatchDeleteCall<'a, C, A> { + pub fn permissions_batch_delete(&self, request: PermissionsBatchDeleteRequest, id: &str) -> RasterCollectionPermissionBatchDeleteCall<'a, C, A> { RasterCollectionPermissionBatchDeleteCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3742,10 +3744,10 @@ impl<'a, C, A> RasterCollectionMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The ID of the raster collection. - pub fn patch(&self, request: &RasterCollection, id: &str) -> RasterCollectionPatchCall<'a, C, A> { + pub fn patch(&self, request: RasterCollection, id: &str) -> RasterCollectionPatchCall<'a, C, A> { RasterCollectionPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3797,10 +3799,10 @@ impl<'a, C, A> RasterCollectionMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The ID of the asset to which permissions will be added. - pub fn permissions_batch_update(&self, request: &PermissionsBatchUpdateRequest, id: &str) -> RasterCollectionPermissionBatchUpdateCall<'a, C, A> { + pub fn permissions_batch_update(&self, request: PermissionsBatchUpdateRequest, id: &str) -> RasterCollectionPermissionBatchUpdateCall<'a, C, A> { RasterCollectionPermissionBatchUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3879,10 +3881,10 @@ impl<'a, C, A> RasterCollectionMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The ID of the raster collection to which these rasters belong. - pub fn rasters_batch_insert(&self, request: &RasterCollectionsRastersBatchInsertRequest, id: &str) -> RasterCollectionRasterBatchInsertCall<'a, C, A> { + pub fn rasters_batch_insert(&self, request: RasterCollectionsRastersBatchInsertRequest, id: &str) -> RasterCollectionRasterBatchInsertCall<'a, C, A> { RasterCollectionRasterBatchInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3900,10 +3902,10 @@ impl<'a, C, A> RasterCollectionMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The ID of the raster collection to which these rasters belong. - pub fn rasters_batch_delete(&self, request: &RasterCollectionsRasterBatchDeleteRequest, id: &str) -> RasterCollectionRasterBatchDeleteCall<'a, C, A> { + pub fn rasters_batch_delete(&self, request: RasterCollectionsRasterBatchDeleteRequest, id: &str) -> RasterCollectionRasterBatchDeleteCall<'a, C, A> { RasterCollectionRasterBatchDeleteCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -4041,10 +4043,10 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `projectId` - The ID of the project. - pub fn icons_create(&self, request: &Icon, project_id: &str) -> ProjectIconCreateCall<'a, C, A> { + pub fn icons_create(&self, request: Icon, project_id: &str) -> ProjectIconCreateCall<'a, C, A> { ProjectIconCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _project_id: project_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -4237,12 +4239,17 @@ impl<'a, C, A> LayerUnpublishCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4251,7 +4258,7 @@ impl<'a, C, A> LayerUnpublishCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4476,12 +4483,17 @@ impl<'a, C, A> LayerPublishCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4490,7 +4502,7 @@ impl<'a, C, A> LayerPublishCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4706,12 +4718,17 @@ impl<'a, C, A> LayerListPublishedCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4720,7 +4737,7 @@ impl<'a, C, A> LayerListPublishedCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4838,7 +4855,7 @@ impl<'a, C, A> LayerListPublishedCall<'a, C, A> where C: BorrowMut<hyper::Client /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.layers().create(&req) +/// let result = hub.layers().create(req) /// .process(false) /// .doit(); /// # } @@ -4945,12 +4962,17 @@ impl<'a, C, A> LayerCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4959,7 +4981,7 @@ impl<'a, C, A> LayerCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4977,8 +4999,8 @@ impl<'a, C, A> LayerCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Layer) -> LayerCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Layer) -> LayerCreateCall<'a, C, A> { + self._request = new_value; self } /// Whether to queue the created layer for processing. @@ -5185,12 +5207,17 @@ impl<'a, C, A> LayerGetPublishedCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5199,7 +5226,7 @@ impl<'a, C, A> LayerGetPublishedCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5418,12 +5445,17 @@ impl<'a, C, A> LayerDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -5647,12 +5679,17 @@ impl<'a, C, A> LayerGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5661,7 +5698,7 @@ impl<'a, C, A> LayerGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5775,7 +5812,7 @@ impl<'a, C, A> LayerGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.layers().permissions_batch_delete(&req, "id") +/// let result = hub.layers().permissions_batch_delete(req, "id") /// .doit(); /// # } /// ``` @@ -5903,12 +5940,17 @@ impl<'a, C, A> LayerPermissionBatchDeleteCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5917,7 +5959,7 @@ impl<'a, C, A> LayerPermissionBatchDeleteCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5935,8 +5977,8 @@ impl<'a, C, A> LayerPermissionBatchDeleteCall<'a, C, A> where C: BorrowMut<hyper /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PermissionsBatchDeleteRequest) -> LayerPermissionBatchDeleteCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PermissionsBatchDeleteRequest) -> LayerPermissionBatchDeleteCall<'a, C, A> { + self._request = new_value; self } /// The ID of the asset from which permissions will be removed. @@ -6035,7 +6077,7 @@ impl<'a, C, A> LayerPermissionBatchDeleteCall<'a, C, A> where C: BorrowMut<hyper /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.layers().permissions_batch_update(&req, "id") +/// let result = hub.layers().permissions_batch_update(req, "id") /// .doit(); /// # } /// ``` @@ -6163,12 +6205,17 @@ impl<'a, C, A> LayerPermissionBatchUpdateCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6177,7 +6224,7 @@ impl<'a, C, A> LayerPermissionBatchUpdateCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6195,8 +6242,8 @@ impl<'a, C, A> LayerPermissionBatchUpdateCall<'a, C, A> where C: BorrowMut<hyper /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PermissionsBatchUpdateRequest) -> LayerPermissionBatchUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PermissionsBatchUpdateRequest) -> LayerPermissionBatchUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the asset to which permissions will be added. @@ -6445,12 +6492,17 @@ impl<'a, C, A> LayerListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6459,7 +6511,7 @@ impl<'a, C, A> LayerListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6769,12 +6821,17 @@ impl<'a, C, A> LayerParentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6783,7 +6840,7 @@ impl<'a, C, A> LayerParentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7017,12 +7074,17 @@ impl<'a, C, A> LayerCancelProcessingCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7031,7 +7093,7 @@ impl<'a, C, A> LayerCancelProcessingCall<'a, C, A> where C: BorrowMut<hyper::Cli Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7138,7 +7200,7 @@ impl<'a, C, A> LayerCancelProcessingCall<'a, C, A> where C: BorrowMut<hyper::Cli /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.layers().patch(&req, "id") +/// let result = hub.layers().patch(req, "id") /// .doit(); /// # } /// ``` @@ -7265,12 +7327,17 @@ impl<'a, C, A> LayerPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -7287,8 +7354,8 @@ impl<'a, C, A> LayerPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Layer) -> LayerPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Layer) -> LayerPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the layer. @@ -7498,12 +7565,17 @@ impl<'a, C, A> LayerPermissionListCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7512,7 +7584,7 @@ impl<'a, C, A> LayerPermissionListCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7732,12 +7804,17 @@ impl<'a, C, A> LayerProcesCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7746,7 +7823,7 @@ impl<'a, C, A> LayerProcesCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7855,7 +7932,7 @@ impl<'a, C, A> LayerProcesCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.rasters().permissions_batch_update(&req, "id") +/// let result = hub.rasters().permissions_batch_update(req, "id") /// .doit(); /// # } /// ``` @@ -7983,12 +8060,17 @@ impl<'a, C, A> RasterPermissionBatchUpdateCall<'a, C, A> where C: BorrowMut<hype if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7997,7 +8079,7 @@ impl<'a, C, A> RasterPermissionBatchUpdateCall<'a, C, A> where C: BorrowMut<hype Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8015,8 +8097,8 @@ impl<'a, C, A> RasterPermissionBatchUpdateCall<'a, C, A> where C: BorrowMut<hype /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PermissionsBatchUpdateRequest) -> RasterPermissionBatchUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PermissionsBatchUpdateRequest) -> RasterPermissionBatchUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the asset to which permissions will be added. @@ -8113,7 +8195,7 @@ impl<'a, C, A> RasterPermissionBatchUpdateCall<'a, C, A> where C: BorrowMut<hype /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.rasters().patch(&req, "id") +/// let result = hub.rasters().patch(req, "id") /// .doit(); /// # } /// ``` @@ -8240,12 +8322,17 @@ impl<'a, C, A> RasterPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -8262,8 +8349,8 @@ impl<'a, C, A> RasterPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Raster) -> RasterPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Raster) -> RasterPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the raster. @@ -8473,12 +8560,17 @@ impl<'a, C, A> RasterPermissionListCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8487,7 +8579,7 @@ impl<'a, C, A> RasterPermissionListCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8706,12 +8798,17 @@ impl<'a, C, A> RasterDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -8817,7 +8914,7 @@ impl<'a, C, A> RasterDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.rasters().permissions_batch_delete(&req, "id") +/// let result = hub.rasters().permissions_batch_delete(req, "id") /// .doit(); /// # } /// ``` @@ -8945,12 +9042,17 @@ impl<'a, C, A> RasterPermissionBatchDeleteCall<'a, C, A> where C: BorrowMut<hype if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8959,7 +9061,7 @@ impl<'a, C, A> RasterPermissionBatchDeleteCall<'a, C, A> where C: BorrowMut<hype Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8977,8 +9079,8 @@ impl<'a, C, A> RasterPermissionBatchDeleteCall<'a, C, A> where C: BorrowMut<hype /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PermissionsBatchDeleteRequest) -> RasterPermissionBatchDeleteCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PermissionsBatchDeleteRequest) -> RasterPermissionBatchDeleteCall<'a, C, A> { + self._request = new_value; self } /// The ID of the asset from which permissions will be removed. @@ -9116,14 +9218,15 @@ impl<'a, C, A> RasterFileInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, } - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/mapsengine/v1/rasters/{id}/files".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/mapsengine/v1/rasters/{id}/files".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/mapsengine/v1/rasters/{id}/files".to_string() + ("https://www.googleapis.com/resumable/upload/mapsengine/v1/rasters/{id}/files".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } @@ -9229,12 +9332,17 @@ impl<'a, C, A> RasterFileInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -9244,9 +9352,9 @@ impl<'a, C, A> RasterFileInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -9256,7 +9364,7 @@ impl<'a, C, A> RasterFileInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -9533,12 +9641,17 @@ impl<'a, C, A> RasterProcesCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9547,7 +9660,7 @@ impl<'a, C, A> RasterProcesCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9767,12 +9880,17 @@ impl<'a, C, A> RasterGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9781,7 +9899,7 @@ impl<'a, C, A> RasterGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10037,12 +10155,17 @@ impl<'a, C, A> RasterListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10051,7 +10174,7 @@ impl<'a, C, A> RasterListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10241,7 +10364,7 @@ impl<'a, C, A> RasterListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.rasters().upload(&req) +/// let result = hub.rasters().upload(req) /// .doit(); /// # } /// ``` @@ -10343,12 +10466,17 @@ impl<'a, C, A> RasterUploadCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10357,7 +10485,7 @@ impl<'a, C, A> RasterUploadCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10375,8 +10503,8 @@ impl<'a, C, A> RasterUploadCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Raster) -> RasterUploadCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Raster) -> RasterUploadCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -10586,12 +10714,17 @@ impl<'a, C, A> RasterParentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10600,7 +10733,7 @@ impl<'a, C, A> RasterParentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10834,12 +10967,17 @@ impl<'a, C, A> AssetPermissionListCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10848,7 +10986,7 @@ impl<'a, C, A> AssetPermissionListCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11107,12 +11245,17 @@ impl<'a, C, A> AssetListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11121,7 +11264,7 @@ impl<'a, C, A> AssetListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11422,12 +11565,17 @@ impl<'a, C, A> AssetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11436,7 +11584,7 @@ impl<'a, C, A> AssetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11666,12 +11814,17 @@ impl<'a, C, A> AssetParentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11680,7 +11833,7 @@ impl<'a, C, A> AssetParentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11913,12 +12066,17 @@ impl<'a, C, A> TableDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -12066,14 +12224,15 @@ impl<'a, C, A> TableFileInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, } - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/mapsengine/v1/tables/{id}/files".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/mapsengine/v1/tables/{id}/files".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/mapsengine/v1/tables/{id}/files".to_string() + ("https://www.googleapis.com/resumable/upload/mapsengine/v1/tables/{id}/files".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } @@ -12179,12 +12338,17 @@ impl<'a, C, A> TableFileInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -12194,9 +12358,9 @@ impl<'a, C, A> TableFileInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -12206,7 +12370,7 @@ impl<'a, C, A> TableFileInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -12378,7 +12542,7 @@ impl<'a, C, A> TableFileInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.tables().features_batch_insert(&req, "id") +/// let result = hub.tables().features_batch_insert(req, "id") /// .doit(); /// # } /// ``` @@ -12505,12 +12669,17 @@ impl<'a, C, A> TableFeatureBatchInsertCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -12527,8 +12696,8 @@ impl<'a, C, A> TableFeatureBatchInsertCall<'a, C, A> where C: BorrowMut<hyper::C /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &FeaturesBatchInsertRequest) -> TableFeatureBatchInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: FeaturesBatchInsertRequest) -> TableFeatureBatchInsertCall<'a, C, A> { + self._request = new_value; self } /// The ID of the table to append the features to. @@ -12777,12 +12946,17 @@ impl<'a, C, A> TableListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12791,7 +12965,7 @@ impl<'a, C, A> TableListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13096,12 +13270,17 @@ impl<'a, C, A> TableGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13110,7 +13289,7 @@ impl<'a, C, A> TableGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13223,7 +13402,7 @@ impl<'a, C, A> TableGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.tables().features_batch_delete(&req, "id") +/// let result = hub.tables().features_batch_delete(req, "id") /// .doit(); /// # } /// ``` @@ -13350,12 +13529,17 @@ impl<'a, C, A> TableFeatureBatchDeleteCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -13372,8 +13556,8 @@ impl<'a, C, A> TableFeatureBatchDeleteCall<'a, C, A> where C: BorrowMut<hyper::C /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &FeaturesBatchDeleteRequest) -> TableFeatureBatchDeleteCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: FeaturesBatchDeleteRequest) -> TableFeatureBatchDeleteCall<'a, C, A> { + self._request = new_value; self } /// The ID of the table that contains the features to be deleted. @@ -13628,12 +13812,17 @@ impl<'a, C, A> TableFeatureListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13642,7 +13831,7 @@ impl<'a, C, A> TableFeatureListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13925,12 +14114,17 @@ impl<'a, C, A> TableProcesCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13939,7 +14133,7 @@ impl<'a, C, A> TableProcesCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14169,12 +14363,17 @@ impl<'a, C, A> TableParentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14183,7 +14382,7 @@ impl<'a, C, A> TableParentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14306,7 +14505,7 @@ impl<'a, C, A> TableParentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.tables().permissions_batch_update(&req, "id") +/// let result = hub.tables().permissions_batch_update(req, "id") /// .doit(); /// # } /// ``` @@ -14434,12 +14633,17 @@ impl<'a, C, A> TablePermissionBatchUpdateCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14448,7 +14652,7 @@ impl<'a, C, A> TablePermissionBatchUpdateCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14466,8 +14670,8 @@ impl<'a, C, A> TablePermissionBatchUpdateCall<'a, C, A> where C: BorrowMut<hyper /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PermissionsBatchUpdateRequest) -> TablePermissionBatchUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PermissionsBatchUpdateRequest) -> TablePermissionBatchUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the asset to which permissions will be added. @@ -14566,7 +14770,7 @@ impl<'a, C, A> TablePermissionBatchUpdateCall<'a, C, A> where C: BorrowMut<hyper /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.tables().upload(&req) +/// let result = hub.tables().upload(req) /// .doit(); /// # } /// ``` @@ -14668,12 +14872,17 @@ impl<'a, C, A> TableUploadCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14682,7 +14891,7 @@ impl<'a, C, A> TableUploadCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14700,8 +14909,8 @@ impl<'a, C, A> TableUploadCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Table) -> TableUploadCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Table) -> TableUploadCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -14802,7 +15011,7 @@ impl<'a, C, A> TableUploadCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.tables().features_batch_patch(&req, "id") +/// let result = hub.tables().features_batch_patch(req, "id") /// .doit(); /// # } /// ``` @@ -14929,12 +15138,17 @@ impl<'a, C, A> TableFeatureBatchPatchCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -14951,8 +15165,8 @@ impl<'a, C, A> TableFeatureBatchPatchCall<'a, C, A> where C: BorrowMut<hyper::Cl /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &FeaturesBatchPatchRequest) -> TableFeatureBatchPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: FeaturesBatchPatchRequest) -> TableFeatureBatchPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the table containing the features to be patched. @@ -15049,7 +15263,7 @@ impl<'a, C, A> TableFeatureBatchPatchCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.tables().patch(&req, "id") +/// let result = hub.tables().patch(req, "id") /// .doit(); /// # } /// ``` @@ -15176,12 +15390,17 @@ impl<'a, C, A> TablePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -15198,8 +15417,8 @@ impl<'a, C, A> TablePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Table) -> TablePatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Table) -> TablePatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the table. @@ -15296,7 +15515,7 @@ impl<'a, C, A> TablePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.tables().permissions_batch_delete(&req, "id") +/// let result = hub.tables().permissions_batch_delete(req, "id") /// .doit(); /// # } /// ``` @@ -15424,12 +15643,17 @@ impl<'a, C, A> TablePermissionBatchDeleteCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15438,7 +15662,7 @@ impl<'a, C, A> TablePermissionBatchDeleteCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15456,8 +15680,8 @@ impl<'a, C, A> TablePermissionBatchDeleteCall<'a, C, A> where C: BorrowMut<hyper /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PermissionsBatchDeleteRequest) -> TablePermissionBatchDeleteCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PermissionsBatchDeleteRequest) -> TablePermissionBatchDeleteCall<'a, C, A> { + self._request = new_value; self } /// The ID of the asset from which permissions will be removed. @@ -15554,7 +15778,7 @@ impl<'a, C, A> TablePermissionBatchDeleteCall<'a, C, A> where C: BorrowMut<hyper /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.tables().create(&req) +/// let result = hub.tables().create(req) /// .doit(); /// # } /// ``` @@ -15656,12 +15880,17 @@ impl<'a, C, A> TableCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15670,7 +15899,7 @@ impl<'a, C, A> TableCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15688,8 +15917,8 @@ impl<'a, C, A> TableCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Table) -> TableCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Table) -> TableCreateCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -15889,12 +16118,17 @@ impl<'a, C, A> TablePermissionListCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15903,7 +16137,7 @@ impl<'a, C, A> TablePermissionListCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16135,12 +16369,17 @@ impl<'a, C, A> TableFeatureGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16149,7 +16388,7 @@ impl<'a, C, A> TableFeatureGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16432,12 +16671,17 @@ impl<'a, C, A> MapListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16446,7 +16690,7 @@ impl<'a, C, A> MapListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16735,12 +16979,17 @@ impl<'a, C, A> MapListPublishedCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16749,7 +16998,7 @@ impl<'a, C, A> MapListPublishedCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16867,7 +17116,7 @@ impl<'a, C, A> MapListPublishedCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.maps().patch(&req, "id") +/// let result = hub.maps().patch(req, "id") /// .doit(); /// # } /// ``` @@ -16994,12 +17243,17 @@ impl<'a, C, A> MapPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -17016,8 +17270,8 @@ impl<'a, C, A> MapPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Map) -> MapPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Map) -> MapPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the map. @@ -17116,7 +17370,7 @@ impl<'a, C, A> MapPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.maps().permissions_batch_update(&req, "id") +/// let result = hub.maps().permissions_batch_update(req, "id") /// .doit(); /// # } /// ``` @@ -17244,12 +17498,17 @@ impl<'a, C, A> MapPermissionBatchUpdateCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -17258,7 +17517,7 @@ impl<'a, C, A> MapPermissionBatchUpdateCall<'a, C, A> where C: BorrowMut<hyper:: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -17276,8 +17535,8 @@ impl<'a, C, A> MapPermissionBatchUpdateCall<'a, C, A> where C: BorrowMut<hyper:: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PermissionsBatchUpdateRequest) -> MapPermissionBatchUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PermissionsBatchUpdateRequest) -> MapPermissionBatchUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the asset to which permissions will be added. @@ -17486,12 +17745,17 @@ impl<'a, C, A> MapDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -17710,12 +17974,17 @@ impl<'a, C, A> MapUnpublishCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -17724,7 +17993,7 @@ impl<'a, C, A> MapUnpublishCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -17949,12 +18218,17 @@ impl<'a, C, A> MapPublishCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -17963,7 +18237,7 @@ impl<'a, C, A> MapPublishCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -18190,12 +18464,17 @@ impl<'a, C, A> MapPermissionListCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -18204,7 +18483,7 @@ impl<'a, C, A> MapPermissionListCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -18311,7 +18590,7 @@ impl<'a, C, A> MapPermissionListCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.maps().create(&req) +/// let result = hub.maps().create(req) /// .doit(); /// # } /// ``` @@ -18413,12 +18692,17 @@ impl<'a, C, A> MapCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -18427,7 +18711,7 @@ impl<'a, C, A> MapCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -18445,8 +18729,8 @@ impl<'a, C, A> MapCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Map) -> MapCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Map) -> MapCreateCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -18646,12 +18930,17 @@ impl<'a, C, A> MapGetPublishedCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -18660,7 +18949,7 @@ impl<'a, C, A> MapGetPublishedCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -18885,12 +19174,17 @@ impl<'a, C, A> MapGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -18899,7 +19193,7 @@ impl<'a, C, A> MapGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -19013,7 +19307,7 @@ impl<'a, C, A> MapGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.maps().permissions_batch_delete(&req, "id") +/// let result = hub.maps().permissions_batch_delete(req, "id") /// .doit(); /// # } /// ``` @@ -19141,12 +19435,17 @@ impl<'a, C, A> MapPermissionBatchDeleteCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -19155,7 +19454,7 @@ impl<'a, C, A> MapPermissionBatchDeleteCall<'a, C, A> where C: BorrowMut<hyper:: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -19173,8 +19472,8 @@ impl<'a, C, A> MapPermissionBatchDeleteCall<'a, C, A> where C: BorrowMut<hyper:: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PermissionsBatchDeleteRequest) -> MapPermissionBatchDeleteCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PermissionsBatchDeleteRequest) -> MapPermissionBatchDeleteCall<'a, C, A> { + self._request = new_value; self } /// The ID of the asset from which permissions will be removed. @@ -19271,7 +19570,7 @@ impl<'a, C, A> MapPermissionBatchDeleteCall<'a, C, A> where C: BorrowMut<hyper:: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.raster_collections().create(&req) +/// let result = hub.raster_collections().create(req) /// .doit(); /// # } /// ``` @@ -19373,12 +19672,17 @@ impl<'a, C, A> RasterCollectionCreateCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -19387,7 +19691,7 @@ impl<'a, C, A> RasterCollectionCreateCall<'a, C, A> where C: BorrowMut<hyper::Cl Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -19405,8 +19709,8 @@ impl<'a, C, A> RasterCollectionCreateCall<'a, C, A> where C: BorrowMut<hyper::Cl /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &RasterCollection) -> RasterCollectionCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: RasterCollection) -> RasterCollectionCreateCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -19493,7 +19797,7 @@ impl<'a, C, A> RasterCollectionCreateCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.raster_collections().permissions_batch_delete(&req, "id") +/// let result = hub.raster_collections().permissions_batch_delete(req, "id") /// .doit(); /// # } /// ``` @@ -19621,12 +19925,17 @@ impl<'a, C, A> RasterCollectionPermissionBatchDeleteCall<'a, C, A> where C: Borr if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -19635,7 +19944,7 @@ impl<'a, C, A> RasterCollectionPermissionBatchDeleteCall<'a, C, A> where C: Borr Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -19653,8 +19962,8 @@ impl<'a, C, A> RasterCollectionPermissionBatchDeleteCall<'a, C, A> where C: Borr /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PermissionsBatchDeleteRequest) -> RasterCollectionPermissionBatchDeleteCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PermissionsBatchDeleteRequest) -> RasterCollectionPermissionBatchDeleteCall<'a, C, A> { + self._request = new_value; self } /// The ID of the asset from which permissions will be removed. @@ -19751,7 +20060,7 @@ impl<'a, C, A> RasterCollectionPermissionBatchDeleteCall<'a, C, A> where C: Borr /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.raster_collections().patch(&req, "id") +/// let result = hub.raster_collections().patch(req, "id") /// .doit(); /// # } /// ``` @@ -19878,12 +20187,17 @@ impl<'a, C, A> RasterCollectionPatchCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -19900,8 +20214,8 @@ impl<'a, C, A> RasterCollectionPatchCall<'a, C, A> where C: BorrowMut<hyper::Cli /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &RasterCollection) -> RasterCollectionPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: RasterCollection) -> RasterCollectionPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the raster collection. @@ -20111,12 +20425,17 @@ impl<'a, C, A> RasterCollectionCancelProcessingCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -20125,7 +20444,7 @@ impl<'a, C, A> RasterCollectionCancelProcessingCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -20345,12 +20664,17 @@ impl<'a, C, A> RasterCollectionProcesCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -20359,7 +20683,7 @@ impl<'a, C, A> RasterCollectionProcesCall<'a, C, A> where C: BorrowMut<hyper::Cl Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -20468,7 +20792,7 @@ impl<'a, C, A> RasterCollectionProcesCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.raster_collections().permissions_batch_update(&req, "id") +/// let result = hub.raster_collections().permissions_batch_update(req, "id") /// .doit(); /// # } /// ``` @@ -20596,12 +20920,17 @@ impl<'a, C, A> RasterCollectionPermissionBatchUpdateCall<'a, C, A> where C: Borr if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -20610,7 +20939,7 @@ impl<'a, C, A> RasterCollectionPermissionBatchUpdateCall<'a, C, A> where C: Borr Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -20628,8 +20957,8 @@ impl<'a, C, A> RasterCollectionPermissionBatchUpdateCall<'a, C, A> where C: Borr /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PermissionsBatchUpdateRequest) -> RasterCollectionPermissionBatchUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PermissionsBatchUpdateRequest) -> RasterCollectionPermissionBatchUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the asset to which permissions will be added. @@ -20838,12 +21167,17 @@ impl<'a, C, A> RasterCollectionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -21072,12 +21406,17 @@ impl<'a, C, A> RasterCollectionParentListCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -21086,7 +21425,7 @@ impl<'a, C, A> RasterCollectionParentListCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -21359,12 +21698,17 @@ impl<'a, C, A> RasterCollectionListCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -21373,7 +21717,7 @@ impl<'a, C, A> RasterCollectionListCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -21562,7 +21906,7 @@ impl<'a, C, A> RasterCollectionListCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.raster_collections().rasters_batch_insert(&req, "id") +/// let result = hub.raster_collections().rasters_batch_insert(req, "id") /// .doit(); /// # } /// ``` @@ -21690,12 +22034,17 @@ impl<'a, C, A> RasterCollectionRasterBatchInsertCall<'a, C, A> where C: BorrowMu if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -21704,7 +22053,7 @@ impl<'a, C, A> RasterCollectionRasterBatchInsertCall<'a, C, A> where C: BorrowMu Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -21722,8 +22071,8 @@ impl<'a, C, A> RasterCollectionRasterBatchInsertCall<'a, C, A> where C: BorrowMu /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &RasterCollectionsRastersBatchInsertRequest) -> RasterCollectionRasterBatchInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: RasterCollectionsRastersBatchInsertRequest) -> RasterCollectionRasterBatchInsertCall<'a, C, A> { + self._request = new_value; self } /// The ID of the raster collection to which these rasters belong. @@ -21822,7 +22171,7 @@ impl<'a, C, A> RasterCollectionRasterBatchInsertCall<'a, C, A> where C: BorrowMu /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.raster_collections().rasters_batch_delete(&req, "id") +/// let result = hub.raster_collections().rasters_batch_delete(req, "id") /// .doit(); /// # } /// ``` @@ -21950,12 +22299,17 @@ impl<'a, C, A> RasterCollectionRasterBatchDeleteCall<'a, C, A> where C: BorrowMu if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -21964,7 +22318,7 @@ impl<'a, C, A> RasterCollectionRasterBatchDeleteCall<'a, C, A> where C: BorrowMu Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -21982,8 +22336,8 @@ impl<'a, C, A> RasterCollectionRasterBatchDeleteCall<'a, C, A> where C: BorrowMu /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &RasterCollectionsRasterBatchDeleteRequest) -> RasterCollectionRasterBatchDeleteCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: RasterCollectionsRasterBatchDeleteRequest) -> RasterCollectionRasterBatchDeleteCall<'a, C, A> { + self._request = new_value; self } /// The ID of the raster collection to which these rasters belong. @@ -22193,12 +22547,17 @@ impl<'a, C, A> RasterCollectionPermissionListCall<'a, C, A> where C: BorrowMut<h if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -22207,7 +22566,7 @@ impl<'a, C, A> RasterCollectionPermissionListCall<'a, C, A> where C: BorrowMut<h Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -22427,12 +22786,17 @@ impl<'a, C, A> RasterCollectionGetCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -22441,7 +22805,7 @@ impl<'a, C, A> RasterCollectionGetCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -22716,12 +23080,17 @@ impl<'a, C, A> RasterCollectionRasterListCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -22730,7 +23099,7 @@ impl<'a, C, A> RasterCollectionRasterListCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -23050,12 +23419,17 @@ impl<'a, C, A> ProjectIconGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = if enable_resource_parsing { let mut json_response = String::new(); @@ -23064,7 +23438,7 @@ impl<'a, C, A> ProjectIconGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } } else { (res, Default::default()) }; @@ -23182,7 +23556,7 @@ impl<'a, C, A> ProjectIconGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.projects().icons_create(&req, "projectId") +/// let result = hub.projects().icons_create(req, "projectId") /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } /// ``` @@ -23228,14 +23602,15 @@ impl<'a, C, A> ProjectIconCreateCall<'a, C, A> where C: BorrowMut<hyper::Client> params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/mapsengine/v1/projects/{projectId}/icons".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/mapsengine/v1/projects/{projectId}/icons".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/mapsengine/v1/projects/{projectId}/icons".to_string() + ("https://www.googleapis.com/resumable/upload/mapsengine/v1/projects/{projectId}/icons".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } @@ -23354,12 +23729,17 @@ impl<'a, C, A> ProjectIconCreateCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -23369,9 +23749,9 @@ impl<'a, C, A> ProjectIconCreateCall<'a, C, A> where C: BorrowMut<hyper::Client> } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -23381,7 +23761,7 @@ impl<'a, C, A> ProjectIconCreateCall<'a, C, A> where C: BorrowMut<hyper::Client> auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -23412,7 +23792,7 @@ impl<'a, C, A> ProjectIconCreateCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -23456,8 +23836,8 @@ impl<'a, C, A> ProjectIconCreateCall<'a, C, A> where C: BorrowMut<hyper::Client> /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Icon) -> ProjectIconCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Icon) -> ProjectIconCreateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the project. @@ -23641,12 +24021,17 @@ impl<'a, C, A> ProjectListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -23655,7 +24040,7 @@ impl<'a, C, A> ProjectListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -23875,12 +24260,17 @@ impl<'a, C, A> ProjectIconListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -23889,7 +24279,7 @@ impl<'a, C, A> ProjectIconListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/mirror1-cli/Cargo.toml b/gen/mirror1-cli/Cargo.toml index b279ad7773..74f034b3ec 100644 --- a/gen/mirror1-cli/Cargo.toml +++ b/gen/mirror1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-mirror1-cli" -version = "0.0.1+20150220" +version = "0.1.0+20150220" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with mirror (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/mirror1-cli" diff --git a/gen/mirror1-cli/README.md b/gen/mirror1-cli/README.md index 59c3764d20..4b834a2fcf 100644 --- a/gen/mirror1-cli/README.md +++ b/gen/mirror1-cli/README.md @@ -1,4 +1,125 @@ -# HELLO MIRROR:V1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `mirror1` command-line interface *(CLI)* allows to use most features of the *Google mirror* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *mirror* API at revision *20150220*. The CLI is at version *0.1.0*. + +```bash + mirror1 [options] accounts insert <user-token> <account-type> <account-name> -r <kv>... [-p <v>...] [-o <out>] + mirror1 [options] contacts delete <id> [-p <v>...] + mirror1 [options] contacts get <id> [-p <v>...] [-o <out>] + mirror1 [options] contacts insert -r <kv>... [-p <v>...] [-o <out>] + mirror1 [options] contacts list [-p <v>...] [-o <out>] + mirror1 [options] contacts patch <id> -r <kv>... [-p <v>...] [-o <out>] + mirror1 [options] contacts update <id> -r <kv>... [-p <v>...] [-o <out>] + mirror1 [options] locations get <id> [-p <v>...] [-o <out>] + mirror1 [options] locations list [-p <v>...] [-o <out>] + mirror1 [options] settings get <id> [-p <v>...] [-o <out>] + mirror1 [options] subscriptions delete <id> [-p <v>...] + mirror1 [options] subscriptions insert -r <kv>... [-p <v>...] [-o <out>] + mirror1 [options] subscriptions list [-p <v>...] [-o <out>] + mirror1 [options] subscriptions update <id> -r <kv>... [-p <v>...] [-o <out>] + mirror1 [options] timeline attachments-delete <item-id> <attachment-id> [-p <v>...] + mirror1 [options] timeline attachments-get <item-id> <attachment-id> [-p <v>...] [-o <out>] + mirror1 [options] timeline attachments-insert <item-id> -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + mirror1 [options] timeline attachments-list <item-id> [-p <v>...] [-o <out>] + mirror1 [options] timeline delete <id> [-p <v>...] + mirror1 [options] timeline get <id> [-p <v>...] [-o <out>] + mirror1 [options] timeline insert -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + mirror1 [options] timeline list [-p <v>...] [-o <out>] + mirror1 [options] timeline patch <id> -r <kv>... [-p <v>...] [-o <out>] + mirror1 [options] timeline update <id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + mirror1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_mirror1_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `mirror1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/mirror1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/mirror1-secret.json`, assuming that the required *mirror* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `mirror1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/mirror1-cli/mkdocs.yml b/gen/mirror1-cli/mkdocs.yml index 56f894e986..67795a8215 100644 --- a/gen/mirror1-cli/mkdocs.yml +++ b/gen/mirror1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: mirror v0.0.1+20150220 +site_name: mirror v0.1.0+20150220 site_url: http://byron.github.io/google-apis-rs/google-mirror1-cli site_description: Write integrating applications with bcore diff --git a/gen/mirror1-cli/src/cmn.rs b/gen/mirror1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/mirror1-cli/src/cmn.rs +++ b/gen/mirror1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/mirror1-cli/src/main.rs b/gen/mirror1-cli/src/main.rs index 7281e4d8d7..3157409e1f 100644 --- a/gen/mirror1-cli/src/main.rs +++ b/gen/mirror1-cli/src/main.rs @@ -19,49 +19,50 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - mirror1 [options] accounts insert <user-token> <account-type> <account-name> -r <kv>... [-p <v>]... [-o <out>] - mirror1 [options] contacts delete <id> [-p <v>]... - mirror1 [options] contacts get <id> [-p <v>]... [-o <out>] - mirror1 [options] contacts insert -r <kv>... [-p <v>]... [-o <out>] - mirror1 [options] contacts list [-p <v>]... [-o <out>] - mirror1 [options] contacts patch <id> -r <kv>... [-p <v>]... [-o <out>] - mirror1 [options] contacts update <id> -r <kv>... [-p <v>]... [-o <out>] - mirror1 [options] locations get <id> [-p <v>]... [-o <out>] - mirror1 [options] locations list [-p <v>]... [-o <out>] - mirror1 [options] settings get <id> [-p <v>]... [-o <out>] - mirror1 [options] subscriptions delete <id> [-p <v>]... - mirror1 [options] subscriptions insert -r <kv>... [-p <v>]... [-o <out>] - mirror1 [options] subscriptions list [-p <v>]... [-o <out>] - mirror1 [options] subscriptions update <id> -r <kv>... [-p <v>]... [-o <out>] - mirror1 [options] timeline attachments-delete <item-id> <attachment-id> [-p <v>]... - mirror1 [options] timeline attachments-get <item-id> <attachment-id> [-p <v>]... [-o <out>] - mirror1 [options] timeline attachments-insert <item-id> -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] - mirror1 [options] timeline attachments-list <item-id> [-p <v>]... [-o <out>] - mirror1 [options] timeline delete <id> [-p <v>]... - mirror1 [options] timeline get <id> [-p <v>]... [-o <out>] - mirror1 [options] timeline insert -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] - mirror1 [options] timeline list [-p <v>]... [-o <out>] - mirror1 [options] timeline patch <id> -r <kv>... [-p <v>]... [-o <out>] - mirror1 [options] timeline update <id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] + mirror1 [options] accounts insert <user-token> <account-type> <account-name> -r <kv>... [-p <v>...] [-o <out>] + mirror1 [options] contacts delete <id> [-p <v>...] + mirror1 [options] contacts get <id> [-p <v>...] [-o <out>] + mirror1 [options] contacts insert -r <kv>... [-p <v>...] [-o <out>] + mirror1 [options] contacts list [-p <v>...] [-o <out>] + mirror1 [options] contacts patch <id> -r <kv>... [-p <v>...] [-o <out>] + mirror1 [options] contacts update <id> -r <kv>... [-p <v>...] [-o <out>] + mirror1 [options] locations get <id> [-p <v>...] [-o <out>] + mirror1 [options] locations list [-p <v>...] [-o <out>] + mirror1 [options] settings get <id> [-p <v>...] [-o <out>] + mirror1 [options] subscriptions delete <id> [-p <v>...] + mirror1 [options] subscriptions insert -r <kv>... [-p <v>...] [-o <out>] + mirror1 [options] subscriptions list [-p <v>...] [-o <out>] + mirror1 [options] subscriptions update <id> -r <kv>... [-p <v>...] [-o <out>] + mirror1 [options] timeline attachments-delete <item-id> <attachment-id> [-p <v>...] + mirror1 [options] timeline attachments-get <item-id> <attachment-id> [-p <v>...] [-o <out>] + mirror1 [options] timeline attachments-insert <item-id> -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + mirror1 [options] timeline attachments-list <item-id> [-p <v>...] [-o <out>] + mirror1 [options] timeline delete <id> [-p <v>...] + mirror1 [options] timeline get <id> [-p <v>...] [-o <out>] + mirror1 [options] timeline insert -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + mirror1 [options] timeline list [-p <v>...] [-o <out>] + mirror1 [options] timeline patch <id> -r <kv>... [-p <v>...] [-o <out>] + mirror1 [options] timeline update <id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] mirror1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_mirror1_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -83,8 +84,39 @@ struct Engine { impl Engine { fn _accounts_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Account::default(); - let mut call = self.hub.accounts().insert(&request, &self.opt.arg_user_token, &self.opt.arg_account_type, &self.opt.arg_account_name); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "password" => { + request.password = Some(value.unwrap_or("").to_string()); + }, + "features" => { + if request.features.is_none() { + request.features = Some(Default::default()); + } + request.features.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.accounts().insert(request, &self.opt.arg_user_token, &self.opt.arg_account_type, &self.opt.arg_account_name); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -106,28 +138,6 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "password" => { - request.password = Some(value.unwrap_or("").to_string()); - }, - "features" => { - if request.features.is_none() { - request.features = Some(Default::default()); - } - request.features.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None @@ -176,6 +186,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -217,6 +230,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -233,37 +249,24 @@ impl Engine { fn _contacts_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Contact::default(); - let mut call = self.hub.contacts().insert(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Contact::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -307,15 +310,40 @@ impl Engine { request.speakable_name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.contacts().insert(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -359,6 +387,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -375,37 +406,24 @@ impl Engine { fn _contacts_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Contact::default(); - let mut call = self.hub.contacts().patch(&request, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Contact::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -449,15 +467,40 @@ impl Engine { request.speakable_name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.contacts().patch(request, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -474,37 +517,24 @@ impl Engine { fn _contacts_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Contact::default(); - let mut call = self.hub.contacts().update(&request, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Contact::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -548,15 +578,40 @@ impl Engine { request.speakable_name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.contacts().update(request, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -600,6 +655,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -643,6 +701,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -686,6 +747,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -729,6 +793,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -743,43 +810,30 @@ impl Engine { fn _subscriptions_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Subscription::default(); - let mut call = self.hub.subscriptions().insert(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Subscription::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_notification_init(request: &mut api::Subscription) { if request.notification.is_none() { request.notification = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -835,15 +889,40 @@ impl Engine { request.callback_url = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.subscriptions().insert(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -887,6 +966,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -903,43 +985,30 @@ impl Engine { fn _subscriptions_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Subscription::default(); - let mut call = self.hub.subscriptions().update(&request, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Subscription::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_notification_init(request: &mut api::Subscription) { if request.notification.is_none() { request.notification = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -995,15 +1064,40 @@ impl Engine { request.callback_url = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.subscriptions().update(request, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1047,6 +1141,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1092,6 +1189,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1148,6 +1248,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -1192,6 +1295,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1235,6 +1341,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1276,6 +1385,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1292,36 +1404,23 @@ impl Engine { fn _timeline_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::TimelineItem::default(); - let mut call = self.hub.timeline().insert(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::TimelineItem::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_creator_init(request: &mut api::TimelineItem) { if request.creator.is_none() { request.creator = Some(Default::default()); @@ -1340,7 +1439,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "display-time" => { request.display_time = Some(value.unwrap_or("").to_string()); }, @@ -1514,10 +1613,32 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.timeline().insert(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = if self.opt.cmd_simple { "simple" @@ -1532,6 +1653,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -1597,6 +1721,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1613,36 +1740,23 @@ impl Engine { fn _timeline_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::TimelineItem::default(); - let mut call = self.hub.timeline().patch(&request, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::TimelineItem::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_creator_init(request: &mut api::TimelineItem) { if request.creator.is_none() { request.creator = Some(Default::default()); @@ -1661,7 +1775,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "display-time" => { request.display_time = Some(value.unwrap_or("").to_string()); }, @@ -1835,15 +1949,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.timeline().patch(request, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1860,36 +1999,23 @@ impl Engine { fn _timeline_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::TimelineItem::default(); - let mut call = self.hub.timeline().update(&request, &self.opt.arg_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::TimelineItem::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_creator_init(request: &mut api::TimelineItem) { if request.creator.is_none() { request.creator = Some(Default::default()); @@ -1908,7 +2034,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "display-time" => { request.display_time = Some(value.unwrap_or("").to_string()); }, @@ -2082,10 +2208,32 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.timeline().update(request, &self.opt.arg_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = if self.opt.cmd_simple { "simple" @@ -2100,6 +2248,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -2265,6 +2416,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -2272,8 +2424,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/mirror1/Cargo.toml b/gen/mirror1/Cargo.toml index bcd163216b..424257bf08 100644 --- a/gen/mirror1/Cargo.toml +++ b/gen/mirror1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-mirror1" -version = "0.1.5+20150220" +version = "0.1.6+20150220" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with mirror (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/mirror1" diff --git a/gen/mirror1/README.md b/gen/mirror1/README.md index 154b2986e4..06b4f0c961 100644 --- a/gen/mirror1/README.md +++ b/gen/mirror1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-mirror1` library allows access to all features of the *Google mirror* service. -This documentation was generated from *mirror* crate version *0.1.5+20150220*, where *20150220* is the exact revision of the *mirror:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *mirror* crate version *0.1.6+20150220*, where *20150220* is the exact revision of the *mirror:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *mirror* *v1* API can be found at the [official documentation site](https://developers.google.com/glass). @@ -123,21 +123,22 @@ let mut req = Contact::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.contacts().update(&req, "id") +let result = hub.contacts().update(req, "id") .doit(); match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/mirror1/src/cmn.rs b/gen/mirror1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/mirror1/src/cmn.rs +++ b/gen/mirror1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/mirror1/src/lib.rs b/gen/mirror1/src/lib.rs index 54e4ff8aee..5e71e5d889 100644 --- a/gen/mirror1/src/lib.rs +++ b/gen/mirror1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *mirror* crate version *0.1.5+20150220*, where *20150220* is the exact revision of the *mirror:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *mirror* crate version *0.1.6+20150220*, where *20150220* is the exact revision of the *mirror:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *mirror* *v1* API can be found at the //! [official documentation site](https://developers.google.com/glass). @@ -124,21 +124,22 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.contacts().update(&req, "id") +//! let result = hub.contacts().update(req, "id") //! .doit(); //! //! match result { //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -226,7 +227,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -303,21 +304,22 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.contacts().update(&req, "id") +/// let result = hub.contacts().update(req, "id") /// .doit(); /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -338,7 +340,7 @@ impl<'a, C, A> Mirror<C, A> Mirror { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -362,7 +364,7 @@ impl<'a, C, A> Mirror<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -1051,10 +1053,10 @@ impl<'a, C, A> SubscriptionMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &Subscription) -> SubscriptionInsertCall<'a, C, A> { + pub fn insert(&self, request: Subscription) -> SubscriptionInsertCall<'a, C, A> { SubscriptionInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1086,10 +1088,10 @@ impl<'a, C, A> SubscriptionMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The ID of the subscription. - pub fn update(&self, request: &Subscription, id: &str) -> SubscriptionUpdateCall<'a, C, A> { + pub fn update(&self, request: Subscription, id: &str) -> SubscriptionUpdateCall<'a, C, A> { SubscriptionUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1174,10 +1176,10 @@ impl<'a, C, A> TimelineMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &TimelineItem) -> TimelineInsertCall<'a, C, A> { + pub fn insert(&self, request: TimelineItem) -> TimelineInsertCall<'a, C, A> { TimelineInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1192,10 +1194,10 @@ impl<'a, C, A> TimelineMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The ID of the timeline item. - pub fn patch(&self, request: &TimelineItem, id: &str) -> TimelinePatchCall<'a, C, A> { + pub fn patch(&self, request: TimelineItem, id: &str) -> TimelinePatchCall<'a, C, A> { TimelinePatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1283,10 +1285,10 @@ impl<'a, C, A> TimelineMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The ID of the timeline item. - pub fn update(&self, request: &TimelineItem, id: &str) -> TimelineUpdateCall<'a, C, A> { + pub fn update(&self, request: TimelineItem, id: &str) -> TimelineUpdateCall<'a, C, A> { TimelineUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1511,10 +1513,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// * `userToken` - The ID for the user. /// * `accountType` - Account type to be passed to Android Account Manager. /// * `accountName` - The name of the account to be passed to the Android Account Manager. - pub fn insert(&self, request: &Account, user_token: &str, account_type: &str, account_name: &str) -> AccountInsertCall<'a, C, A> { + pub fn insert(&self, request: Account, user_token: &str, account_type: &str, account_name: &str) -> AccountInsertCall<'a, C, A> { AccountInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_token: user_token.to_string(), _account_type: account_type.to_string(), _account_name: account_name.to_string(), @@ -1605,10 +1607,10 @@ impl<'a, C, A> ContactMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &Contact) -> ContactInsertCall<'a, C, A> { + pub fn insert(&self, request: Contact) -> ContactInsertCall<'a, C, A> { ContactInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1623,10 +1625,10 @@ impl<'a, C, A> ContactMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The ID of the contact. - pub fn patch(&self, request: &Contact, id: &str) -> ContactPatchCall<'a, C, A> { + pub fn patch(&self, request: Contact, id: &str) -> ContactPatchCall<'a, C, A> { ContactPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1654,10 +1656,10 @@ impl<'a, C, A> ContactMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The ID of the contact. - pub fn update(&self, request: &Contact, id: &str) -> ContactUpdateCall<'a, C, A> { + pub fn update(&self, request: Contact, id: &str) -> ContactUpdateCall<'a, C, A> { ContactUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1706,7 +1708,7 @@ impl<'a, C, A> ContactMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.subscriptions().insert(&req) +/// let result = hub.subscriptions().insert(req) /// .doit(); /// # } /// ``` @@ -1808,12 +1810,17 @@ impl<'a, C, A> SubscriptionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1822,7 +1829,7 @@ impl<'a, C, A> SubscriptionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1840,8 +1847,8 @@ impl<'a, C, A> SubscriptionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Subscription) -> SubscriptionInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Subscription) -> SubscriptionInsertCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -2040,12 +2047,17 @@ impl<'a, C, A> SubscriptionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -2151,7 +2163,7 @@ impl<'a, C, A> SubscriptionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.subscriptions().update(&req, "id") +/// let result = hub.subscriptions().update(req, "id") /// .doit(); /// # } /// ``` @@ -2279,12 +2291,17 @@ impl<'a, C, A> SubscriptionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2293,7 +2310,7 @@ impl<'a, C, A> SubscriptionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2311,8 +2328,8 @@ impl<'a, C, A> SubscriptionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Subscription) -> SubscriptionUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Subscription) -> SubscriptionUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the subscription. @@ -2496,12 +2513,17 @@ impl<'a, C, A> SubscriptionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2510,7 +2532,7 @@ impl<'a, C, A> SubscriptionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2720,12 +2742,17 @@ impl<'a, C, A> TimelineAttachmentListCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2734,7 +2761,7 @@ impl<'a, C, A> TimelineAttachmentListCall<'a, C, A> where C: BorrowMut<hyper::Cl Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2842,7 +2869,7 @@ impl<'a, C, A> TimelineAttachmentListCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.timeline().insert(&req) +/// let result = hub.timeline().insert(req) /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } /// ``` @@ -2886,14 +2913,15 @@ impl<'a, C, A> TimelineInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/mirror/v1/timeline".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/mirror/v1/timeline".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/mirror/v1/timeline".to_string() + ("https://www.googleapis.com/resumable/upload/mirror/v1/timeline".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::GlasLocation.as_ref().to_string(), ()); } @@ -2988,12 +3016,17 @@ impl<'a, C, A> TimelineInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -3003,9 +3036,9 @@ impl<'a, C, A> TimelineInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -3015,7 +3048,7 @@ impl<'a, C, A> TimelineInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -3046,7 +3079,7 @@ impl<'a, C, A> TimelineInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3090,8 +3123,8 @@ impl<'a, C, A> TimelineInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &TimelineItem) -> TimelineInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: TimelineItem) -> TimelineInsertCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -3178,7 +3211,7 @@ impl<'a, C, A> TimelineInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.timeline().patch(&req, "id") +/// let result = hub.timeline().patch(req, "id") /// .doit(); /// # } /// ``` @@ -3306,12 +3339,17 @@ impl<'a, C, A> TimelinePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3320,7 +3358,7 @@ impl<'a, C, A> TimelinePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3338,8 +3376,8 @@ impl<'a, C, A> TimelinePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &TimelineItem) -> TimelinePatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: TimelineItem) -> TimelinePatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the timeline item. @@ -3558,12 +3596,17 @@ impl<'a, C, A> TimelineListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3572,7 +3615,7 @@ impl<'a, C, A> TimelineListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3758,14 +3801,15 @@ impl<'a, C, A> TimelineAttachmentInsertCall<'a, C, A> where C: BorrowMut<hyper:: params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/mirror/v1/timeline/{itemId}/attachments".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/mirror/v1/timeline/{itemId}/attachments".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/mirror/v1/timeline/{itemId}/attachments".to_string() + ("https://www.googleapis.com/resumable/upload/mirror/v1/timeline/{itemId}/attachments".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::GlasTimeline.as_ref().to_string(), ()); } @@ -3871,12 +3915,17 @@ impl<'a, C, A> TimelineAttachmentInsertCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -3886,9 +3935,9 @@ impl<'a, C, A> TimelineAttachmentInsertCall<'a, C, A> where C: BorrowMut<hyper:: } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -3898,7 +3947,7 @@ impl<'a, C, A> TimelineAttachmentInsertCall<'a, C, A> where C: BorrowMut<hyper:: auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -3929,7 +3978,7 @@ impl<'a, C, A> TimelineAttachmentInsertCall<'a, C, A> where C: BorrowMut<hyper:: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4176,12 +4225,17 @@ impl<'a, C, A> TimelineAttachmentDeleteCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -4409,12 +4463,17 @@ impl<'a, C, A> TimelineDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -4521,7 +4580,7 @@ impl<'a, C, A> TimelineDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.timeline().update(&req, "id") +/// let result = hub.timeline().update(req, "id") /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } /// ``` @@ -4567,14 +4626,15 @@ impl<'a, C, A> TimelineUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/mirror/v1/timeline/{id}".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/mirror/v1/timeline/{id}".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/mirror/v1/timeline/{id}".to_string() + ("https://www.googleapis.com/resumable/upload/mirror/v1/timeline/{id}".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::GlasLocation.as_ref().to_string(), ()); } @@ -4693,12 +4753,17 @@ impl<'a, C, A> TimelineUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -4708,9 +4773,9 @@ impl<'a, C, A> TimelineUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -4720,7 +4785,7 @@ impl<'a, C, A> TimelineUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -4751,7 +4816,7 @@ impl<'a, C, A> TimelineUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4795,8 +4860,8 @@ impl<'a, C, A> TimelineUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &TimelineItem) -> TimelineUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: TimelineItem) -> TimelineUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the timeline item. @@ -5029,12 +5094,17 @@ impl<'a, C, A> TimelineAttachmentGetCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = if enable_resource_parsing { let mut json_response = String::new(); @@ -5043,7 +5113,7 @@ impl<'a, C, A> TimelineAttachmentGetCall<'a, C, A> where C: BorrowMut<hyper::Cli Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } } else { (res, Default::default()) }; @@ -5273,12 +5343,17 @@ impl<'a, C, A> TimelineGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5287,7 +5362,7 @@ impl<'a, C, A> TimelineGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5507,12 +5582,17 @@ impl<'a, C, A> SettingGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5521,7 +5601,7 @@ impl<'a, C, A> SettingGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5743,12 +5823,17 @@ impl<'a, C, A> LocationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5757,7 +5842,7 @@ impl<'a, C, A> LocationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5951,12 +6036,17 @@ impl<'a, C, A> LocationListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5965,7 +6055,7 @@ impl<'a, C, A> LocationListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6062,7 +6152,7 @@ impl<'a, C, A> LocationListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().insert(&req, "userToken", "accountType", "accountName") +/// let result = hub.accounts().insert(req, "userToken", "accountType", "accountName") /// .doit(); /// # } /// ``` @@ -6187,12 +6277,17 @@ impl<'a, C, A> AccountInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6201,7 +6296,7 @@ impl<'a, C, A> AccountInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6219,8 +6314,8 @@ impl<'a, C, A> AccountInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Account) -> AccountInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Account) -> AccountInsertCall<'a, C, A> { + self._request = new_value; self } /// The ID for the user. @@ -6434,12 +6529,17 @@ impl<'a, C, A> ContactGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6448,7 +6548,7 @@ impl<'a, C, A> ContactGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6667,12 +6767,17 @@ impl<'a, C, A> ContactDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -6778,7 +6883,7 @@ impl<'a, C, A> ContactDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.contacts().insert(&req) +/// let result = hub.contacts().insert(req) /// .doit(); /// # } /// ``` @@ -6880,12 +6985,17 @@ impl<'a, C, A> ContactInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6894,7 +7004,7 @@ impl<'a, C, A> ContactInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6912,8 +7022,8 @@ impl<'a, C, A> ContactInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Contact) -> ContactInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Contact) -> ContactInsertCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -7000,7 +7110,7 @@ impl<'a, C, A> ContactInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.contacts().patch(&req, "id") +/// let result = hub.contacts().patch(req, "id") /// .doit(); /// # } /// ``` @@ -7128,12 +7238,17 @@ impl<'a, C, A> ContactPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7142,7 +7257,7 @@ impl<'a, C, A> ContactPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7160,8 +7275,8 @@ impl<'a, C, A> ContactPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Contact) -> ContactPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Contact) -> ContactPatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the contact. @@ -7345,12 +7460,17 @@ impl<'a, C, A> ContactListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7359,7 +7479,7 @@ impl<'a, C, A> ContactListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7456,7 +7576,7 @@ impl<'a, C, A> ContactListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.contacts().update(&req, "id") +/// let result = hub.contacts().update(req, "id") /// .doit(); /// # } /// ``` @@ -7584,12 +7704,17 @@ impl<'a, C, A> ContactUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7598,7 +7723,7 @@ impl<'a, C, A> ContactUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7616,8 +7741,8 @@ impl<'a, C, A> ContactUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Contact) -> ContactUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Contact) -> ContactUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the contact. diff --git a/gen/oauth2_v2-cli/Cargo.toml b/gen/oauth2_v2-cli/Cargo.toml index e0935cbf17..8ef9be7c49 100644 --- a/gen/oauth2_v2-cli/Cargo.toml +++ b/gen/oauth2_v2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-oauth2_v2-cli" -version = "0.0.1+20150416" +version = "0.1.0+20150416" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with oauth2 (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/oauth2_v2-cli" diff --git a/gen/oauth2_v2-cli/README.md b/gen/oauth2_v2-cli/README.md index 06c3dae8b8..52569ecb8a 100644 --- a/gen/oauth2_v2-cli/README.md +++ b/gen/oauth2_v2-cli/README.md @@ -1,4 +1,105 @@ -# HELLO OAUTH2:V2 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `oauth2-v2` command-line interface *(CLI)* allows to use most features of the *Google oauth2* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *oauth2* API at revision *20150416*. The CLI is at version *0.1.0*. + +```bash + oauth2-v2 [options] methods get-cert-for-open-id-connect [-p <v>...] [-o <out>] + oauth2-v2 [options] methods tokeninfo [-p <v>...] [-o <out>] + oauth2-v2 [options] userinfo get [-p <v>...] [-o <out>] + oauth2-v2 [options] userinfo v2-me-get [-p <v>...] [-o <out>] + oauth2-v2 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_oauth2_v2_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `oauth2-v2-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/oauth2-v2-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/oauth2-v2-secret.json`, assuming that the required *oauth2* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `oauth2-v2 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/oauth2_v2-cli/mkdocs.yml b/gen/oauth2_v2-cli/mkdocs.yml index 09e1f91baf..e2dee89956 100644 --- a/gen/oauth2_v2-cli/mkdocs.yml +++ b/gen/oauth2_v2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: oauth2 v0.0.1+20150416 +site_name: oauth2 v0.1.0+20150416 site_url: http://byron.github.io/google-apis-rs/google-oauth2_v2-cli site_description: Write integrating applications with bcore diff --git a/gen/oauth2_v2-cli/src/cmn.rs b/gen/oauth2_v2-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/oauth2_v2-cli/src/cmn.rs +++ b/gen/oauth2_v2-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/oauth2_v2-cli/src/main.rs b/gen/oauth2_v2-cli/src/main.rs index 92d9e2c929..dca65268c2 100644 --- a/gen/oauth2_v2-cli/src/main.rs +++ b/gen/oauth2_v2-cli/src/main.rs @@ -19,29 +19,30 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - oauth2-v2 [options] methods get-cert-for-open-id-connect [-p <v>]... [-o <out>] - oauth2-v2 [options] methods tokeninfo [-p <v>]... [-o <out>] - oauth2-v2 [options] userinfo get [-p <v>]... [-o <out>] - oauth2-v2 [options] userinfo v2-me-get [-p <v>]... [-o <out>] + oauth2-v2 [options] methods get-cert-for-open-id-connect [-p <v>...] [-o <out>] + oauth2-v2 [options] methods tokeninfo [-p <v>...] [-o <out>] + oauth2-v2 [options] userinfo get [-p <v>...] [-o <out>] + oauth2-v2 [options] userinfo v2-me-get [-p <v>...] [-o <out>] oauth2-v2 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_oauth2_v2_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -185,6 +186,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -228,6 +232,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -332,6 +339,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -339,8 +347,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/oauth2_v2/Cargo.toml b/gen/oauth2_v2/Cargo.toml index 07b8cf01fd..873512b778 100644 --- a/gen/oauth2_v2/Cargo.toml +++ b/gen/oauth2_v2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-oauth2_v2" -version = "0.1.5+20150416" +version = "0.1.6+20150416" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with oauth2 (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/oauth2_v2" diff --git a/gen/oauth2_v2/README.md b/gen/oauth2_v2/README.md index 5e8b0252d3..0f62b458e5 100644 --- a/gen/oauth2_v2/README.md +++ b/gen/oauth2_v2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-oauth2_v2` library allows access to all features of the *Google oauth2* service. -This documentation was generated from *oauth2* crate version *0.1.5+20150416*, where *20150416* is the exact revision of the *oauth2:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *oauth2* crate version *0.1.6+20150416*, where *20150416* is the exact revision of the *oauth2:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *oauth2* *v2* API can be found at the [official documentation site](https://developers.google.com/accounts/docs/OAuth2). @@ -104,14 +104,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/oauth2_v2/src/cmn.rs b/gen/oauth2_v2/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/oauth2_v2/src/cmn.rs +++ b/gen/oauth2_v2/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/oauth2_v2/src/lib.rs b/gen/oauth2_v2/src/lib.rs index affdcf0831..6a2f8e33cc 100644 --- a/gen/oauth2_v2/src/lib.rs +++ b/gen/oauth2_v2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *oauth2* crate version *0.1.5+20150416*, where *20150416* is the exact revision of the *oauth2:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *oauth2* crate version *0.1.6+20150416*, where *20150416* is the exact revision of the *oauth2:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *oauth2* *v2* API can be found at the //! [official documentation site](https://developers.google.com/accounts/docs/OAuth2). @@ -105,14 +105,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -200,7 +201,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -286,14 +287,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -314,7 +316,7 @@ impl<'a, C, A> Oauth2<C, A> Oauth2 { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -326,7 +328,7 @@ impl<'a, C, A> Oauth2<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -703,12 +705,17 @@ impl<'a, C, A> UserinfoV2MeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -717,7 +724,7 @@ impl<'a, C, A> UserinfoV2MeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -899,12 +906,17 @@ impl<'a, C, A> UserinfoGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -913,7 +925,7 @@ impl<'a, C, A> UserinfoGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1103,12 +1115,17 @@ impl<'a, C, A> MethodTokeninfoCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1117,7 +1134,7 @@ impl<'a, C, A> MethodTokeninfoCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1294,12 +1311,17 @@ impl<'a, C, A> MethodGetCertForOpenIdConnectCall<'a, C, A> where C: BorrowMut<hy if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1308,7 +1330,7 @@ impl<'a, C, A> MethodGetCertForOpenIdConnectCall<'a, C, A> where C: BorrowMut<hy Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/pagespeedonline2-cli/Cargo.toml b/gen/pagespeedonline2-cli/Cargo.toml index 91a036aff9..e2ab450d70 100644 --- a/gen/pagespeedonline2-cli/Cargo.toml +++ b/gen/pagespeedonline2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-pagespeedonline2-cli" -version = "0.0.1+20150317" +version = "0.1.0+20150317" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with pagespeedonline (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/pagespeedonline2-cli" diff --git a/gen/pagespeedonline2-cli/README.md b/gen/pagespeedonline2-cli/README.md index 01f2986fac..d384c56065 100644 --- a/gen/pagespeedonline2-cli/README.md +++ b/gen/pagespeedonline2-cli/README.md @@ -1,4 +1,98 @@ -# HELLO PAGESPEEDONLINE:V2 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `pagespeedonline2` command-line interface *(CLI)* allows to use most features of the *Google pagespeedonline* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *pagespeedonline* API at revision *20150317*. The CLI is at version *0.1.0*. + +```bash + pagespeedonline2 [options] pagespeedapi runpagespeed <url> [-p <v>...] [-o <out>] + pagespeedonline2 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_pagespeedonline2_cli/index.html + +Configuration: + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `pagespeedonline2-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/pagespeedonline2-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/pagespeedonline2-secret.json`, assuming that the required *pagespeedonline* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `pagespeedonline2 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/pagespeedonline2-cli/mkdocs.yml b/gen/pagespeedonline2-cli/mkdocs.yml index e680d831db..9e2345d4ff 100644 --- a/gen/pagespeedonline2-cli/mkdocs.yml +++ b/gen/pagespeedonline2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: pagespeedonline v0.0.1+20150317 +site_name: pagespeedonline v0.1.0+20150317 site_url: http://byron.github.io/google-apis-rs/google-pagespeedonline2-cli site_description: Write integrating applications with bcore diff --git a/gen/pagespeedonline2-cli/src/cmn.rs b/gen/pagespeedonline2-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/pagespeedonline2-cli/src/cmn.rs +++ b/gen/pagespeedonline2-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/pagespeedonline2-cli/src/main.rs b/gen/pagespeedonline2-cli/src/main.rs index 521d5ef1b0..9b77b1ba0f 100644 --- a/gen/pagespeedonline2-cli/src/main.rs +++ b/gen/pagespeedonline2-cli/src/main.rs @@ -19,22 +19,23 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - pagespeedonline2 [options] pagespeedapi runpagespeed <url> [-p <v>]... [-o <out>] + pagespeedonline2 [options] pagespeedapi runpagespeed <url> [-p <v>...] [-o <out>] pagespeedonline2 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_pagespeedonline2_cli/index.html Configuration: --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -191,6 +192,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -198,8 +200,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/pagespeedonline2/Cargo.toml b/gen/pagespeedonline2/Cargo.toml index 63e71cb79e..a0dfca69f3 100644 --- a/gen/pagespeedonline2/Cargo.toml +++ b/gen/pagespeedonline2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-pagespeedonline2" -version = "0.1.5+20150317" +version = "0.1.6+20150317" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with pagespeedonline (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/pagespeedonline2" diff --git a/gen/pagespeedonline2/README.md b/gen/pagespeedonline2/README.md index 027f5a874c..bb7a5ffc38 100644 --- a/gen/pagespeedonline2/README.md +++ b/gen/pagespeedonline2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-pagespeedonline2` library allows access to all features of the *Google pagespeedonline* service. -This documentation was generated from *pagespeedonline* crate version *0.1.5+20150317*, where *20150317* is the exact revision of the *pagespeedonline:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *pagespeedonline* crate version *0.1.6+20150317*, where *20150317* is the exact revision of the *pagespeedonline:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *pagespeedonline* *v2* API can be found at the [official documentation site](https://developers.google.com/speed/docs/insights/v2/getting-started). @@ -104,14 +104,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/pagespeedonline2/src/cmn.rs b/gen/pagespeedonline2/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/pagespeedonline2/src/cmn.rs +++ b/gen/pagespeedonline2/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/pagespeedonline2/src/lib.rs b/gen/pagespeedonline2/src/lib.rs index 0e2dedca5a..e019f666fd 100644 --- a/gen/pagespeedonline2/src/lib.rs +++ b/gen/pagespeedonline2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *pagespeedonline* crate version *0.1.5+20150317*, where *20150317* is the exact revision of the *pagespeedonline:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *pagespeedonline* crate version *0.1.6+20150317*, where *20150317* is the exact revision of the *pagespeedonline:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *pagespeedonline* *v2* API can be found at the //! [official documentation site](https://developers.google.com/speed/docs/insights/v2/getting-started). @@ -105,14 +105,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -200,7 +201,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -257,14 +258,15 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -285,7 +287,7 @@ impl<'a, C, A> Pagespeedonline<C, A> Pagespeedonline { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -294,7 +296,7 @@ impl<'a, C, A> Pagespeedonline<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -841,12 +843,17 @@ impl<'a, C, A> PagespeedapiRunpagespeedCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -855,7 +862,7 @@ impl<'a, C, A> PagespeedapiRunpagespeedCall<'a, C, A> where C: BorrowMut<hyper:: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/plus1-cli/Cargo.toml b/gen/plus1-cli/Cargo.toml index a3ed7d5a13..ad8728b810 100644 --- a/gen/plus1-cli/Cargo.toml +++ b/gen/plus1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-plus1-cli" -version = "0.0.1+20150303" +version = "0.1.0+20150303" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with plus (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/plus1-cli" diff --git a/gen/plus1-cli/README.md b/gen/plus1-cli/README.md index befbebc1fb..471e643ce0 100644 --- a/gen/plus1-cli/README.md +++ b/gen/plus1-cli/README.md @@ -1,4 +1,113 @@ -# HELLO PLUS:V1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `plus1` command-line interface *(CLI)* allows to use most features of the *Google plus* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *plus* API at revision *20150303*. The CLI is at version *0.1.0*. + +```bash + plus1 [options] activities get <activity-id> [-p <v>...] [-o <out>] + plus1 [options] activities list <user-id> <collection> [-p <v>...] [-o <out>] + plus1 [options] activities search <query> [-p <v>...] [-o <out>] + plus1 [options] comments get <comment-id> [-p <v>...] [-o <out>] + plus1 [options] comments list <activity-id> [-p <v>...] [-o <out>] + plus1 [options] moments insert <user-id> <collection> -r <kv>... [-p <v>...] [-o <out>] + plus1 [options] moments list <user-id> <collection> [-p <v>...] [-o <out>] + plus1 [options] moments remove <id> [-p <v>...] + plus1 [options] people get <user-id> [-p <v>...] [-o <out>] + plus1 [options] people list <user-id> <collection> [-p <v>...] [-o <out>] + plus1 [options] people list-by-activity <activity-id> <collection> [-p <v>...] [-o <out>] + plus1 [options] people search <query> [-p <v>...] [-o <out>] + plus1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_plus1_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `plus1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/plus1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/plus1-secret.json`, assuming that the required *plus* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `plus1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/plus1-cli/mkdocs.yml b/gen/plus1-cli/mkdocs.yml index db18bb94ff..6a4050153d 100644 --- a/gen/plus1-cli/mkdocs.yml +++ b/gen/plus1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: plus v0.0.1+20150303 +site_name: plus v0.1.0+20150303 site_url: http://byron.github.io/google-apis-rs/google-plus1-cli site_description: Write integrating applications with bcore diff --git a/gen/plus1-cli/src/cmn.rs b/gen/plus1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/plus1-cli/src/cmn.rs +++ b/gen/plus1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/plus1-cli/src/main.rs b/gen/plus1-cli/src/main.rs index b1c40fcc69..d3674b3fde 100644 --- a/gen/plus1-cli/src/main.rs +++ b/gen/plus1-cli/src/main.rs @@ -19,37 +19,38 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - plus1 [options] activities get <activity-id> [-p <v>]... [-o <out>] - plus1 [options] activities list <user-id> <collection> [-p <v>]... [-o <out>] - plus1 [options] activities search <query> [-p <v>]... [-o <out>] - plus1 [options] comments get <comment-id> [-p <v>]... [-o <out>] - plus1 [options] comments list <activity-id> [-p <v>]... [-o <out>] - plus1 [options] moments insert <user-id> <collection> -r <kv>... [-p <v>]... [-o <out>] - plus1 [options] moments list <user-id> <collection> [-p <v>]... [-o <out>] - plus1 [options] moments remove <id> [-p <v>]... - plus1 [options] people get <user-id> [-p <v>]... [-o <out>] - plus1 [options] people list <user-id> <collection> [-p <v>]... [-o <out>] - plus1 [options] people list-by-activity <activity-id> <collection> [-p <v>]... [-o <out>] - plus1 [options] people search <query> [-p <v>]... [-o <out>] + plus1 [options] activities get <activity-id> [-p <v>...] [-o <out>] + plus1 [options] activities list <user-id> <collection> [-p <v>...] [-o <out>] + plus1 [options] activities search <query> [-p <v>...] [-o <out>] + plus1 [options] comments get <comment-id> [-p <v>...] [-o <out>] + plus1 [options] comments list <activity-id> [-p <v>...] [-o <out>] + plus1 [options] moments insert <user-id> <collection> -r <kv>... [-p <v>...] [-o <out>] + plus1 [options] moments list <user-id> <collection> [-p <v>...] [-o <out>] + plus1 [options] moments remove <id> [-p <v>...] + plus1 [options] people get <user-id> [-p <v>...] [-o <out>] + plus1 [options] people list <user-id> <collection> [-p <v>...] [-o <out>] + plus1 [options] people list-by-activity <activity-id> <collection> [-p <v>...] [-o <out>] + plus1 [options] people search <query> [-p <v>...] [-o <out>] plus1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_plus1_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -98,6 +99,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -147,6 +151,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -202,6 +209,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -245,6 +255,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -297,6 +310,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -313,39 +329,23 @@ impl Engine { fn _moments_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Moment::default(); - let mut call = self.hub.moments().insert(&request, &self.opt.arg_user_id, &self.opt.arg_collection); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "debug" => { - call = call.debug(arg_from_str(value.unwrap_or("false"), err, "debug", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Moment::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_object_init(request: &mut api::Moment) { if request.object.is_none() { request.object = Some(Default::default()); @@ -364,7 +364,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "start-date" => { request.start_date = Some(value.unwrap_or("").to_string()); }, @@ -869,15 +869,43 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.moments().insert(request, &self.opt.arg_user_id, &self.opt.arg_collection); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "debug" => { + call = call.debug(arg_from_str(value.unwrap_or("false"), err, "debug", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -933,6 +961,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -976,6 +1007,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1017,6 +1051,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1069,6 +1106,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1118,6 +1158,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1170,6 +1213,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1300,6 +1346,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -1307,8 +1354,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/plus1/Cargo.toml b/gen/plus1/Cargo.toml index 090fb2841f..6195fb2729 100644 --- a/gen/plus1/Cargo.toml +++ b/gen/plus1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-plus1" -version = "0.1.5+20150303" +version = "0.1.6+20150303" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with plus (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/plus1" diff --git a/gen/plus1/README.md b/gen/plus1/README.md index 22db0ea089..27131452db 100644 --- a/gen/plus1/README.md +++ b/gen/plus1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-plus1` library allows access to all features of the *Google plus* service. -This documentation was generated from *plus* crate version *0.1.5+20150303*, where *20150303* is the exact revision of the *plus:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *plus* crate version *0.1.6+20150303*, where *20150303* is the exact revision of the *plus:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *plus* *v1* API can be found at the [official documentation site](https://developers.google.com/+/api/). @@ -110,14 +110,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/plus1/src/cmn.rs b/gen/plus1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/plus1/src/cmn.rs +++ b/gen/plus1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/plus1/src/lib.rs b/gen/plus1/src/lib.rs index e9096dffad..5992568c7c 100644 --- a/gen/plus1/src/lib.rs +++ b/gen/plus1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *plus* crate version *0.1.5+20150303*, where *20150303* is the exact revision of the *plus:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *plus* crate version *0.1.6+20150303*, where *20150303* is the exact revision of the *plus:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *plus* *v1* API can be found at the //! [official documentation site](https://developers.google.com/+/api/). @@ -111,14 +111,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -206,7 +207,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -295,14 +296,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -323,7 +325,7 @@ impl<'a, C, A> Plus<C, A> Plus { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -341,7 +343,7 @@ impl<'a, C, A> Plus<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -1669,10 +1671,10 @@ impl<'a, C, A> MomentMethods<'a, C, A> { /// * `request` - No description provided. /// * `userId` - The ID of the user to record actions for. The only valid values are "me" and the ID of the authenticated user. /// * `collection` - The collection to which to write moments. - pub fn insert(&self, request: &Moment, user_id: &str, collection: &str) -> MomentInsertCall<'a, C, A> { + pub fn insert(&self, request: Moment, user_id: &str, collection: &str) -> MomentInsertCall<'a, C, A> { MomentInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_id: user_id.to_string(), _collection: collection.to_string(), _debug: Default::default(), @@ -2062,7 +2064,7 @@ impl<'a, C, A> PeopleMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.moments().insert(&req, "userId", "collection") +/// let result = hub.moments().insert(req, "userId", "collection") /// .debug(false) /// .doit(); /// # } @@ -2197,12 +2199,17 @@ impl<'a, C, A> MomentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2211,7 +2218,7 @@ impl<'a, C, A> MomentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2229,8 +2236,8 @@ impl<'a, C, A> MomentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Moment) -> MomentInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Moment) -> MomentInsertCall<'a, C, A> { + self._request = new_value; self } /// The ID of the user to record actions for. The only valid values are "me" and the ID of the authenticated user. @@ -2479,12 +2486,17 @@ impl<'a, C, A> MomentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2493,7 +2505,7 @@ impl<'a, C, A> MomentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2750,12 +2762,17 @@ impl<'a, C, A> MomentRemoveCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -2970,12 +2987,17 @@ impl<'a, C, A> ActivitySearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2984,7 +3006,7 @@ impl<'a, C, A> ActivitySearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3232,12 +3254,17 @@ impl<'a, C, A> ActivityGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3246,7 +3273,7 @@ impl<'a, C, A> ActivityGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3478,12 +3505,17 @@ impl<'a, C, A> ActivityListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3492,7 +3524,7 @@ impl<'a, C, A> ActivityListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3751,12 +3783,17 @@ impl<'a, C, A> CommentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3765,7 +3802,7 @@ impl<'a, C, A> CommentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4006,12 +4043,17 @@ impl<'a, C, A> CommentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4020,7 +4062,7 @@ impl<'a, C, A> CommentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4231,12 +4273,17 @@ impl<'a, C, A> PeopleSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4245,7 +4292,7 @@ impl<'a, C, A> PeopleSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4498,12 +4545,17 @@ impl<'a, C, A> PeopleListByActivityCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4512,7 +4564,7 @@ impl<'a, C, A> PeopleListByActivityCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4773,12 +4825,17 @@ impl<'a, C, A> PeopleListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4787,7 +4844,7 @@ impl<'a, C, A> PeopleListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5038,12 +5095,17 @@ impl<'a, C, A> PeopleGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5052,7 +5114,7 @@ impl<'a, C, A> PeopleGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/plusdomains1-cli/Cargo.toml b/gen/plusdomains1-cli/Cargo.toml index 79b9b05b21..ed08c527e8 100644 --- a/gen/plusdomains1-cli/Cargo.toml +++ b/gen/plusdomains1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-plusdomains1-cli" -version = "0.0.1+20150303" +version = "0.1.0+20150303" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with plusDomains (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/plusdomains1-cli" diff --git a/gen/plusdomains1-cli/README.md b/gen/plusdomains1-cli/README.md index 6567d52c4e..e5ba604b99 100644 --- a/gen/plusdomains1-cli/README.md +++ b/gen/plusdomains1-cli/README.md @@ -1,4 +1,121 @@ -# HELLO PLUSDOMAINS:V1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `plusdomains1` command-line interface *(CLI)* allows to use most features of the *Google plusDomains* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *plusDomains* API at revision *20150303*. The CLI is at version *0.1.0*. + +```bash + plusdomains1 [options] activities get <activity-id> [-p <v>...] [-o <out>] + plusdomains1 [options] activities insert <user-id> -r <kv>... [-p <v>...] [-o <out>] + plusdomains1 [options] activities list <user-id> <collection> [-p <v>...] [-o <out>] + plusdomains1 [options] audiences list <user-id> [-p <v>...] [-o <out>] + plusdomains1 [options] circles add-people <circle-id> [-p <v>...] [-o <out>] + plusdomains1 [options] circles get <circle-id> [-p <v>...] [-o <out>] + plusdomains1 [options] circles insert <user-id> -r <kv>... [-p <v>...] [-o <out>] + plusdomains1 [options] circles list <user-id> [-p <v>...] [-o <out>] + plusdomains1 [options] circles patch <circle-id> -r <kv>... [-p <v>...] [-o <out>] + plusdomains1 [options] circles remove <circle-id> [-p <v>...] + plusdomains1 [options] circles remove-people <circle-id> [-p <v>...] + plusdomains1 [options] circles update <circle-id> -r <kv>... [-p <v>...] [-o <out>] + plusdomains1 [options] comments get <comment-id> [-p <v>...] [-o <out>] + plusdomains1 [options] comments insert <activity-id> -r <kv>... [-p <v>...] [-o <out>] + plusdomains1 [options] comments list <activity-id> [-p <v>...] [-o <out>] + plusdomains1 [options] media insert <user-id> <collection> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + plusdomains1 [options] people get <user-id> [-p <v>...] [-o <out>] + plusdomains1 [options] people list <user-id> <collection> [-p <v>...] [-o <out>] + plusdomains1 [options] people list-by-activity <activity-id> <collection> [-p <v>...] [-o <out>] + plusdomains1 [options] people list-by-circle <circle-id> [-p <v>...] [-o <out>] + plusdomains1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_plusdomains1_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `plusdomains1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/plusdomains1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/plusdomains1-secret.json`, assuming that the required *plusDomains* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `plusdomains1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/plusdomains1-cli/mkdocs.yml b/gen/plusdomains1-cli/mkdocs.yml index b545e49080..3e8b71e3f1 100644 --- a/gen/plusdomains1-cli/mkdocs.yml +++ b/gen/plusdomains1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: plusDomains v0.0.1+20150303 +site_name: plusDomains v0.1.0+20150303 site_url: http://byron.github.io/google-apis-rs/google-plusdomains1-cli site_description: Write integrating applications with bcore diff --git a/gen/plusdomains1-cli/src/cmn.rs b/gen/plusdomains1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/plusdomains1-cli/src/cmn.rs +++ b/gen/plusdomains1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/plusdomains1-cli/src/main.rs b/gen/plusdomains1-cli/src/main.rs index dcb7112879..52a5c8c538 100644 --- a/gen/plusdomains1-cli/src/main.rs +++ b/gen/plusdomains1-cli/src/main.rs @@ -19,45 +19,46 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - plusdomains1 [options] activities get <activity-id> [-p <v>]... [-o <out>] - plusdomains1 [options] activities insert <user-id> -r <kv>... [-p <v>]... [-o <out>] - plusdomains1 [options] activities list <user-id> <collection> [-p <v>]... [-o <out>] - plusdomains1 [options] audiences list <user-id> [-p <v>]... [-o <out>] - plusdomains1 [options] circles add-people <circle-id> [-p <v>]... [-o <out>] - plusdomains1 [options] circles get <circle-id> [-p <v>]... [-o <out>] - plusdomains1 [options] circles insert <user-id> -r <kv>... [-p <v>]... [-o <out>] - plusdomains1 [options] circles list <user-id> [-p <v>]... [-o <out>] - plusdomains1 [options] circles patch <circle-id> -r <kv>... [-p <v>]... [-o <out>] - plusdomains1 [options] circles remove <circle-id> [-p <v>]... - plusdomains1 [options] circles remove-people <circle-id> [-p <v>]... - plusdomains1 [options] circles update <circle-id> -r <kv>... [-p <v>]... [-o <out>] - plusdomains1 [options] comments get <comment-id> [-p <v>]... [-o <out>] - plusdomains1 [options] comments insert <activity-id> -r <kv>... [-p <v>]... [-o <out>] - plusdomains1 [options] comments list <activity-id> [-p <v>]... [-o <out>] - plusdomains1 [options] media insert <user-id> <collection> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] - plusdomains1 [options] people get <user-id> [-p <v>]... [-o <out>] - plusdomains1 [options] people list <user-id> <collection> [-p <v>]... [-o <out>] - plusdomains1 [options] people list-by-activity <activity-id> <collection> [-p <v>]... [-o <out>] - plusdomains1 [options] people list-by-circle <circle-id> [-p <v>]... [-o <out>] + plusdomains1 [options] activities get <activity-id> [-p <v>...] [-o <out>] + plusdomains1 [options] activities insert <user-id> -r <kv>... [-p <v>...] [-o <out>] + plusdomains1 [options] activities list <user-id> <collection> [-p <v>...] [-o <out>] + plusdomains1 [options] audiences list <user-id> [-p <v>...] [-o <out>] + plusdomains1 [options] circles add-people <circle-id> [-p <v>...] [-o <out>] + plusdomains1 [options] circles get <circle-id> [-p <v>...] [-o <out>] + plusdomains1 [options] circles insert <user-id> -r <kv>... [-p <v>...] [-o <out>] + plusdomains1 [options] circles list <user-id> [-p <v>...] [-o <out>] + plusdomains1 [options] circles patch <circle-id> -r <kv>... [-p <v>...] [-o <out>] + plusdomains1 [options] circles remove <circle-id> [-p <v>...] + plusdomains1 [options] circles remove-people <circle-id> [-p <v>...] + plusdomains1 [options] circles update <circle-id> -r <kv>... [-p <v>...] [-o <out>] + plusdomains1 [options] comments get <comment-id> [-p <v>...] [-o <out>] + plusdomains1 [options] comments insert <activity-id> -r <kv>... [-p <v>...] [-o <out>] + plusdomains1 [options] comments list <activity-id> [-p <v>...] [-o <out>] + plusdomains1 [options] media insert <user-id> <collection> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + plusdomains1 [options] people get <user-id> [-p <v>...] [-o <out>] + plusdomains1 [options] people list <user-id> <collection> [-p <v>...] [-o <out>] + plusdomains1 [options] people list-by-activity <activity-id> <collection> [-p <v>...] [-o <out>] + plusdomains1 [options] people list-by-circle <circle-id> [-p <v>...] [-o <out>] plusdomains1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_plusdomains1_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -106,6 +107,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -122,39 +126,23 @@ impl Engine { fn _activities_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Activity::default(); - let mut call = self.hub.activities().insert(&request, &self.opt.arg_user_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "preview" => { - call = call.preview(arg_from_str(value.unwrap_or("false"), err, "preview", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Activity::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_access_init(request: &mut api::Activity) { if request.access.is_none() { request.access = Some(Default::default()); @@ -255,7 +243,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "place-name" => { request.place_name = Some(value.unwrap_or("").to_string()); }, @@ -459,15 +447,43 @@ impl Engine { request.published = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.activities().insert(request, &self.opt.arg_user_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "preview" => { + call = call.preview(arg_from_str(value.unwrap_or("false"), err, "preview", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -517,6 +533,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -566,6 +585,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -615,6 +637,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -658,6 +683,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -674,43 +702,30 @@ impl Engine { fn _circles_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Circle::default(); - let mut call = self.hub.circles().insert(&request, &self.opt.arg_user_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Circle::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_people_init(request: &mut api::Circle) { if request.people.is_none() { request.people = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -737,15 +752,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.circles().insert(request, &self.opt.arg_user_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -795,6 +835,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -811,43 +854,30 @@ impl Engine { fn _circles_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Circle::default(); - let mut call = self.hub.circles().patch(&request, &self.opt.arg_circle_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Circle::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_people_init(request: &mut api::Circle) { if request.people.is_none() { request.people = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -874,15 +904,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.circles().patch(request, &self.opt.arg_circle_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -926,6 +981,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -973,6 +1031,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -987,43 +1048,30 @@ impl Engine { fn _circles_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Circle::default(); - let mut call = self.hub.circles().update(&request, &self.opt.arg_circle_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Circle::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_people_init(request: &mut api::Circle) { if request.people.is_none() { request.people = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1050,15 +1098,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.circles().update(request, &self.opt.arg_circle_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1102,6 +1175,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1118,36 +1194,23 @@ impl Engine { fn _comments_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Comment::default(); - let mut call = self.hub.comments().insert(&request, &self.opt.arg_activity_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Comment::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_actor_image_init(request: &mut api::Comment) { request_actor_init(request); if request.actor.as_mut().unwrap().image.is_none() { @@ -1173,7 +1236,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1234,15 +1297,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.comments().insert(request, &self.opt.arg_activity_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1295,6 +1383,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1311,36 +1402,23 @@ impl Engine { fn _media_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Media::default(); - let mut call = self.hub.media().insert(&request, &self.opt.arg_user_id, &self.opt.arg_collection); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Media::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_author_image_init(request: &mut api::Media) { request_author_init(request); if request.author.as_mut().unwrap().image.is_none() { @@ -1360,7 +1438,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "updated" => { request.updated = Some(value.unwrap_or("").to_string()); }, @@ -1440,10 +1518,32 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.media().insert(request, &self.opt.arg_user_id, &self.opt.arg_collection); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = if self.opt.cmd_simple { "simple" @@ -1458,6 +1558,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -1502,6 +1605,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1554,6 +1660,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1603,6 +1712,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1652,6 +1764,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1808,6 +1923,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -1815,8 +1931,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/plusdomains1/Cargo.toml b/gen/plusdomains1/Cargo.toml index a4b0052e03..d792de681a 100644 --- a/gen/plusdomains1/Cargo.toml +++ b/gen/plusdomains1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-plusdomains1" -version = "0.1.5+20150303" +version = "0.1.6+20150303" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with plusDomains (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/plusdomains1" diff --git a/gen/plusdomains1/README.md b/gen/plusdomains1/README.md index 1073cf3a38..03d847dbf9 100644 --- a/gen/plusdomains1/README.md +++ b/gen/plusdomains1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-plusdomains1` library allows access to all features of the *Google plusDomains* service. -This documentation was generated from *plusDomains* crate version *0.1.5+20150303*, where *20150303* is the exact revision of the *plusDomains:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *plusDomains* crate version *0.1.6+20150303*, where *20150303* is the exact revision of the *plusDomains:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *plusDomains* *v1* API can be found at the [official documentation site](https://developers.google.com/+/domains/). @@ -122,14 +122,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/plusdomains1/src/cmn.rs b/gen/plusdomains1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/plusdomains1/src/cmn.rs +++ b/gen/plusdomains1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/plusdomains1/src/lib.rs b/gen/plusdomains1/src/lib.rs index f8a1b1176c..6e04be32a6 100644 --- a/gen/plusdomains1/src/lib.rs +++ b/gen/plusdomains1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *plusDomains* crate version *0.1.5+20150303*, where *20150303* is the exact revision of the *plusDomains:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *plusDomains* crate version *0.1.6+20150303*, where *20150303* is the exact revision of the *plusDomains:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *plusDomains* *v1* API can be found at the //! [official documentation site](https://developers.google.com/+/domains/). @@ -123,14 +123,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -218,7 +219,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -330,14 +331,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -358,7 +360,7 @@ impl<'a, C, A> PlusDomains<C, A> PlusDomains { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -382,7 +384,7 @@ impl<'a, C, A> PlusDomains<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -1817,10 +1819,10 @@ impl<'a, C, A> CircleMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `userId` - The ID of the user to create the circle on behalf of. The value "me" can be used to indicate the authenticated user. - pub fn insert(&self, request: &Circle, user_id: &str) -> CircleInsertCall<'a, C, A> { + pub fn insert(&self, request: Circle, user_id: &str) -> CircleInsertCall<'a, C, A> { CircleInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_id: user_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1891,10 +1893,10 @@ impl<'a, C, A> CircleMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `circleId` - The ID of the circle to update. - pub fn update(&self, request: &Circle, circle_id: &str) -> CircleUpdateCall<'a, C, A> { + pub fn update(&self, request: Circle, circle_id: &str) -> CircleUpdateCall<'a, C, A> { CircleUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _circle_id: circle_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1910,10 +1912,10 @@ impl<'a, C, A> CircleMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `circleId` - The ID of the circle to update. - pub fn patch(&self, request: &Circle, circle_id: &str) -> CirclePatchCall<'a, C, A> { + pub fn patch(&self, request: Circle, circle_id: &str) -> CirclePatchCall<'a, C, A> { CirclePatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _circle_id: circle_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1987,10 +1989,10 @@ impl<'a, C, A> ActivityMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `userId` - The ID of the user to create the activity on behalf of. Its value should be "me", to indicate the authenticated user. - pub fn insert(&self, request: &Activity, user_id: &str) -> ActivityInsertCall<'a, C, A> { + pub fn insert(&self, request: Activity, user_id: &str) -> ActivityInsertCall<'a, C, A> { ActivityInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_id: user_id.to_string(), _preview: Default::default(), _delegate: Default::default(), @@ -2207,10 +2209,10 @@ impl<'a, C, A> MediaMethods<'a, C, A> { /// * `request` - No description provided. /// * `userId` - The ID of the user to create the activity on behalf of. /// * `collection` - No description provided. - pub fn insert(&self, request: &Media, user_id: &str, collection: &str) -> MediaInsertCall<'a, C, A> { + pub fn insert(&self, request: Media, user_id: &str, collection: &str) -> MediaInsertCall<'a, C, A> { MediaInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _user_id: user_id.to_string(), _collection: collection.to_string(), _delegate: Default::default(), @@ -2268,10 +2270,10 @@ impl<'a, C, A> CommentMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `activityId` - The ID of the activity to reply to. - pub fn insert(&self, request: &Comment, activity_id: &str) -> CommentInsertCall<'a, C, A> { + pub fn insert(&self, request: Comment, activity_id: &str) -> CommentInsertCall<'a, C, A> { CommentInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _activity_id: activity_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2547,12 +2549,17 @@ impl<'a, C, A> CircleRemovePeopleCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -2674,7 +2681,7 @@ impl<'a, C, A> CircleRemovePeopleCall<'a, C, A> where C: BorrowMut<hyper::Client /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.circles().insert(&req, "userId") +/// let result = hub.circles().insert(req, "userId") /// .doit(); /// # } /// ``` @@ -2802,12 +2809,17 @@ impl<'a, C, A> CircleInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2816,7 +2828,7 @@ impl<'a, C, A> CircleInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2834,8 +2846,8 @@ impl<'a, C, A> CircleInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Circle) -> CircleInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Circle) -> CircleInsertCall<'a, C, A> { + self._request = new_value; self } /// The ID of the user to create the circle on behalf of. The value "me" can be used to indicate the authenticated user. @@ -3063,12 +3075,17 @@ impl<'a, C, A> CircleAddPeopleCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3077,7 +3094,7 @@ impl<'a, C, A> CircleAddPeopleCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3313,12 +3330,17 @@ impl<'a, C, A> CircleGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3327,7 +3349,7 @@ impl<'a, C, A> CircleGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3557,12 +3579,17 @@ impl<'a, C, A> CircleListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3571,7 +3598,7 @@ impl<'a, C, A> CircleListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3692,7 +3719,7 @@ impl<'a, C, A> CircleListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.circles().update(&req, "circleId") +/// let result = hub.circles().update(req, "circleId") /// .doit(); /// # } /// ``` @@ -3820,12 +3847,17 @@ impl<'a, C, A> CircleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3834,7 +3866,7 @@ impl<'a, C, A> CircleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3852,8 +3884,8 @@ impl<'a, C, A> CircleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Circle) -> CircleUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Circle) -> CircleUpdateCall<'a, C, A> { + self._request = new_value; self } /// The ID of the circle to update. @@ -3950,7 +3982,7 @@ impl<'a, C, A> CircleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.circles().patch(&req, "circleId") +/// let result = hub.circles().patch(req, "circleId") /// .doit(); /// # } /// ``` @@ -4078,12 +4110,17 @@ impl<'a, C, A> CirclePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4092,7 +4129,7 @@ impl<'a, C, A> CirclePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4110,8 +4147,8 @@ impl<'a, C, A> CirclePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Circle) -> CirclePatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Circle) -> CirclePatchCall<'a, C, A> { + self._request = new_value; self } /// The ID of the circle to update. @@ -4320,12 +4357,17 @@ impl<'a, C, A> CircleRemoveCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -4431,7 +4473,7 @@ impl<'a, C, A> CircleRemoveCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.activities().insert(&req, "userId") +/// let result = hub.activities().insert(req, "userId") /// .preview(true) /// .doit(); /// # } @@ -4564,12 +4606,17 @@ impl<'a, C, A> ActivityInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4578,7 +4625,7 @@ impl<'a, C, A> ActivityInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4596,8 +4643,8 @@ impl<'a, C, A> ActivityInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Activity) -> ActivityInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Activity) -> ActivityInsertCall<'a, C, A> { + self._request = new_value; self } /// The ID of the user to create the activity on behalf of. Its value should be "me", to indicate the authenticated user. @@ -4814,12 +4861,17 @@ impl<'a, C, A> ActivityGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4828,7 +4880,7 @@ impl<'a, C, A> ActivityGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5060,12 +5112,17 @@ impl<'a, C, A> ActivityListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5074,7 +5131,7 @@ impl<'a, C, A> ActivityListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5328,12 +5385,17 @@ impl<'a, C, A> PeopleListByCircleCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5342,7 +5404,7 @@ impl<'a, C, A> PeopleListByCircleCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5593,12 +5655,17 @@ impl<'a, C, A> PeopleListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5607,7 +5674,7 @@ impl<'a, C, A> PeopleListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5858,12 +5925,17 @@ impl<'a, C, A> PeopleGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5872,7 +5944,7 @@ impl<'a, C, A> PeopleGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6104,12 +6176,17 @@ impl<'a, C, A> PeopleListByActivityCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6118,7 +6195,7 @@ impl<'a, C, A> PeopleListByActivityCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6250,7 +6327,7 @@ impl<'a, C, A> PeopleListByActivityCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.media().insert(&req, "userId", "collection") +/// let result = hub.media().insert(req, "userId", "collection") /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } /// ``` @@ -6298,14 +6375,15 @@ impl<'a, C, A> MediaInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/plusDomains/v1/people/{userId}/media/{collection}".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/plusDomains/v1/people/{userId}/media/{collection}".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/plusDomains/v1/people/{userId}/media/{collection}".to_string() + ("https://www.googleapis.com/resumable/upload/plusDomains/v1/people/{userId}/media/{collection}".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::PluLogin.as_ref().to_string(), ()); } @@ -6422,12 +6500,17 @@ impl<'a, C, A> MediaInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -6435,9 +6518,9 @@ impl<'a, C, A> MediaInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -6447,7 +6530,7 @@ impl<'a, C, A> MediaInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -6478,7 +6561,7 @@ impl<'a, C, A> MediaInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6522,8 +6605,8 @@ impl<'a, C, A> MediaInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Media) -> MediaInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Media) -> MediaInsertCall<'a, C, A> { + self._request = new_value; self } /// The ID of the user to create the activity on behalf of. @@ -6629,7 +6712,7 @@ impl<'a, C, A> MediaInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.comments().insert(&req, "activityId") +/// let result = hub.comments().insert(req, "activityId") /// .doit(); /// # } /// ``` @@ -6757,12 +6840,17 @@ impl<'a, C, A> CommentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6771,7 +6859,7 @@ impl<'a, C, A> CommentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6789,8 +6877,8 @@ impl<'a, C, A> CommentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Comment) -> CommentInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Comment) -> CommentInsertCall<'a, C, A> { + self._request = new_value; self } /// The ID of the activity to reply to. @@ -7015,12 +7103,17 @@ impl<'a, C, A> CommentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7029,7 +7122,7 @@ impl<'a, C, A> CommentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7270,12 +7363,17 @@ impl<'a, C, A> CommentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7284,7 +7382,7 @@ impl<'a, C, A> CommentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7514,12 +7612,17 @@ impl<'a, C, A> AudienceListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7528,7 +7631,7 @@ impl<'a, C, A> AudienceListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/prediction1d6-cli/Cargo.toml b/gen/prediction1d6-cli/Cargo.toml index 59d02e58df..00b813c6a6 100644 --- a/gen/prediction1d6-cli/Cargo.toml +++ b/gen/prediction1d6-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-prediction1d6-cli" -version = "0.0.1+20140522" +version = "0.1.0+20140522" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with prediction (protocol v1.6)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/prediction1d6-cli" diff --git a/gen/prediction1d6-cli/README.md b/gen/prediction1d6-cli/README.md index 77a70ce2d2..fcff4605bc 100644 --- a/gen/prediction1d6-cli/README.md +++ b/gen/prediction1d6-cli/README.md @@ -1,4 +1,109 @@ -# HELLO PREDICTION:V1.6 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `prediction1d6` command-line interface *(CLI)* allows to use most features of the *Google prediction* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *prediction* API at revision *20140522*. The CLI is at version *0.1.0*. + +```bash + prediction1d6 [options] hostedmodels predict <project> <hosted-model-name> -r <kv>... [-p <v>...] [-o <out>] + prediction1d6 [options] trainedmodels analyze <project> <id> [-p <v>...] [-o <out>] + prediction1d6 [options] trainedmodels delete <project> <id> [-p <v>...] + prediction1d6 [options] trainedmodels get <project> <id> [-p <v>...] [-o <out>] + prediction1d6 [options] trainedmodels insert <project> -r <kv>... [-p <v>...] [-o <out>] + prediction1d6 [options] trainedmodels list <project> [-p <v>...] [-o <out>] + prediction1d6 [options] trainedmodels predict <project> <id> -r <kv>... [-p <v>...] [-o <out>] + prediction1d6 [options] trainedmodels update <project> <id> -r <kv>... [-p <v>...] [-o <out>] + prediction1d6 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_prediction1d6_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `prediction1d6-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/prediction1d6-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/prediction1d6-secret.json`, assuming that the required *prediction* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `prediction1d6 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/prediction1d6-cli/mkdocs.yml b/gen/prediction1d6-cli/mkdocs.yml index 61cb4baff0..6d33de3c7f 100644 --- a/gen/prediction1d6-cli/mkdocs.yml +++ b/gen/prediction1d6-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: prediction v0.0.1+20140522 +site_name: prediction v0.1.0+20140522 site_url: http://byron.github.io/google-apis-rs/google-prediction1d6-cli site_description: Write integrating applications with bcore diff --git a/gen/prediction1d6-cli/src/cmn.rs b/gen/prediction1d6-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/prediction1d6-cli/src/cmn.rs +++ b/gen/prediction1d6-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/prediction1d6-cli/src/main.rs b/gen/prediction1d6-cli/src/main.rs index 57df417732..bc01507695 100644 --- a/gen/prediction1d6-cli/src/main.rs +++ b/gen/prediction1d6-cli/src/main.rs @@ -19,33 +19,34 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - prediction1d6 [options] hostedmodels predict <project> <hosted-model-name> -r <kv>... [-p <v>]... [-o <out>] - prediction1d6 [options] trainedmodels analyze <project> <id> [-p <v>]... [-o <out>] - prediction1d6 [options] trainedmodels delete <project> <id> [-p <v>]... - prediction1d6 [options] trainedmodels get <project> <id> [-p <v>]... [-o <out>] - prediction1d6 [options] trainedmodels insert <project> -r <kv>... [-p <v>]... [-o <out>] - prediction1d6 [options] trainedmodels list <project> [-p <v>]... [-o <out>] - prediction1d6 [options] trainedmodels predict <project> <id> -r <kv>... [-p <v>]... [-o <out>] - prediction1d6 [options] trainedmodels update <project> <id> -r <kv>... [-p <v>]... [-o <out>] + prediction1d6 [options] hostedmodels predict <project> <hosted-model-name> -r <kv>... [-p <v>...] [-o <out>] + prediction1d6 [options] trainedmodels analyze <project> <id> [-p <v>...] [-o <out>] + prediction1d6 [options] trainedmodels delete <project> <id> [-p <v>...] + prediction1d6 [options] trainedmodels get <project> <id> [-p <v>...] [-o <out>] + prediction1d6 [options] trainedmodels insert <project> -r <kv>... [-p <v>...] [-o <out>] + prediction1d6 [options] trainedmodels list <project> [-p <v>...] [-o <out>] + prediction1d6 [options] trainedmodels predict <project> <id> -r <kv>... [-p <v>...] [-o <out>] + prediction1d6 [options] trainedmodels update <project> <id> -r <kv>... [-p <v>...] [-o <out>] prediction1d6 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_prediction1d6_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -67,8 +68,30 @@ struct Engine { impl Engine { fn _hostedmodels_predict(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Input::default(); - let mut call = self.hub.hostedmodels().predict(&request, &self.opt.arg_project, &self.opt.arg_hosted_model_name); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.hostedmodels().predict(request, &self.opt.arg_project, &self.opt.arg_hosted_model_name); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -90,24 +113,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -151,6 +164,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -194,6 +210,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -235,6 +254,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -251,8 +273,48 @@ impl Engine { fn _trainedmodels_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Insert::default(); - let mut call = self.hub.trainedmodels().insert(&request, &self.opt.arg_project); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "storage-data-location" => { + request.storage_data_location = Some(value.unwrap_or("").to_string()); + }, + "model-type" => { + request.model_type = Some(value.unwrap_or("").to_string()); + }, + "storage-pmml-model-location" => { + request.storage_pmml_model_location = Some(value.unwrap_or("").to_string()); + }, + "source-model" => { + request.source_model = Some(value.unwrap_or("").to_string()); + }, + "storage-pmml-location" => { + request.storage_pmml_location = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.trainedmodels().insert(request, &self.opt.arg_project); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -274,42 +336,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "storage-data-location" => { - request.storage_data_location = Some(value.unwrap_or("").to_string()); - }, - "model-type" => { - request.model_type = Some(value.unwrap_or("").to_string()); - }, - "storage-pmml-model-location" => { - request.storage_pmml_model_location = Some(value.unwrap_or("").to_string()); - }, - "source-model" => { - request.source_model = Some(value.unwrap_or("").to_string()); - }, - "storage-pmml-location" => { - request.storage_pmml_location = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -359,6 +393,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -375,8 +412,30 @@ impl Engine { fn _trainedmodels_predict(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Input::default(); - let mut call = self.hub.trainedmodels().predict(&request, &self.opt.arg_project, &self.opt.arg_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.trainedmodels().predict(request, &self.opt.arg_project, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -398,24 +457,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -432,8 +481,33 @@ impl Engine { fn _trainedmodels_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Update::default(); - let mut call = self.hub.trainedmodels().update(&request, &self.opt.arg_project, &self.opt.arg_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "output" => { + request.output = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.trainedmodels().update(request, &self.opt.arg_project, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -455,27 +529,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "output" => { - request.output = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -588,6 +649,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -595,8 +657,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/prediction1d6/Cargo.toml b/gen/prediction1d6/Cargo.toml index 857e20bdd1..a85f237d63 100644 --- a/gen/prediction1d6/Cargo.toml +++ b/gen/prediction1d6/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-prediction1d6" -version = "0.1.5+20140522" +version = "0.1.6+20140522" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with prediction (protocol v1.6)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/prediction1d6" diff --git a/gen/prediction1d6/README.md b/gen/prediction1d6/README.md index 3fb800f6e9..d06060ef0f 100644 --- a/gen/prediction1d6/README.md +++ b/gen/prediction1d6/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-prediction1d6` library allows access to all features of the *Google prediction* service. -This documentation was generated from *prediction* crate version *0.1.5+20140522*, where *20140522* is the exact revision of the *prediction:v1.6* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *prediction* crate version *0.1.6+20140522*, where *20140522* is the exact revision of the *prediction:v1.6* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *prediction* *v1d6* API can be found at the [official documentation site](https://developers.google.com/prediction/docs/developer-guide). @@ -102,21 +102,22 @@ let mut req = Update::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.trainedmodels().update(&req, "project", "id") +let result = hub.trainedmodels().update(req, "project", "id") .doit(); match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/prediction1d6/src/cmn.rs b/gen/prediction1d6/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/prediction1d6/src/cmn.rs +++ b/gen/prediction1d6/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/prediction1d6/src/lib.rs b/gen/prediction1d6/src/lib.rs index ca3860c31b..131fe41ed6 100644 --- a/gen/prediction1d6/src/lib.rs +++ b/gen/prediction1d6/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *prediction* crate version *0.1.5+20140522*, where *20140522* is the exact revision of the *prediction:v1.6* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *prediction* crate version *0.1.6+20140522*, where *20140522* is the exact revision of the *prediction:v1.6* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *prediction* *v1d6* API can be found at the //! [official documentation site](https://developers.google.com/prediction/docs/developer-guide). @@ -103,21 +103,22 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.trainedmodels().update(&req, "project", "id") +//! let result = hub.trainedmodels().update(req, "project", "id") //! .doit(); //! //! match result { //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -205,7 +206,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -290,21 +291,22 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.trainedmodels().update(&req, "project", "id") +/// let result = hub.trainedmodels().update(req, "project", "id") /// .doit(); /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -325,7 +327,7 @@ impl<'a, C, A> Prediction<C, A> Prediction { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -337,7 +339,7 @@ impl<'a, C, A> Prediction<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -887,10 +889,10 @@ impl<'a, C, A> TrainedmodelMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - The project associated with the model. /// * `id` - The unique name for the predictive model. - pub fn update(&self, request: &Update, project: &str, id: &str) -> TrainedmodelUpdateCall<'a, C, A> { + pub fn update(&self, request: Update, project: &str, id: &str) -> TrainedmodelUpdateCall<'a, C, A> { TrainedmodelUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -945,10 +947,10 @@ impl<'a, C, A> TrainedmodelMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `project` - The project associated with the model. - pub fn insert(&self, request: &Insert, project: &str) -> TrainedmodelInsertCall<'a, C, A> { + pub fn insert(&self, request: Insert, project: &str) -> TrainedmodelInsertCall<'a, C, A> { TrainedmodelInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -984,10 +986,10 @@ impl<'a, C, A> TrainedmodelMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - The project associated with the model. /// * `id` - The unique name for the predictive model. - pub fn predict(&self, request: &Input, project: &str, id: &str) -> TrainedmodelPredictCall<'a, C, A> { + pub fn predict(&self, request: Input, project: &str, id: &str) -> TrainedmodelPredictCall<'a, C, A> { TrainedmodelPredictCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -1046,10 +1048,10 @@ impl<'a, C, A> HostedmodelMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - The project associated with the model. /// * `hostedModelName` - The name of a hosted model. - pub fn predict(&self, request: &Input, project: &str, hosted_model_name: &str) -> HostedmodelPredictCall<'a, C, A> { + pub fn predict(&self, request: Input, project: &str, hosted_model_name: &str) -> HostedmodelPredictCall<'a, C, A> { HostedmodelPredictCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _hosted_model_name: hosted_model_name.to_string(), _delegate: Default::default(), @@ -1214,12 +1216,17 @@ impl<'a, C, A> TrainedmodelGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1228,7 +1235,7 @@ impl<'a, C, A> TrainedmodelGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1345,7 +1352,7 @@ impl<'a, C, A> TrainedmodelGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.trainedmodels().update(&req, "project", "id") +/// let result = hub.trainedmodels().update(req, "project", "id") /// .doit(); /// # } /// ``` @@ -1475,12 +1482,17 @@ impl<'a, C, A> TrainedmodelUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1489,7 +1501,7 @@ impl<'a, C, A> TrainedmodelUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1507,8 +1519,8 @@ impl<'a, C, A> TrainedmodelUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Update) -> TrainedmodelUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Update) -> TrainedmodelUpdateCall<'a, C, A> { + self._request = new_value; self } /// The project associated with the model. @@ -1738,12 +1750,17 @@ impl<'a, C, A> TrainedmodelListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1752,7 +1769,7 @@ impl<'a, C, A> TrainedmodelListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1987,12 +2004,17 @@ impl<'a, C, A> TrainedmodelDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -2108,7 +2130,7 @@ impl<'a, C, A> TrainedmodelDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.trainedmodels().insert(&req, "project") +/// let result = hub.trainedmodels().insert(req, "project") /// .doit(); /// # } /// ``` @@ -2236,12 +2258,17 @@ impl<'a, C, A> TrainedmodelInsertCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2250,7 +2277,7 @@ impl<'a, C, A> TrainedmodelInsertCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2268,8 +2295,8 @@ impl<'a, C, A> TrainedmodelInsertCall<'a, C, A> where C: BorrowMut<hyper::Client /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Insert) -> TrainedmodelInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Insert) -> TrainedmodelInsertCall<'a, C, A> { + self._request = new_value; self } /// The project associated with the model. @@ -2481,12 +2508,17 @@ impl<'a, C, A> TrainedmodelAnalyzeCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2495,7 +2527,7 @@ impl<'a, C, A> TrainedmodelAnalyzeCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2612,7 +2644,7 @@ impl<'a, C, A> TrainedmodelAnalyzeCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.trainedmodels().predict(&req, "project", "id") +/// let result = hub.trainedmodels().predict(req, "project", "id") /// .doit(); /// # } /// ``` @@ -2742,12 +2774,17 @@ impl<'a, C, A> TrainedmodelPredictCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2756,7 +2793,7 @@ impl<'a, C, A> TrainedmodelPredictCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2774,8 +2811,8 @@ impl<'a, C, A> TrainedmodelPredictCall<'a, C, A> where C: BorrowMut<hyper::Clien /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Input) -> TrainedmodelPredictCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Input) -> TrainedmodelPredictCall<'a, C, A> { + self._request = new_value; self } /// The project associated with the model. @@ -2882,7 +2919,7 @@ impl<'a, C, A> TrainedmodelPredictCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.hostedmodels().predict(&req, "project", "hostedModelName") +/// let result = hub.hostedmodels().predict(req, "project", "hostedModelName") /// .doit(); /// # } /// ``` @@ -3012,12 +3049,17 @@ impl<'a, C, A> HostedmodelPredictCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3026,7 +3068,7 @@ impl<'a, C, A> HostedmodelPredictCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3044,8 +3086,8 @@ impl<'a, C, A> HostedmodelPredictCall<'a, C, A> where C: BorrowMut<hyper::Client /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Input) -> HostedmodelPredictCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Input) -> HostedmodelPredictCall<'a, C, A> { + self._request = new_value; self } /// The project associated with the model. diff --git a/gen/pubsub1_beta2-cli/Cargo.toml b/gen/pubsub1_beta2-cli/Cargo.toml index c3e7445e94..ee18f89f70 100644 --- a/gen/pubsub1_beta2-cli/Cargo.toml +++ b/gen/pubsub1_beta2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-pubsub1_beta2-cli" -version = "0.0.1+20150326" +version = "0.1.0+20150326" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with pubsub (protocol v1beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/pubsub1_beta2-cli" diff --git a/gen/pubsub1_beta2-cli/README.md b/gen/pubsub1_beta2-cli/README.md index ec8932c2fd..a62fb376c7 100644 --- a/gen/pubsub1_beta2-cli/README.md +++ b/gen/pubsub1_beta2-cli/README.md @@ -1,4 +1,115 @@ -# HELLO PUBSUB:V1BETA2 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `pubsub1-beta2` command-line interface *(CLI)* allows to use most features of the *Google pubsub* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *pubsub* API at revision *20150326*. The CLI is at version *0.1.0*. + +```bash + pubsub1-beta2 [options] projects subscriptions-acknowledge <subscription> -r <kv>... [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects subscriptions-create <name> -r <kv>... [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects subscriptions-delete <subscription> [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects subscriptions-get <subscription> [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects subscriptions-list <project> [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects subscriptions-modify-ack-deadline <subscription> -r <kv>... [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects subscriptions-modify-push-config <subscription> -r <kv>... [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects subscriptions-pull <subscription> -r <kv>... [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects topics-create <name> -r <kv>... [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects topics-delete <topic> [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects topics-get <topic> [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects topics-list <project> [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects topics-publish <topic> -r <kv>... [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects topics-subscriptions-list <topic> [-p <v>...] [-o <out>] + pubsub1-beta2 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_pubsub1_beta2_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `pubsub1-beta2-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/pubsub1-beta2-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/pubsub1-beta2-secret.json`, assuming that the required *pubsub* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `pubsub1-beta2 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/pubsub1_beta2-cli/mkdocs.yml b/gen/pubsub1_beta2-cli/mkdocs.yml index f92e8ae4a1..bc50e18aff 100644 --- a/gen/pubsub1_beta2-cli/mkdocs.yml +++ b/gen/pubsub1_beta2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: pubsub v0.0.1+20150326 +site_name: pubsub v0.1.0+20150326 site_url: http://byron.github.io/google-apis-rs/google-pubsub1_beta2-cli site_description: Write integrating applications with bcore diff --git a/gen/pubsub1_beta2-cli/src/cmn.rs b/gen/pubsub1_beta2-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/pubsub1_beta2-cli/src/cmn.rs +++ b/gen/pubsub1_beta2-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/pubsub1_beta2-cli/src/main.rs b/gen/pubsub1_beta2-cli/src/main.rs index 9aa088c4e3..18bdd1d6ce 100644 --- a/gen/pubsub1_beta2-cli/src/main.rs +++ b/gen/pubsub1_beta2-cli/src/main.rs @@ -19,39 +19,40 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - pubsub1-beta2 [options] projects subscriptions-acknowledge <subscription> -r <kv>... [-p <v>]... [-o <out>] - pubsub1-beta2 [options] projects subscriptions-create <name> -r <kv>... [-p <v>]... [-o <out>] - pubsub1-beta2 [options] projects subscriptions-delete <subscription> [-p <v>]... [-o <out>] - pubsub1-beta2 [options] projects subscriptions-get <subscription> [-p <v>]... [-o <out>] - pubsub1-beta2 [options] projects subscriptions-list <project> [-p <v>]... [-o <out>] - pubsub1-beta2 [options] projects subscriptions-modify-ack-deadline <subscription> -r <kv>... [-p <v>]... [-o <out>] - pubsub1-beta2 [options] projects subscriptions-modify-push-config <subscription> -r <kv>... [-p <v>]... [-o <out>] - pubsub1-beta2 [options] projects subscriptions-pull <subscription> -r <kv>... [-p <v>]... [-o <out>] - pubsub1-beta2 [options] projects topics-create <name> -r <kv>... [-p <v>]... [-o <out>] - pubsub1-beta2 [options] projects topics-delete <topic> [-p <v>]... [-o <out>] - pubsub1-beta2 [options] projects topics-get <topic> [-p <v>]... [-o <out>] - pubsub1-beta2 [options] projects topics-list <project> [-p <v>]... [-o <out>] - pubsub1-beta2 [options] projects topics-publish <topic> -r <kv>... [-p <v>]... [-o <out>] - pubsub1-beta2 [options] projects topics-subscriptions-list <topic> [-p <v>]... [-o <out>] + pubsub1-beta2 [options] projects subscriptions-acknowledge <subscription> -r <kv>... [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects subscriptions-create <name> -r <kv>... [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects subscriptions-delete <subscription> [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects subscriptions-get <subscription> [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects subscriptions-list <project> [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects subscriptions-modify-ack-deadline <subscription> -r <kv>... [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects subscriptions-modify-push-config <subscription> -r <kv>... [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects subscriptions-pull <subscription> -r <kv>... [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects topics-create <name> -r <kv>... [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects topics-delete <topic> [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects topics-get <topic> [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects topics-list <project> [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects topics-publish <topic> -r <kv>... [-p <v>...] [-o <out>] + pubsub1-beta2 [options] projects topics-subscriptions-list <topic> [-p <v>...] [-o <out>] pubsub1-beta2 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_pubsub1_beta2_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -73,8 +74,36 @@ struct Engine { impl Engine { fn _projects_subscriptions_acknowledge(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::AcknowledgeRequest::default(); - let mut call = self.hub.projects().subscriptions_acknowledge(&request, &self.opt.arg_subscription); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "ack-ids" => { + if request.ack_ids.is_none() { + request.ack_ids = Some(Default::default()); + } + request.ack_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.projects().subscriptions_acknowledge(request, &self.opt.arg_subscription); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -96,30 +125,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "ack-ids" => { - if request.ack_ids.is_none() { - request.ack_ids = Some(Default::default()); - } - request.ack_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -136,43 +149,30 @@ impl Engine { fn _projects_subscriptions_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Subscription::default(); - let mut call = self.hub.projects().subscriptions_create(&request, &self.opt.arg_name); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Subscription::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_push_config_init(request: &mut api::Subscription) { if request.push_config.is_none() { request.push_config = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "ack-deadline-seconds" => { request.ack_deadline_seconds = Some(arg_from_str(value.unwrap_or("-0"), err, "ack-deadline-seconds", "integer")); }, @@ -196,15 +196,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.projects().subscriptions_create(request, &self.opt.arg_name); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -248,6 +273,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -291,6 +319,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -340,6 +371,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -356,8 +390,36 @@ impl Engine { fn _projects_subscriptions_modify_ack_deadline(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::ModifyAckDeadlineRequest::default(); - let mut call = self.hub.projects().subscriptions_modify_ack_deadline(&request, &self.opt.arg_subscription); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "ack-deadline-seconds" => { + request.ack_deadline_seconds = Some(arg_from_str(value.unwrap_or("-0"), err, "ack-deadline-seconds", "integer")); + }, + "ack-id" => { + request.ack_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.projects().subscriptions_modify_ack_deadline(request, &self.opt.arg_subscription); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -379,30 +441,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "ack-deadline-seconds" => { - request.ack_deadline_seconds = Some(arg_from_str(value.unwrap_or("-0"), err, "ack-deadline-seconds", "integer")); - }, - "ack-id" => { - request.ack_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -419,8 +465,48 @@ impl Engine { fn _projects_subscriptions_modify_push_config(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::ModifyPushConfigRequest::default(); - let mut call = self.hub.projects().subscriptions_modify_push_config(&request, &self.opt.arg_subscription); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + fn request_push_config_init(request: &mut api::ModifyPushConfigRequest) { + if request.push_config.is_none() { + request.push_config = Some(Default::default()); + } + } + + match &temp_cursor.to_string()[..] { + "push-config.attributes" => { + request_push_config_init(&mut request); + if request.push_config.as_mut().unwrap().attributes.is_none() { + request.push_config.as_mut().unwrap().attributes = Some(Default::default()); + } + let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); + request.push_config.as_mut().unwrap().attributes.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); + }, + "push-config.push-endpoint" => { + request_push_config_init(&mut request); + request.push_config.as_mut().unwrap().push_endpoint = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.projects().subscriptions_modify_push_config(request, &self.opt.arg_subscription); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -442,42 +528,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_push_config_init(request: &mut api::ModifyPushConfigRequest) { - if request.push_config.is_none() { - request.push_config = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "push-config.attributes" => { - request_push_config_init(&mut request); - if request.push_config.as_mut().unwrap().attributes.is_none() { - request.push_config.as_mut().unwrap().attributes = Some(Default::default()); - } - let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); - request.push_config.as_mut().unwrap().attributes.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); - }, - "push-config.push-endpoint" => { - request_push_config_init(&mut request); - request.push_config.as_mut().unwrap().push_endpoint = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -494,8 +552,36 @@ impl Engine { fn _projects_subscriptions_pull(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::PullRequest::default(); - let mut call = self.hub.projects().subscriptions_pull(&request, &self.opt.arg_subscription); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "return-immediately" => { + request.return_immediately = Some(arg_from_str(value.unwrap_or("false"), err, "return-immediately", "boolean")); + }, + "max-messages" => { + request.max_messages = Some(arg_from_str(value.unwrap_or("-0"), err, "max-messages", "integer")); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.projects().subscriptions_pull(request, &self.opt.arg_subscription); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -517,30 +603,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "return-immediately" => { - request.return_immediately = Some(arg_from_str(value.unwrap_or("false"), err, "return-immediately", "boolean")); - }, - "max-messages" => { - request.max_messages = Some(arg_from_str(value.unwrap_or("-0"), err, "max-messages", "integer")); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -557,8 +627,33 @@ impl Engine { fn _projects_topics_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Topic::default(); - let mut call = self.hub.projects().topics_create(&request, &self.opt.arg_name); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.projects().topics_create(request, &self.opt.arg_name); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -580,27 +675,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -644,6 +726,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -687,6 +772,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -736,6 +824,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -752,8 +843,30 @@ impl Engine { fn _projects_topics_publish(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::PublishRequest::default(); - let mut call = self.hub.projects().topics_publish(&request, &self.opt.arg_topic); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.projects().topics_publish(request, &self.opt.arg_topic); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -775,24 +888,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -842,6 +945,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -961,6 +1067,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -968,8 +1075,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/pubsub1_beta2/Cargo.toml b/gen/pubsub1_beta2/Cargo.toml index adcf77a5f5..087f49471c 100644 --- a/gen/pubsub1_beta2/Cargo.toml +++ b/gen/pubsub1_beta2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-pubsub1_beta2" -version = "0.1.5+20150326" +version = "0.1.6+20150326" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with pubsub (protocol v1beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/pubsub1_beta2" diff --git a/gen/pubsub1_beta2/README.md b/gen/pubsub1_beta2/README.md index 8c753fa0ae..ac8a7a54f9 100644 --- a/gen/pubsub1_beta2/README.md +++ b/gen/pubsub1_beta2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-pubsub1_beta2` library allows access to all features of the *Google pubsub* service. -This documentation was generated from *pubsub* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *pubsub:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *pubsub* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *pubsub:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. # Features Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_pubsub1_beta2/struct.Pubsub.html) ... @@ -99,21 +99,22 @@ let mut req = AcknowledgeRequest::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.projects().subscriptions_acknowledge(&req, "subscription") +let result = hub.projects().subscriptions_acknowledge(req, "subscription") .doit(); match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/pubsub1_beta2/src/cmn.rs b/gen/pubsub1_beta2/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/pubsub1_beta2/src/cmn.rs +++ b/gen/pubsub1_beta2/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/pubsub1_beta2/src/lib.rs b/gen/pubsub1_beta2/src/lib.rs index 702900bc48..1a1d79e2f4 100644 --- a/gen/pubsub1_beta2/src/lib.rs +++ b/gen/pubsub1_beta2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *pubsub* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *pubsub:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *pubsub* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *pubsub:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/pubsub1_beta2). //! # Features //! @@ -100,21 +100,22 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.projects().subscriptions_acknowledge(&req, "subscription") +//! let result = hub.projects().subscriptions_acknowledge(req, "subscription") //! .doit(); //! //! match result { //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -202,7 +203,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -279,21 +280,22 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.projects().subscriptions_acknowledge(&req, "subscription") +/// let result = hub.projects().subscriptions_acknowledge(req, "subscription") /// .doit(); /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -314,7 +316,7 @@ impl<'a, C, A> Pubsub<C, A> Pubsub { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -323,7 +325,7 @@ impl<'a, C, A> Pubsub<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -725,10 +727,10 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `subscription` - No description provided. - pub fn subscriptions_pull(&self, request: &PullRequest, subscription: &str) -> ProjectSubscriptionPullCall<'a, C, A> { + pub fn subscriptions_pull(&self, request: PullRequest, subscription: &str) -> ProjectSubscriptionPullCall<'a, C, A> { ProjectSubscriptionPullCall { hub: self.hub, - _request: request.clone(), + _request: request, _subscription: subscription.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -744,10 +746,10 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `name` - No description provided. - pub fn topics_create(&self, request: &Topic, name: &str) -> ProjectTopicCreateCall<'a, C, A> { + pub fn topics_create(&self, request: Topic, name: &str) -> ProjectTopicCreateCall<'a, C, A> { ProjectTopicCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _name: name.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -780,10 +782,10 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `subscription` - No description provided. - pub fn subscriptions_modify_push_config(&self, request: &ModifyPushConfigRequest, subscription: &str) -> ProjectSubscriptionModifyPushConfigCall<'a, C, A> { + pub fn subscriptions_modify_push_config(&self, request: ModifyPushConfigRequest, subscription: &str) -> ProjectSubscriptionModifyPushConfigCall<'a, C, A> { ProjectSubscriptionModifyPushConfigCall { hub: self.hub, - _request: request.clone(), + _request: request, _subscription: subscription.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -799,10 +801,10 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `topic` - No description provided. - pub fn topics_publish(&self, request: &PublishRequest, topic: &str) -> ProjectTopicPublishCall<'a, C, A> { + pub fn topics_publish(&self, request: PublishRequest, topic: &str) -> ProjectTopicPublishCall<'a, C, A> { ProjectTopicPublishCall { hub: self.hub, - _request: request.clone(), + _request: request, _topic: topic.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -835,10 +837,10 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `subscription` - No description provided. - pub fn subscriptions_modify_ack_deadline(&self, request: &ModifyAckDeadlineRequest, subscription: &str) -> ProjectSubscriptionModifyAckDeadlineCall<'a, C, A> { + pub fn subscriptions_modify_ack_deadline(&self, request: ModifyAckDeadlineRequest, subscription: &str) -> ProjectSubscriptionModifyAckDeadlineCall<'a, C, A> { ProjectSubscriptionModifyAckDeadlineCall { hub: self.hub, - _request: request.clone(), + _request: request, _subscription: subscription.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -854,10 +856,10 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `subscription` - No description provided. - pub fn subscriptions_acknowledge(&self, request: &AcknowledgeRequest, subscription: &str) -> ProjectSubscriptionAcknowledgeCall<'a, C, A> { + pub fn subscriptions_acknowledge(&self, request: AcknowledgeRequest, subscription: &str) -> ProjectSubscriptionAcknowledgeCall<'a, C, A> { ProjectSubscriptionAcknowledgeCall { hub: self.hub, - _request: request.clone(), + _request: request, _subscription: subscription.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -890,10 +892,10 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `name` - No description provided. - pub fn subscriptions_create(&self, request: &Subscription, name: &str) -> ProjectSubscriptionCreateCall<'a, C, A> { + pub fn subscriptions_create(&self, request: Subscription, name: &str) -> ProjectSubscriptionCreateCall<'a, C, A> { ProjectSubscriptionCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _name: name.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1016,7 +1018,7 @@ impl<'a, C, A> ProjectTopicListCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, ListTopicsResponse)> { - use url::{percent_encode, FORM_URLENCODED_ENCODE_SET}; + use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -1124,12 +1126,17 @@ impl<'a, C, A> ProjectTopicListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1138,7 +1145,7 @@ impl<'a, C, A> ProjectTopicListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1256,7 +1263,7 @@ impl<'a, C, A> ProjectTopicListCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.projects().subscriptions_pull(&req, "subscription") +/// let result = hub.projects().subscriptions_pull(req, "subscription") /// .doit(); /// # } /// ``` @@ -1278,7 +1285,7 @@ impl<'a, C, A> ProjectSubscriptionPullCall<'a, C, A> where C: BorrowMut<hyper::C /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, PullResponse)> { - use url::{percent_encode, FORM_URLENCODED_ENCODE_SET}; + use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -1388,12 +1395,17 @@ impl<'a, C, A> ProjectSubscriptionPullCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1402,7 +1414,7 @@ impl<'a, C, A> ProjectSubscriptionPullCall<'a, C, A> where C: BorrowMut<hyper::C Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1420,8 +1432,8 @@ impl<'a, C, A> ProjectSubscriptionPullCall<'a, C, A> where C: BorrowMut<hyper::C /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PullRequest) -> ProjectSubscriptionPullCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PullRequest) -> ProjectSubscriptionPullCall<'a, C, A> { + self._request = new_value; self } /// @@ -1517,7 +1529,7 @@ impl<'a, C, A> ProjectSubscriptionPullCall<'a, C, A> where C: BorrowMut<hyper::C /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.projects().topics_create(&req, "name") +/// let result = hub.projects().topics_create(req, "name") /// .doit(); /// # } /// ``` @@ -1539,7 +1551,7 @@ impl<'a, C, A> ProjectTopicCreateCall<'a, C, A> where C: BorrowMut<hyper::Client /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, Topic)> { - use url::{percent_encode, FORM_URLENCODED_ENCODE_SET}; + use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -1649,12 +1661,17 @@ impl<'a, C, A> ProjectTopicCreateCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1663,7 +1680,7 @@ impl<'a, C, A> ProjectTopicCreateCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1681,8 +1698,8 @@ impl<'a, C, A> ProjectTopicCreateCall<'a, C, A> where C: BorrowMut<hyper::Client /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Topic) -> ProjectTopicCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Topic) -> ProjectTopicCreateCall<'a, C, A> { + self._request = new_value; self } /// @@ -1793,7 +1810,7 @@ impl<'a, C, A> ProjectTopicDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, Empty)> { - use url::{percent_encode, FORM_URLENCODED_ENCODE_SET}; + use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -1895,12 +1912,17 @@ impl<'a, C, A> ProjectTopicDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1909,7 +1931,7 @@ impl<'a, C, A> ProjectTopicDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2015,7 +2037,7 @@ impl<'a, C, A> ProjectTopicDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.projects().subscriptions_modify_push_config(&req, "subscription") +/// let result = hub.projects().subscriptions_modify_push_config(req, "subscription") /// .doit(); /// # } /// ``` @@ -2037,7 +2059,7 @@ impl<'a, C, A> ProjectSubscriptionModifyPushConfigCall<'a, C, A> where C: Borrow /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, Empty)> { - use url::{percent_encode, FORM_URLENCODED_ENCODE_SET}; + use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -2147,12 +2169,17 @@ impl<'a, C, A> ProjectSubscriptionModifyPushConfigCall<'a, C, A> where C: Borrow if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2161,7 +2188,7 @@ impl<'a, C, A> ProjectSubscriptionModifyPushConfigCall<'a, C, A> where C: Borrow Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2179,8 +2206,8 @@ impl<'a, C, A> ProjectSubscriptionModifyPushConfigCall<'a, C, A> where C: Borrow /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ModifyPushConfigRequest) -> ProjectSubscriptionModifyPushConfigCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ModifyPushConfigRequest) -> ProjectSubscriptionModifyPushConfigCall<'a, C, A> { + self._request = new_value; self } /// @@ -2276,7 +2303,7 @@ impl<'a, C, A> ProjectSubscriptionModifyPushConfigCall<'a, C, A> where C: Borrow /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.projects().topics_publish(&req, "topic") +/// let result = hub.projects().topics_publish(req, "topic") /// .doit(); /// # } /// ``` @@ -2298,7 +2325,7 @@ impl<'a, C, A> ProjectTopicPublishCall<'a, C, A> where C: BorrowMut<hyper::Clien /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, PublishResponse)> { - use url::{percent_encode, FORM_URLENCODED_ENCODE_SET}; + use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -2408,12 +2435,17 @@ impl<'a, C, A> ProjectTopicPublishCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2422,7 +2454,7 @@ impl<'a, C, A> ProjectTopicPublishCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2440,8 +2472,8 @@ impl<'a, C, A> ProjectTopicPublishCall<'a, C, A> where C: BorrowMut<hyper::Clien /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PublishRequest) -> ProjectTopicPublishCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PublishRequest) -> ProjectTopicPublishCall<'a, C, A> { + self._request = new_value; self } /// @@ -2552,7 +2584,7 @@ impl<'a, C, A> ProjectTopicGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, Topic)> { - use url::{percent_encode, FORM_URLENCODED_ENCODE_SET}; + use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -2654,12 +2686,17 @@ impl<'a, C, A> ProjectTopicGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2668,7 +2705,7 @@ impl<'a, C, A> ProjectTopicGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2774,7 +2811,7 @@ impl<'a, C, A> ProjectTopicGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.projects().subscriptions_modify_ack_deadline(&req, "subscription") +/// let result = hub.projects().subscriptions_modify_ack_deadline(req, "subscription") /// .doit(); /// # } /// ``` @@ -2796,7 +2833,7 @@ impl<'a, C, A> ProjectSubscriptionModifyAckDeadlineCall<'a, C, A> where C: Borro /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, Empty)> { - use url::{percent_encode, FORM_URLENCODED_ENCODE_SET}; + use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -2906,12 +2943,17 @@ impl<'a, C, A> ProjectSubscriptionModifyAckDeadlineCall<'a, C, A> where C: Borro if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2920,7 +2962,7 @@ impl<'a, C, A> ProjectSubscriptionModifyAckDeadlineCall<'a, C, A> where C: Borro Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2938,8 +2980,8 @@ impl<'a, C, A> ProjectSubscriptionModifyAckDeadlineCall<'a, C, A> where C: Borro /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ModifyAckDeadlineRequest) -> ProjectSubscriptionModifyAckDeadlineCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ModifyAckDeadlineRequest) -> ProjectSubscriptionModifyAckDeadlineCall<'a, C, A> { + self._request = new_value; self } /// @@ -3035,7 +3077,7 @@ impl<'a, C, A> ProjectSubscriptionModifyAckDeadlineCall<'a, C, A> where C: Borro /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.projects().subscriptions_acknowledge(&req, "subscription") +/// let result = hub.projects().subscriptions_acknowledge(req, "subscription") /// .doit(); /// # } /// ``` @@ -3057,7 +3099,7 @@ impl<'a, C, A> ProjectSubscriptionAcknowledgeCall<'a, C, A> where C: BorrowMut<h /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, Empty)> { - use url::{percent_encode, FORM_URLENCODED_ENCODE_SET}; + use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -3167,12 +3209,17 @@ impl<'a, C, A> ProjectSubscriptionAcknowledgeCall<'a, C, A> where C: BorrowMut<h if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3181,7 +3228,7 @@ impl<'a, C, A> ProjectSubscriptionAcknowledgeCall<'a, C, A> where C: BorrowMut<h Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3199,8 +3246,8 @@ impl<'a, C, A> ProjectSubscriptionAcknowledgeCall<'a, C, A> where C: BorrowMut<h /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &AcknowledgeRequest) -> ProjectSubscriptionAcknowledgeCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: AcknowledgeRequest) -> ProjectSubscriptionAcknowledgeCall<'a, C, A> { + self._request = new_value; self } /// @@ -3311,7 +3358,7 @@ impl<'a, C, A> ProjectSubscriptionDeleteCall<'a, C, A> where C: BorrowMut<hyper: /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, Empty)> { - use url::{percent_encode, FORM_URLENCODED_ENCODE_SET}; + use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -3413,12 +3460,17 @@ impl<'a, C, A> ProjectSubscriptionDeleteCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3427,7 +3479,7 @@ impl<'a, C, A> ProjectSubscriptionDeleteCall<'a, C, A> where C: BorrowMut<hyper: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3533,7 +3585,7 @@ impl<'a, C, A> ProjectSubscriptionDeleteCall<'a, C, A> where C: BorrowMut<hyper: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.projects().subscriptions_create(&req, "name") +/// let result = hub.projects().subscriptions_create(req, "name") /// .doit(); /// # } /// ``` @@ -3555,7 +3607,7 @@ impl<'a, C, A> ProjectSubscriptionCreateCall<'a, C, A> where C: BorrowMut<hyper: /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, Subscription)> { - use url::{percent_encode, FORM_URLENCODED_ENCODE_SET}; + use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -3665,12 +3717,17 @@ impl<'a, C, A> ProjectSubscriptionCreateCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3679,7 +3736,7 @@ impl<'a, C, A> ProjectSubscriptionCreateCall<'a, C, A> where C: BorrowMut<hyper: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3697,8 +3754,8 @@ impl<'a, C, A> ProjectSubscriptionCreateCall<'a, C, A> where C: BorrowMut<hyper: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Subscription) -> ProjectSubscriptionCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Subscription) -> ProjectSubscriptionCreateCall<'a, C, A> { + self._request = new_value; self } /// @@ -3809,7 +3866,7 @@ impl<'a, C, A> ProjectSubscriptionGetCall<'a, C, A> where C: BorrowMut<hyper::Cl /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, Subscription)> { - use url::{percent_encode, FORM_URLENCODED_ENCODE_SET}; + use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -3911,12 +3968,17 @@ impl<'a, C, A> ProjectSubscriptionGetCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3925,7 +3987,7 @@ impl<'a, C, A> ProjectSubscriptionGetCall<'a, C, A> where C: BorrowMut<hyper::Cl Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4050,7 +4112,7 @@ impl<'a, C, A> ProjectTopicSubscriptionListCall<'a, C, A> where C: BorrowMut<hyp /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, ListTopicSubscriptionsResponse)> { - use url::{percent_encode, FORM_URLENCODED_ENCODE_SET}; + use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -4158,12 +4220,17 @@ impl<'a, C, A> ProjectTopicSubscriptionListCall<'a, C, A> where C: BorrowMut<hyp if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4172,7 +4239,7 @@ impl<'a, C, A> ProjectTopicSubscriptionListCall<'a, C, A> where C: BorrowMut<hyp Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4309,7 +4376,7 @@ impl<'a, C, A> ProjectSubscriptionListCall<'a, C, A> where C: BorrowMut<hyper::C /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, ListSubscriptionsResponse)> { - use url::{percent_encode, FORM_URLENCODED_ENCODE_SET}; + use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -4417,12 +4484,17 @@ impl<'a, C, A> ProjectSubscriptionListCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4431,7 +4503,7 @@ impl<'a, C, A> ProjectSubscriptionListCall<'a, C, A> where C: BorrowMut<hyper::C Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/qpxexpress1-cli/Cargo.toml b/gen/qpxexpress1-cli/Cargo.toml index 7512ba8d5e..d6b4a73bed 100644 --- a/gen/qpxexpress1-cli/Cargo.toml +++ b/gen/qpxexpress1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-qpxexpress1-cli" -version = "0.0.1+20140321" +version = "0.1.0+20140321" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with QPX Express (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/qpxexpress1-cli" diff --git a/gen/qpxexpress1-cli/README.md b/gen/qpxexpress1-cli/README.md index 698d1daecd..87ca65ea9d 100644 --- a/gen/qpxexpress1-cli/README.md +++ b/gen/qpxexpress1-cli/README.md @@ -1,4 +1,98 @@ -# HELLO QPXEXPRESS:V1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `qpxexpress1` command-line interface *(CLI)* allows to use most features of the *Google QPX Express* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *QPX Express* API at revision *20140321*. The CLI is at version *0.1.0*. + +```bash + qpxexpress1 [options] trips search -r <kv>... [-p <v>...] [-o <out>] + qpxexpress1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_qpxexpress1_cli/index.html + +Configuration: + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `qpxexpress1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/qpxexpress1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/qpxexpress1-secret.json`, assuming that the required *qpxExpress* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `qpxexpress1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/qpxexpress1-cli/mkdocs.yml b/gen/qpxexpress1-cli/mkdocs.yml index 8b40ea9235..a141bef20b 100644 --- a/gen/qpxexpress1-cli/mkdocs.yml +++ b/gen/qpxexpress1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: QPX Express v0.0.1+20140321 +site_name: QPX Express v0.1.0+20140321 site_url: http://byron.github.io/google-apis-rs/google-qpxexpress1-cli site_description: Write integrating applications with bcore diff --git a/gen/qpxexpress1-cli/src/cmn.rs b/gen/qpxexpress1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/qpxexpress1-cli/src/cmn.rs +++ b/gen/qpxexpress1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/qpxexpress1-cli/src/main.rs b/gen/qpxexpress1-cli/src/main.rs index e54488b401..ec10a38698 100644 --- a/gen/qpxexpress1-cli/src/main.rs +++ b/gen/qpxexpress1-cli/src/main.rs @@ -19,22 +19,23 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - qpxexpress1 [options] trips search -r <kv>... [-p <v>]... [-o <out>] + qpxexpress1 [options] trips search -r <kv>... [-p <v>...] [-o <out>] qpxexpress1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_qpxexpress1_cli/index.html Configuration: --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -56,36 +57,23 @@ struct Engine { impl Engine { fn _trips_search(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::TripsSearchRequest::default(); - let mut call = self.hub.trips().search(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::TripsSearchRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_request_init(request: &mut api::TripsSearchRequest) { if request.request.is_none() { request.request = Some(Default::default()); @@ -99,7 +87,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "request.refundable" => { request_request_init(&mut request); request.request.as_mut().unwrap().refundable = Some(arg_from_str(value.unwrap_or("false"), err, "request.refundable", "boolean")); @@ -141,10 +129,32 @@ impl Engine { request.request.as_mut().unwrap().max_price = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.trips().search(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None @@ -243,6 +253,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -250,8 +261,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/qpxexpress1/Cargo.toml b/gen/qpxexpress1/Cargo.toml index 01246af09b..ff177f53ea 100644 --- a/gen/qpxexpress1/Cargo.toml +++ b/gen/qpxexpress1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-qpxexpress1" -version = "0.1.5+20140321" +version = "0.1.6+20140321" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with QPX Express (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/qpxexpress1" diff --git a/gen/qpxexpress1/README.md b/gen/qpxexpress1/README.md index d47cf9981f..317e67cf76 100644 --- a/gen/qpxexpress1/README.md +++ b/gen/qpxexpress1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-qpxexpress1` library allows access to all features of the *Google QPX Express* service. -This documentation was generated from *QPX Express* crate version *0.1.5+20140321*, where *20140321* is the exact revision of the *qpxExpress:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *QPX Express* crate version *0.1.6+20140321*, where *20140321* is the exact revision of the *qpxExpress:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *QPX Express* *v1* API can be found at the [official documentation site](http://developers.google.com/qpx-express). @@ -98,21 +98,22 @@ let mut req = TripsSearchRequest::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.trips().search(&req) +let result = hub.trips().search(req) .doit(); match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/qpxexpress1/src/cmn.rs b/gen/qpxexpress1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/qpxexpress1/src/cmn.rs +++ b/gen/qpxexpress1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/qpxexpress1/src/lib.rs b/gen/qpxexpress1/src/lib.rs index 54f12b5e0e..0904a6e8b1 100644 --- a/gen/qpxexpress1/src/lib.rs +++ b/gen/qpxexpress1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *QPX Express* crate version *0.1.5+20140321*, where *20140321* is the exact revision of the *qpxExpress:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *QPX Express* crate version *0.1.6+20140321*, where *20140321* is the exact revision of the *qpxExpress:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *QPX Express* *v1* API can be found at the //! [official documentation site](http://developers.google.com/qpx-express). @@ -99,21 +99,22 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.trips().search(&req) +//! let result = hub.trips().search(req) //! .doit(); //! //! match result { //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -201,7 +202,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -252,21 +253,22 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.trips().search(&req) +/// let result = hub.trips().search(req) /// .doit(); /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -287,7 +289,7 @@ impl<'a, C, A> QPXExpress<C, A> QPXExpress { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -296,7 +298,7 @@ impl<'a, C, A> QPXExpress<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -953,10 +955,10 @@ impl<'a, C, A> TripMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn search(&self, request: &TripsSearchRequest) -> TripSearchCall<'a, C, A> { + pub fn search(&self, request: TripsSearchRequest) -> TripSearchCall<'a, C, A> { TripSearchCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _additional_params: Default::default(), } @@ -1003,7 +1005,7 @@ impl<'a, C, A> TripMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.trips().search(&req) +/// let result = hub.trips().search(req) /// .doit(); /// # } /// ``` @@ -1098,12 +1100,17 @@ impl<'a, C, A> TripSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1112,7 +1119,7 @@ impl<'a, C, A> TripSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1130,8 +1137,8 @@ impl<'a, C, A> TripSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &TripsSearchRequest) -> TripSearchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: TripsSearchRequest) -> TripSearchCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong diff --git a/gen/replicapool1_beta2-cli/Cargo.toml b/gen/replicapool1_beta2-cli/Cargo.toml index 817ea2e25c..f15a17f723 100644 --- a/gen/replicapool1_beta2-cli/Cargo.toml +++ b/gen/replicapool1_beta2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-replicapool1_beta2-cli" -version = "0.0.1+20150223" +version = "0.1.0+20150223" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with replicapool (protocol v1beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/replicapool1_beta2-cli" diff --git a/gen/replicapool1_beta2-cli/README.md b/gen/replicapool1_beta2-cli/README.md index 9030acbc39..d71c1d398e 100644 --- a/gen/replicapool1_beta2-cli/README.md +++ b/gen/replicapool1_beta2-cli/README.md @@ -1,4 +1,113 @@ -# HELLO REPLICAPOOL:V1BETA2 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `replicapool1-beta2` command-line interface *(CLI)* allows to use most features of the *Google replicapool* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *replicapool* API at revision *20150223*. The CLI is at version *0.1.0*. + +```bash + replicapool1-beta2 [options] instance-group-managers abandon-instances <project> <zone> <instance-group-manager> -r <kv>... [-p <v>...] [-o <out>] + replicapool1-beta2 [options] instance-group-managers delete <project> <zone> <instance-group-manager> [-p <v>...] [-o <out>] + replicapool1-beta2 [options] instance-group-managers delete-instances <project> <zone> <instance-group-manager> -r <kv>... [-p <v>...] [-o <out>] + replicapool1-beta2 [options] instance-group-managers get <project> <zone> <instance-group-manager> [-p <v>...] [-o <out>] + replicapool1-beta2 [options] instance-group-managers insert <project> <zone> <size> -r <kv>... [-p <v>...] [-o <out>] + replicapool1-beta2 [options] instance-group-managers list <project> <zone> [-p <v>...] [-o <out>] + replicapool1-beta2 [options] instance-group-managers recreate-instances <project> <zone> <instance-group-manager> -r <kv>... [-p <v>...] [-o <out>] + replicapool1-beta2 [options] instance-group-managers resize <project> <zone> <instance-group-manager> <size> [-p <v>...] [-o <out>] + replicapool1-beta2 [options] instance-group-managers set-instance-template <project> <zone> <instance-group-manager> -r <kv>... [-p <v>...] [-o <out>] + replicapool1-beta2 [options] instance-group-managers set-target-pools <project> <zone> <instance-group-manager> -r <kv>... [-p <v>...] [-o <out>] + replicapool1-beta2 [options] zone-operations get <project> <zone> <operation> [-p <v>...] [-o <out>] + replicapool1-beta2 [options] zone-operations list <project> <zone> [-p <v>...] [-o <out>] + replicapool1-beta2 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_replicapool1_beta2_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `replicapool1-beta2-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/replicapool1-beta2-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/replicapool1-beta2-secret.json`, assuming that the required *replicapool* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `replicapool1-beta2 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/replicapool1_beta2-cli/mkdocs.yml b/gen/replicapool1_beta2-cli/mkdocs.yml index 63d8c2642b..f8c0f3dad2 100644 --- a/gen/replicapool1_beta2-cli/mkdocs.yml +++ b/gen/replicapool1_beta2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: replicapool v0.0.1+20150223 +site_name: replicapool v0.1.0+20150223 site_url: http://byron.github.io/google-apis-rs/google-replicapool1_beta2-cli site_description: Write integrating applications with bcore diff --git a/gen/replicapool1_beta2-cli/src/cmn.rs b/gen/replicapool1_beta2-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/replicapool1_beta2-cli/src/cmn.rs +++ b/gen/replicapool1_beta2-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/replicapool1_beta2-cli/src/main.rs b/gen/replicapool1_beta2-cli/src/main.rs index f637db53d0..37d9ed480b 100644 --- a/gen/replicapool1_beta2-cli/src/main.rs +++ b/gen/replicapool1_beta2-cli/src/main.rs @@ -19,37 +19,38 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - replicapool1-beta2 [options] instance-group-managers abandon-instances <project> <zone> <instance-group-manager> -r <kv>... [-p <v>]... [-o <out>] - replicapool1-beta2 [options] instance-group-managers delete <project> <zone> <instance-group-manager> [-p <v>]... [-o <out>] - replicapool1-beta2 [options] instance-group-managers delete-instances <project> <zone> <instance-group-manager> -r <kv>... [-p <v>]... [-o <out>] - replicapool1-beta2 [options] instance-group-managers get <project> <zone> <instance-group-manager> [-p <v>]... [-o <out>] - replicapool1-beta2 [options] instance-group-managers insert <project> <zone> <size> -r <kv>... [-p <v>]... [-o <out>] - replicapool1-beta2 [options] instance-group-managers list <project> <zone> [-p <v>]... [-o <out>] - replicapool1-beta2 [options] instance-group-managers recreate-instances <project> <zone> <instance-group-manager> -r <kv>... [-p <v>]... [-o <out>] - replicapool1-beta2 [options] instance-group-managers resize <project> <zone> <instance-group-manager> <size> [-p <v>]... [-o <out>] - replicapool1-beta2 [options] instance-group-managers set-instance-template <project> <zone> <instance-group-manager> -r <kv>... [-p <v>]... [-o <out>] - replicapool1-beta2 [options] instance-group-managers set-target-pools <project> <zone> <instance-group-manager> -r <kv>... [-p <v>]... [-o <out>] - replicapool1-beta2 [options] zone-operations get <project> <zone> <operation> [-p <v>]... [-o <out>] - replicapool1-beta2 [options] zone-operations list <project> <zone> [-p <v>]... [-o <out>] + replicapool1-beta2 [options] instance-group-managers abandon-instances <project> <zone> <instance-group-manager> -r <kv>... [-p <v>...] [-o <out>] + replicapool1-beta2 [options] instance-group-managers delete <project> <zone> <instance-group-manager> [-p <v>...] [-o <out>] + replicapool1-beta2 [options] instance-group-managers delete-instances <project> <zone> <instance-group-manager> -r <kv>... [-p <v>...] [-o <out>] + replicapool1-beta2 [options] instance-group-managers get <project> <zone> <instance-group-manager> [-p <v>...] [-o <out>] + replicapool1-beta2 [options] instance-group-managers insert <project> <zone> <size> -r <kv>... [-p <v>...] [-o <out>] + replicapool1-beta2 [options] instance-group-managers list <project> <zone> [-p <v>...] [-o <out>] + replicapool1-beta2 [options] instance-group-managers recreate-instances <project> <zone> <instance-group-manager> -r <kv>... [-p <v>...] [-o <out>] + replicapool1-beta2 [options] instance-group-managers resize <project> <zone> <instance-group-manager> <size> [-p <v>...] [-o <out>] + replicapool1-beta2 [options] instance-group-managers set-instance-template <project> <zone> <instance-group-manager> -r <kv>... [-p <v>...] [-o <out>] + replicapool1-beta2 [options] instance-group-managers set-target-pools <project> <zone> <instance-group-manager> -r <kv>... [-p <v>...] [-o <out>] + replicapool1-beta2 [options] zone-operations get <project> <zone> <operation> [-p <v>...] [-o <out>] + replicapool1-beta2 [options] zone-operations list <project> <zone> [-p <v>...] [-o <out>] replicapool1-beta2 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_replicapool1_beta2_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -71,8 +72,36 @@ struct Engine { impl Engine { fn _instance_group_managers_abandon_instances(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::InstanceGroupManagersAbandonInstancesRequest::default(); - let mut call = self.hub.instance_group_managers().abandon_instances(&request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_instance_group_manager); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "instances" => { + if request.instances.is_none() { + request.instances = Some(Default::default()); + } + request.instances.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.instance_group_managers().abandon_instances(request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_instance_group_manager); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -94,30 +123,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "instances" => { - if request.instances.is_none() { - request.instances = Some(Default::default()); - } - request.instances.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -161,6 +174,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -177,8 +193,36 @@ impl Engine { fn _instance_group_managers_delete_instances(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::InstanceGroupManagersDeleteInstancesRequest::default(); - let mut call = self.hub.instance_group_managers().delete_instances(&request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_instance_group_manager); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "instances" => { + if request.instances.is_none() { + request.instances = Some(Default::default()); + } + request.instances.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.instance_group_managers().delete_instances(request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_instance_group_manager); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -200,30 +244,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "instances" => { - if request.instances.is_none() { - request.instances = Some(Default::default()); - } - request.instances.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -267,6 +295,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -283,38 +314,24 @@ impl Engine { fn _instance_group_managers_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::InstanceGroupManager::default(); - let size: i32 = arg_from_str(&self.opt.arg_size, err, "<size>", "integer"); - let mut call = self.hub.instance_group_managers().insert(&request, &self.opt.arg_project, &self.opt.arg_zone, size); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::InstanceGroupManager::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "target-size" => { request.target_size = Some(arg_from_str(value.unwrap_or("-0"), err, "target-size", "integer")); }, @@ -358,15 +375,41 @@ impl Engine { request.current_size = Some(arg_from_str(value.unwrap_or("-0"), err, "current-size", "integer")); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let size: i32 = arg_from_str(&self.opt.arg_size, err, "<size>", "integer"); + let mut call = self.hub.instance_group_managers().insert(request, &self.opt.arg_project, &self.opt.arg_zone, size); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -419,6 +462,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -435,8 +481,36 @@ impl Engine { fn _instance_group_managers_recreate_instances(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::InstanceGroupManagersRecreateInstancesRequest::default(); - let mut call = self.hub.instance_group_managers().recreate_instances(&request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_instance_group_manager); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "instances" => { + if request.instances.is_none() { + request.instances = Some(Default::default()); + } + request.instances.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.instance_group_managers().recreate_instances(request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_instance_group_manager); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -458,30 +532,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "instances" => { - if request.instances.is_none() { - request.instances = Some(Default::default()); - } - request.instances.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -526,6 +584,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -542,8 +603,33 @@ impl Engine { fn _instance_group_managers_set_instance_template(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::InstanceGroupManagersSetInstanceTemplateRequest::default(); - let mut call = self.hub.instance_group_managers().set_instance_template(&request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_instance_group_manager); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "instance-template" => { + request.instance_template = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.instance_group_managers().set_instance_template(request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_instance_group_manager); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -565,27 +651,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "instance-template" => { - request.instance_template = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -602,8 +675,39 @@ impl Engine { fn _instance_group_managers_set_target_pools(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::InstanceGroupManagersSetTargetPoolsRequest::default(); - let mut call = self.hub.instance_group_managers().set_target_pools(&request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_instance_group_manager); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "target-pools" => { + if request.target_pools.is_none() { + request.target_pools = Some(Default::default()); + } + request.target_pools.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "fingerprint" => { + request.fingerprint = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.instance_group_managers().set_target_pools(request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_instance_group_manager); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -625,33 +729,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "target-pools" => { - if request.target_pools.is_none() { - request.target_pools = Some(Default::default()); - } - request.target_pools.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "fingerprint" => { - request.fingerprint = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -695,6 +780,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -747,6 +835,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -867,6 +958,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -874,8 +966,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/replicapool1_beta2/Cargo.toml b/gen/replicapool1_beta2/Cargo.toml index 2e42468337..5307400ad8 100644 --- a/gen/replicapool1_beta2/Cargo.toml +++ b/gen/replicapool1_beta2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-replicapool1_beta2" -version = "0.1.5+20150223" +version = "0.1.6+20150223" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with replicapool (protocol v1beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/replicapool1_beta2" diff --git a/gen/replicapool1_beta2/README.md b/gen/replicapool1_beta2/README.md index e89ef2d51f..58d97dd083 100644 --- a/gen/replicapool1_beta2/README.md +++ b/gen/replicapool1_beta2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-replicapool1_beta2` library allows access to all features of the *Google replicapool* service. -This documentation was generated from *replicapool* crate version *0.1.5+20150223*, where *20150223* is the exact revision of the *replicapool:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *replicapool* crate version *0.1.6+20150223*, where *20150223* is the exact revision of the *replicapool:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *replicapool* *v1_beta2* API can be found at the [official documentation site](https://developers.google.com/compute/docs/instance-groups/manager/v1beta2). @@ -113,14 +113,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/replicapool1_beta2/src/cmn.rs b/gen/replicapool1_beta2/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/replicapool1_beta2/src/cmn.rs +++ b/gen/replicapool1_beta2/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/replicapool1_beta2/src/lib.rs b/gen/replicapool1_beta2/src/lib.rs index bc27b757a7..a255912332 100644 --- a/gen/replicapool1_beta2/src/lib.rs +++ b/gen/replicapool1_beta2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *replicapool* crate version *0.1.5+20150223*, where *20150223* is the exact revision of the *replicapool:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *replicapool* crate version *0.1.6+20150223*, where *20150223* is the exact revision of the *replicapool:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *replicapool* *v1_beta2* API can be found at the //! [official documentation site](https://developers.google.com/compute/docs/instance-groups/manager/v1beta2). @@ -114,14 +114,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -209,7 +210,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -294,14 +295,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -322,7 +324,7 @@ impl<'a, C, A> Replicapool<C, A> Replicapool { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -334,7 +336,7 @@ impl<'a, C, A> Replicapool<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -845,10 +847,10 @@ impl<'a, C, A> InstanceGroupManagerMethods<'a, C, A> { /// * `project` - The Google Developers Console project name. /// * `zone` - The name of the zone in which the instance group manager resides. /// * `instanceGroupManager` - The name of the instance group manager. - pub fn set_target_pools(&self, request: &InstanceGroupManagersSetTargetPoolsRequest, project: &str, zone: &str, instance_group_manager: &str) -> InstanceGroupManagerSetTargetPoolCall<'a, C, A> { + pub fn set_target_pools(&self, request: InstanceGroupManagersSetTargetPoolsRequest, project: &str, zone: &str, instance_group_manager: &str) -> InstanceGroupManagerSetTargetPoolCall<'a, C, A> { InstanceGroupManagerSetTargetPoolCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _zone: zone.to_string(), _instance_group_manager: instance_group_manager.to_string(), @@ -890,10 +892,10 @@ impl<'a, C, A> InstanceGroupManagerMethods<'a, C, A> { /// * `project` - The Google Developers Console project name. /// * `zone` - The name of the zone in which the instance group manager resides. /// * `size` - Number of instances that should exist. - pub fn insert(&self, request: &InstanceGroupManager, project: &str, zone: &str, size: i32) -> InstanceGroupManagerInsertCall<'a, C, A> { + pub fn insert(&self, request: InstanceGroupManager, project: &str, zone: &str, size: i32) -> InstanceGroupManagerInsertCall<'a, C, A> { InstanceGroupManagerInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _zone: zone.to_string(), _size: size, @@ -934,10 +936,10 @@ impl<'a, C, A> InstanceGroupManagerMethods<'a, C, A> { /// * `project` - The Google Developers Console project name. /// * `zone` - The name of the zone in which the instance group manager resides. /// * `instanceGroupManager` - The name of the instance group manager. - pub fn abandon_instances(&self, request: &InstanceGroupManagersAbandonInstancesRequest, project: &str, zone: &str, instance_group_manager: &str) -> InstanceGroupManagerAbandonInstanceCall<'a, C, A> { + pub fn abandon_instances(&self, request: InstanceGroupManagersAbandonInstancesRequest, project: &str, zone: &str, instance_group_manager: &str) -> InstanceGroupManagerAbandonInstanceCall<'a, C, A> { InstanceGroupManagerAbandonInstanceCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _zone: zone.to_string(), _instance_group_manager: instance_group_manager.to_string(), @@ -957,10 +959,10 @@ impl<'a, C, A> InstanceGroupManagerMethods<'a, C, A> { /// * `project` - The Google Developers Console project name. /// * `zone` - The name of the zone in which the instance group manager resides. /// * `instanceGroupManager` - The name of the instance group manager. - pub fn recreate_instances(&self, request: &InstanceGroupManagersRecreateInstancesRequest, project: &str, zone: &str, instance_group_manager: &str) -> InstanceGroupManagerRecreateInstanceCall<'a, C, A> { + pub fn recreate_instances(&self, request: InstanceGroupManagersRecreateInstancesRequest, project: &str, zone: &str, instance_group_manager: &str) -> InstanceGroupManagerRecreateInstanceCall<'a, C, A> { InstanceGroupManagerRecreateInstanceCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _zone: zone.to_string(), _instance_group_manager: instance_group_manager.to_string(), @@ -1001,10 +1003,10 @@ impl<'a, C, A> InstanceGroupManagerMethods<'a, C, A> { /// * `project` - The Google Developers Console project name. /// * `zone` - The name of the zone in which the instance group manager resides. /// * `instanceGroupManager` - The name of the instance group manager. - pub fn set_instance_template(&self, request: &InstanceGroupManagersSetInstanceTemplateRequest, project: &str, zone: &str, instance_group_manager: &str) -> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> { + pub fn set_instance_template(&self, request: InstanceGroupManagersSetInstanceTemplateRequest, project: &str, zone: &str, instance_group_manager: &str) -> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> { InstanceGroupManagerSetInstanceTemplateCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _zone: zone.to_string(), _instance_group_manager: instance_group_manager.to_string(), @@ -1047,10 +1049,10 @@ impl<'a, C, A> InstanceGroupManagerMethods<'a, C, A> { /// * `project` - The Google Developers Console project name. /// * `zone` - The name of the zone in which the instance group manager resides. /// * `instanceGroupManager` - The name of the instance group manager. - pub fn delete_instances(&self, request: &InstanceGroupManagersDeleteInstancesRequest, project: &str, zone: &str, instance_group_manager: &str) -> InstanceGroupManagerDeleteInstanceCall<'a, C, A> { + pub fn delete_instances(&self, request: InstanceGroupManagersDeleteInstancesRequest, project: &str, zone: &str, instance_group_manager: &str) -> InstanceGroupManagerDeleteInstanceCall<'a, C, A> { InstanceGroupManagerDeleteInstanceCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _zone: zone.to_string(), _instance_group_manager: instance_group_manager.to_string(), @@ -1231,12 +1233,17 @@ impl<'a, C, A> ZoneOperationListCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1245,7 +1252,7 @@ impl<'a, C, A> ZoneOperationListCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1500,12 +1507,17 @@ impl<'a, C, A> ZoneOperationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1514,7 +1526,7 @@ impl<'a, C, A> ZoneOperationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1641,7 +1653,7 @@ impl<'a, C, A> ZoneOperationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.instance_group_managers().set_target_pools(&req, "project", "zone", "instanceGroupManager") +/// let result = hub.instance_group_managers().set_target_pools(req, "project", "zone", "instanceGroupManager") /// .doit(); /// # } /// ``` @@ -1773,12 +1785,17 @@ impl<'a, C, A> InstanceGroupManagerSetTargetPoolCall<'a, C, A> where C: BorrowMu if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1787,7 +1804,7 @@ impl<'a, C, A> InstanceGroupManagerSetTargetPoolCall<'a, C, A> where C: BorrowMu Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1805,8 +1822,8 @@ impl<'a, C, A> InstanceGroupManagerSetTargetPoolCall<'a, C, A> where C: BorrowMu /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &InstanceGroupManagersSetTargetPoolsRequest) -> InstanceGroupManagerSetTargetPoolCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: InstanceGroupManagersSetTargetPoolsRequest) -> InstanceGroupManagerSetTargetPoolCall<'a, C, A> { + self._request = new_value; self } /// The Google Developers Console project name. @@ -2053,12 +2070,17 @@ impl<'a, C, A> InstanceGroupManagerListCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2067,7 +2089,7 @@ impl<'a, C, A> InstanceGroupManagerListCall<'a, C, A> where C: BorrowMut<hyper:: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2205,7 +2227,7 @@ impl<'a, C, A> InstanceGroupManagerListCall<'a, C, A> where C: BorrowMut<hyper:: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.instance_group_managers().insert(&req, "project", "zone", -75) +/// let result = hub.instance_group_managers().insert(req, "project", "zone", -75) /// .doit(); /// # } /// ``` @@ -2337,12 +2359,17 @@ impl<'a, C, A> InstanceGroupManagerInsertCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2351,7 +2378,7 @@ impl<'a, C, A> InstanceGroupManagerInsertCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2369,8 +2396,8 @@ impl<'a, C, A> InstanceGroupManagerInsertCall<'a, C, A> where C: BorrowMut<hyper /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &InstanceGroupManager) -> InstanceGroupManagerInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: InstanceGroupManager) -> InstanceGroupManagerInsertCall<'a, C, A> { + self._request = new_value; self } /// The Google Developers Console project name. @@ -2604,12 +2631,17 @@ impl<'a, C, A> InstanceGroupManagerGetCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2618,7 +2650,7 @@ impl<'a, C, A> InstanceGroupManagerGetCall<'a, C, A> where C: BorrowMut<hyper::C Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2745,7 +2777,7 @@ impl<'a, C, A> InstanceGroupManagerGetCall<'a, C, A> where C: BorrowMut<hyper::C /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.instance_group_managers().abandon_instances(&req, "project", "zone", "instanceGroupManager") +/// let result = hub.instance_group_managers().abandon_instances(req, "project", "zone", "instanceGroupManager") /// .doit(); /// # } /// ``` @@ -2877,12 +2909,17 @@ impl<'a, C, A> InstanceGroupManagerAbandonInstanceCall<'a, C, A> where C: Borrow if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2891,7 +2928,7 @@ impl<'a, C, A> InstanceGroupManagerAbandonInstanceCall<'a, C, A> where C: Borrow Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2909,8 +2946,8 @@ impl<'a, C, A> InstanceGroupManagerAbandonInstanceCall<'a, C, A> where C: Borrow /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &InstanceGroupManagersAbandonInstancesRequest) -> InstanceGroupManagerAbandonInstanceCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: InstanceGroupManagersAbandonInstancesRequest) -> InstanceGroupManagerAbandonInstanceCall<'a, C, A> { + self._request = new_value; self } /// The Google Developers Console project name. @@ -3027,7 +3064,7 @@ impl<'a, C, A> InstanceGroupManagerAbandonInstanceCall<'a, C, A> where C: Borrow /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.instance_group_managers().recreate_instances(&req, "project", "zone", "instanceGroupManager") +/// let result = hub.instance_group_managers().recreate_instances(req, "project", "zone", "instanceGroupManager") /// .doit(); /// # } /// ``` @@ -3159,12 +3196,17 @@ impl<'a, C, A> InstanceGroupManagerRecreateInstanceCall<'a, C, A> where C: Borro if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3173,7 +3215,7 @@ impl<'a, C, A> InstanceGroupManagerRecreateInstanceCall<'a, C, A> where C: Borro Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3191,8 +3233,8 @@ impl<'a, C, A> InstanceGroupManagerRecreateInstanceCall<'a, C, A> where C: Borro /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &InstanceGroupManagersRecreateInstancesRequest) -> InstanceGroupManagerRecreateInstanceCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: InstanceGroupManagersRecreateInstancesRequest) -> InstanceGroupManagerRecreateInstanceCall<'a, C, A> { + self._request = new_value; self } /// The Google Developers Console project name. @@ -3426,12 +3468,17 @@ impl<'a, C, A> InstanceGroupManagerDeleteCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3440,7 +3487,7 @@ impl<'a, C, A> InstanceGroupManagerDeleteCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3567,7 +3614,7 @@ impl<'a, C, A> InstanceGroupManagerDeleteCall<'a, C, A> where C: BorrowMut<hyper /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.instance_group_managers().set_instance_template(&req, "project", "zone", "instanceGroupManager") +/// let result = hub.instance_group_managers().set_instance_template(req, "project", "zone", "instanceGroupManager") /// .doit(); /// # } /// ``` @@ -3699,12 +3746,17 @@ impl<'a, C, A> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> where C: Bo if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3713,7 +3765,7 @@ impl<'a, C, A> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> where C: Bo Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3731,8 +3783,8 @@ impl<'a, C, A> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> where C: Bo /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &InstanceGroupManagersSetInstanceTemplateRequest) -> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: InstanceGroupManagersSetInstanceTemplateRequest) -> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> { + self._request = new_value; self } /// The Google Developers Console project name. @@ -3968,12 +4020,17 @@ impl<'a, C, A> InstanceGroupManagerResizeCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3982,7 +4039,7 @@ impl<'a, C, A> InstanceGroupManagerResizeCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4119,7 +4176,7 @@ impl<'a, C, A> InstanceGroupManagerResizeCall<'a, C, A> where C: BorrowMut<hyper /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.instance_group_managers().delete_instances(&req, "project", "zone", "instanceGroupManager") +/// let result = hub.instance_group_managers().delete_instances(req, "project", "zone", "instanceGroupManager") /// .doit(); /// # } /// ``` @@ -4251,12 +4308,17 @@ impl<'a, C, A> InstanceGroupManagerDeleteInstanceCall<'a, C, A> where C: BorrowM if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4265,7 +4327,7 @@ impl<'a, C, A> InstanceGroupManagerDeleteInstanceCall<'a, C, A> where C: BorrowM Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4283,8 +4345,8 @@ impl<'a, C, A> InstanceGroupManagerDeleteInstanceCall<'a, C, A> where C: BorrowM /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &InstanceGroupManagersDeleteInstancesRequest) -> InstanceGroupManagerDeleteInstanceCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: InstanceGroupManagersDeleteInstancesRequest) -> InstanceGroupManagerDeleteInstanceCall<'a, C, A> { + self._request = new_value; self } /// The Google Developers Console project name. diff --git a/gen/replicapoolupdater1_beta1-cli/Cargo.toml b/gen/replicapoolupdater1_beta1-cli/Cargo.toml index 91ce5a15a8..888c60d793 100644 --- a/gen/replicapoolupdater1_beta1-cli/Cargo.toml +++ b/gen/replicapoolupdater1_beta1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-replicapoolupdater1_beta1-cli" -version = "0.0.1+20150326" +version = "0.1.0+20150326" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with replicapoolupdater (protocol v1beta1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/replicapoolupdater1_beta1-cli" diff --git a/gen/replicapoolupdater1_beta1-cli/README.md b/gen/replicapoolupdater1_beta1-cli/README.md index 30e5466b02..c662ce9df9 100644 --- a/gen/replicapoolupdater1_beta1-cli/README.md +++ b/gen/replicapoolupdater1_beta1-cli/README.md @@ -1,4 +1,110 @@ -# HELLO REPLICAPOOLUPDATER:V1BETA1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `replicapoolupdater1-beta1` command-line interface *(CLI)* allows to use most features of the *Google replicapoolupdater* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *replicapoolupdater* API at revision *20150326*. The CLI is at version *0.1.0*. + +```bash + replicapoolupdater1-beta1 [options] rolling-updates cancel <project> <zone> <rolling-update> [-p <v>...] [-o <out>] + replicapoolupdater1-beta1 [options] rolling-updates get <project> <zone> <rolling-update> [-p <v>...] [-o <out>] + replicapoolupdater1-beta1 [options] rolling-updates insert <project> <zone> -r <kv>... [-p <v>...] [-o <out>] + replicapoolupdater1-beta1 [options] rolling-updates list <project> <zone> [-p <v>...] [-o <out>] + replicapoolupdater1-beta1 [options] rolling-updates list-instance-updates <project> <zone> <rolling-update> [-p <v>...] [-o <out>] + replicapoolupdater1-beta1 [options] rolling-updates pause <project> <zone> <rolling-update> [-p <v>...] [-o <out>] + replicapoolupdater1-beta1 [options] rolling-updates resume <project> <zone> <rolling-update> [-p <v>...] [-o <out>] + replicapoolupdater1-beta1 [options] rolling-updates rollback <project> <zone> <rolling-update> [-p <v>...] [-o <out>] + replicapoolupdater1-beta1 [options] zone-operations get <project> <zone> <operation> [-p <v>...] [-o <out>] + replicapoolupdater1-beta1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_replicapoolupdater1_beta1_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `replicapoolupdater1-beta1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/replicapoolupdater1-beta1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/replicapoolupdater1-beta1-secret.json`, assuming that the required *replicapoolupdater* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `replicapoolupdater1-beta1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/replicapoolupdater1_beta1-cli/mkdocs.yml b/gen/replicapoolupdater1_beta1-cli/mkdocs.yml index 9f30932897..db8bd829ea 100644 --- a/gen/replicapoolupdater1_beta1-cli/mkdocs.yml +++ b/gen/replicapoolupdater1_beta1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: replicapoolupdater v0.0.1+20150326 +site_name: replicapoolupdater v0.1.0+20150326 site_url: http://byron.github.io/google-apis-rs/google-replicapoolupdater1_beta1-cli site_description: Write integrating applications with bcore diff --git a/gen/replicapoolupdater1_beta1-cli/src/cmn.rs b/gen/replicapoolupdater1_beta1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/replicapoolupdater1_beta1-cli/src/cmn.rs +++ b/gen/replicapoolupdater1_beta1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/replicapoolupdater1_beta1-cli/src/main.rs b/gen/replicapoolupdater1_beta1-cli/src/main.rs index a22325cb18..245cb5f644 100644 --- a/gen/replicapoolupdater1_beta1-cli/src/main.rs +++ b/gen/replicapoolupdater1_beta1-cli/src/main.rs @@ -19,34 +19,35 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - replicapoolupdater1-beta1 [options] rolling-updates cancel <project> <zone> <rolling-update> [-p <v>]... [-o <out>] - replicapoolupdater1-beta1 [options] rolling-updates get <project> <zone> <rolling-update> [-p <v>]... [-o <out>] - replicapoolupdater1-beta1 [options] rolling-updates insert <project> <zone> -r <kv>... [-p <v>]... [-o <out>] - replicapoolupdater1-beta1 [options] rolling-updates list <project> <zone> [-p <v>]... [-o <out>] - replicapoolupdater1-beta1 [options] rolling-updates list-instance-updates <project> <zone> <rolling-update> [-p <v>]... [-o <out>] - replicapoolupdater1-beta1 [options] rolling-updates pause <project> <zone> <rolling-update> [-p <v>]... [-o <out>] - replicapoolupdater1-beta1 [options] rolling-updates resume <project> <zone> <rolling-update> [-p <v>]... [-o <out>] - replicapoolupdater1-beta1 [options] rolling-updates rollback <project> <zone> <rolling-update> [-p <v>]... [-o <out>] - replicapoolupdater1-beta1 [options] zone-operations get <project> <zone> <operation> [-p <v>]... [-o <out>] + replicapoolupdater1-beta1 [options] rolling-updates cancel <project> <zone> <rolling-update> [-p <v>...] [-o <out>] + replicapoolupdater1-beta1 [options] rolling-updates get <project> <zone> <rolling-update> [-p <v>...] [-o <out>] + replicapoolupdater1-beta1 [options] rolling-updates insert <project> <zone> -r <kv>... [-p <v>...] [-o <out>] + replicapoolupdater1-beta1 [options] rolling-updates list <project> <zone> [-p <v>...] [-o <out>] + replicapoolupdater1-beta1 [options] rolling-updates list-instance-updates <project> <zone> <rolling-update> [-p <v>...] [-o <out>] + replicapoolupdater1-beta1 [options] rolling-updates pause <project> <zone> <rolling-update> [-p <v>...] [-o <out>] + replicapoolupdater1-beta1 [options] rolling-updates resume <project> <zone> <rolling-update> [-p <v>...] [-o <out>] + replicapoolupdater1-beta1 [options] rolling-updates rollback <project> <zone> <rolling-update> [-p <v>...] [-o <out>] + replicapoolupdater1-beta1 [options] zone-operations get <project> <zone> <operation> [-p <v>...] [-o <out>] replicapoolupdater1-beta1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_replicapoolupdater1_beta1_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -95,6 +96,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -138,6 +142,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -154,43 +161,30 @@ impl Engine { fn _rolling_updates_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::RollingUpdate::default(); - let mut call = self.hub.rolling_updates().insert(&request, &self.opt.arg_project, &self.opt.arg_zone); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::RollingUpdate::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_policy_init(request: &mut api::RollingUpdate) { if request.policy.is_none() { request.policy = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -255,15 +249,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.rolling_updates().insert(request, &self.opt.arg_project, &self.opt.arg_zone); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -319,6 +338,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -371,6 +393,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -414,6 +439,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -457,6 +485,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -500,6 +531,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -543,6 +577,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -657,6 +694,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -664,8 +702,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/replicapoolupdater1_beta1/Cargo.toml b/gen/replicapoolupdater1_beta1/Cargo.toml index 799599e452..fb953646d2 100644 --- a/gen/replicapoolupdater1_beta1/Cargo.toml +++ b/gen/replicapoolupdater1_beta1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-replicapoolupdater1_beta1" -version = "0.1.5+20150326" +version = "0.1.6+20150326" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with replicapoolupdater (protocol v1beta1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/replicapoolupdater1_beta1" diff --git a/gen/replicapoolupdater1_beta1/README.md b/gen/replicapoolupdater1_beta1/README.md index f5535b8a46..7686bb7dfa 100644 --- a/gen/replicapoolupdater1_beta1/README.md +++ b/gen/replicapoolupdater1_beta1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-replicapoolupdater1_beta1` library allows access to all features of the *Google replicapoolupdater* service. -This documentation was generated from *replicapoolupdater* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *replicapoolupdater:v1beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *replicapoolupdater* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *replicapoolupdater:v1beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *replicapoolupdater* *v1_beta1* API can be found at the [official documentation site](https://cloud.google.com/compute/docs/instance-groups/manager/#applying_rolling_updates_using_the_updater_service). @@ -112,14 +112,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/replicapoolupdater1_beta1/src/cmn.rs b/gen/replicapoolupdater1_beta1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/replicapoolupdater1_beta1/src/cmn.rs +++ b/gen/replicapoolupdater1_beta1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/replicapoolupdater1_beta1/src/lib.rs b/gen/replicapoolupdater1_beta1/src/lib.rs index 5361afed9b..1d9e3094f4 100644 --- a/gen/replicapoolupdater1_beta1/src/lib.rs +++ b/gen/replicapoolupdater1_beta1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *replicapoolupdater* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *replicapoolupdater:v1beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *replicapoolupdater* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *replicapoolupdater:v1beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *replicapoolupdater* *v1_beta1* API can be found at the //! [official documentation site](https://cloud.google.com/compute/docs/instance-groups/manager/#applying_rolling_updates_using_the_updater_service). @@ -113,14 +113,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -208,7 +209,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -294,14 +295,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -322,7 +324,7 @@ impl<'a, C, A> Replicapoolupdater<C, A> Replicapoolupdater { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -334,7 +336,7 @@ impl<'a, C, A> Replicapoolupdater<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -885,10 +887,10 @@ impl<'a, C, A> RollingUpdateMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - The Google Developers Console project name. /// * `zone` - The name of the zone in which the update's target resides. - pub fn insert(&self, request: &RollingUpdate, project: &str, zone: &str) -> RollingUpdateInsertCall<'a, C, A> { + pub fn insert(&self, request: RollingUpdate, project: &str, zone: &str) -> RollingUpdateInsertCall<'a, C, A> { RollingUpdateInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _zone: zone.to_string(), _delegate: Default::default(), @@ -1162,12 +1164,17 @@ impl<'a, C, A> RollingUpdatePauseCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1176,7 +1183,7 @@ impl<'a, C, A> RollingUpdatePauseCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1420,12 +1427,17 @@ impl<'a, C, A> RollingUpdateRollbackCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1434,7 +1446,7 @@ impl<'a, C, A> RollingUpdateRollbackCall<'a, C, A> where C: BorrowMut<hyper::Cli Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1678,12 +1690,17 @@ impl<'a, C, A> RollingUpdateGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1692,7 +1709,7 @@ impl<'a, C, A> RollingUpdateGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1936,12 +1953,17 @@ impl<'a, C, A> RollingUpdateResumeCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1950,7 +1972,7 @@ impl<'a, C, A> RollingUpdateResumeCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2212,12 +2234,17 @@ impl<'a, C, A> RollingUpdateListCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2226,7 +2253,7 @@ impl<'a, C, A> RollingUpdateListCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2371,7 +2398,7 @@ impl<'a, C, A> RollingUpdateListCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.rolling_updates().insert(&req, "project", "zone") +/// let result = hub.rolling_updates().insert(req, "project", "zone") /// .doit(); /// # } /// ``` @@ -2501,12 +2528,17 @@ impl<'a, C, A> RollingUpdateInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2515,7 +2547,7 @@ impl<'a, C, A> RollingUpdateInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2533,8 +2565,8 @@ impl<'a, C, A> RollingUpdateInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &RollingUpdate) -> RollingUpdateInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: RollingUpdate) -> RollingUpdateInsertCall<'a, C, A> { + self._request = new_value; self } /// The Google Developers Console project name. @@ -2773,12 +2805,17 @@ impl<'a, C, A> RollingUpdateListInstanceUpdateCall<'a, C, A> where C: BorrowMut< if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2787,7 +2824,7 @@ impl<'a, C, A> RollingUpdateListInstanceUpdateCall<'a, C, A> where C: BorrowMut< Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3052,12 +3089,17 @@ impl<'a, C, A> RollingUpdateCancelCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3066,7 +3108,7 @@ impl<'a, C, A> RollingUpdateCancelCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3310,12 +3352,17 @@ impl<'a, C, A> ZoneOperationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3324,7 +3371,7 @@ impl<'a, C, A> ZoneOperationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/reseller1_sandbox-cli/Cargo.toml b/gen/reseller1_sandbox-cli/Cargo.toml index c77e365f6f..0aadbbd7d5 100644 --- a/gen/reseller1_sandbox-cli/Cargo.toml +++ b/gen/reseller1_sandbox-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-reseller1_sandbox-cli" -version = "0.0.1+20141112" +version = "0.1.0+20141112" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with reseller (protocol v1sandbox)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/reseller1_sandbox-cli" diff --git a/gen/reseller1_sandbox-cli/README.md b/gen/reseller1_sandbox-cli/README.md index 9039e1ee49..a8f2b10074 100644 --- a/gen/reseller1_sandbox-cli/README.md +++ b/gen/reseller1_sandbox-cli/README.md @@ -1,4 +1,115 @@ -# HELLO RESELLER:V1SANDBOX +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `reseller1-sandbox` command-line interface *(CLI)* allows to use most features of the *Google reseller* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *reseller* API at revision *20141112*. The CLI is at version *0.1.0*. + +```bash + reseller1-sandbox [options] customers get <customer-id> [-p <v>...] [-o <out>] + reseller1-sandbox [options] customers insert -r <kv>... [-p <v>...] [-o <out>] + reseller1-sandbox [options] customers patch <customer-id> -r <kv>... [-p <v>...] [-o <out>] + reseller1-sandbox [options] customers update <customer-id> -r <kv>... [-p <v>...] [-o <out>] + reseller1-sandbox [options] subscriptions activate <customer-id> <subscription-id> [-p <v>...] [-o <out>] + reseller1-sandbox [options] subscriptions change-plan <customer-id> <subscription-id> -r <kv>... [-p <v>...] [-o <out>] + reseller1-sandbox [options] subscriptions change-renewal-settings <customer-id> <subscription-id> -r <kv>... [-p <v>...] [-o <out>] + reseller1-sandbox [options] subscriptions change-seats <customer-id> <subscription-id> -r <kv>... [-p <v>...] [-o <out>] + reseller1-sandbox [options] subscriptions delete <customer-id> <subscription-id> <deletion-type> [-p <v>...] + reseller1-sandbox [options] subscriptions get <customer-id> <subscription-id> [-p <v>...] [-o <out>] + reseller1-sandbox [options] subscriptions insert <customer-id> -r <kv>... [-p <v>...] [-o <out>] + reseller1-sandbox [options] subscriptions list [-p <v>...] [-o <out>] + reseller1-sandbox [options] subscriptions start-paid-service <customer-id> <subscription-id> [-p <v>...] [-o <out>] + reseller1-sandbox [options] subscriptions suspend <customer-id> <subscription-id> [-p <v>...] [-o <out>] + reseller1-sandbox --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_reseller1_sandbox_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `reseller1-sandbox-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/reseller1-sandbox-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/reseller1-sandbox-secret.json`, assuming that the required *reseller* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `reseller1-sandbox --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/reseller1_sandbox-cli/mkdocs.yml b/gen/reseller1_sandbox-cli/mkdocs.yml index a19e710f66..8a16c05f51 100644 --- a/gen/reseller1_sandbox-cli/mkdocs.yml +++ b/gen/reseller1_sandbox-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: reseller v0.0.1+20141112 +site_name: reseller v0.1.0+20141112 site_url: http://byron.github.io/google-apis-rs/google-reseller1_sandbox-cli site_description: Write integrating applications with bcore diff --git a/gen/reseller1_sandbox-cli/src/cmn.rs b/gen/reseller1_sandbox-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/reseller1_sandbox-cli/src/cmn.rs +++ b/gen/reseller1_sandbox-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/reseller1_sandbox-cli/src/main.rs b/gen/reseller1_sandbox-cli/src/main.rs index ae24f54e40..3c63f4f65b 100644 --- a/gen/reseller1_sandbox-cli/src/main.rs +++ b/gen/reseller1_sandbox-cli/src/main.rs @@ -19,39 +19,40 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - reseller1-sandbox [options] customers get <customer-id> [-p <v>]... [-o <out>] - reseller1-sandbox [options] customers insert -r <kv>... [-p <v>]... [-o <out>] - reseller1-sandbox [options] customers patch <customer-id> -r <kv>... [-p <v>]... [-o <out>] - reseller1-sandbox [options] customers update <customer-id> -r <kv>... [-p <v>]... [-o <out>] - reseller1-sandbox [options] subscriptions activate <customer-id> <subscription-id> [-p <v>]... [-o <out>] - reseller1-sandbox [options] subscriptions change-plan <customer-id> <subscription-id> -r <kv>... [-p <v>]... [-o <out>] - reseller1-sandbox [options] subscriptions change-renewal-settings <customer-id> <subscription-id> -r <kv>... [-p <v>]... [-o <out>] - reseller1-sandbox [options] subscriptions change-seats <customer-id> <subscription-id> -r <kv>... [-p <v>]... [-o <out>] - reseller1-sandbox [options] subscriptions delete <customer-id> <subscription-id> <deletion-type> [-p <v>]... - reseller1-sandbox [options] subscriptions get <customer-id> <subscription-id> [-p <v>]... [-o <out>] - reseller1-sandbox [options] subscriptions insert <customer-id> -r <kv>... [-p <v>]... [-o <out>] - reseller1-sandbox [options] subscriptions list [-p <v>]... [-o <out>] - reseller1-sandbox [options] subscriptions start-paid-service <customer-id> <subscription-id> [-p <v>]... [-o <out>] - reseller1-sandbox [options] subscriptions suspend <customer-id> <subscription-id> [-p <v>]... [-o <out>] + reseller1-sandbox [options] customers get <customer-id> [-p <v>...] [-o <out>] + reseller1-sandbox [options] customers insert -r <kv>... [-p <v>...] [-o <out>] + reseller1-sandbox [options] customers patch <customer-id> -r <kv>... [-p <v>...] [-o <out>] + reseller1-sandbox [options] customers update <customer-id> -r <kv>... [-p <v>...] [-o <out>] + reseller1-sandbox [options] subscriptions activate <customer-id> <subscription-id> [-p <v>...] [-o <out>] + reseller1-sandbox [options] subscriptions change-plan <customer-id> <subscription-id> -r <kv>... [-p <v>...] [-o <out>] + reseller1-sandbox [options] subscriptions change-renewal-settings <customer-id> <subscription-id> -r <kv>... [-p <v>...] [-o <out>] + reseller1-sandbox [options] subscriptions change-seats <customer-id> <subscription-id> -r <kv>... [-p <v>...] [-o <out>] + reseller1-sandbox [options] subscriptions delete <customer-id> <subscription-id> <deletion-type> [-p <v>...] + reseller1-sandbox [options] subscriptions get <customer-id> <subscription-id> [-p <v>...] [-o <out>] + reseller1-sandbox [options] subscriptions insert <customer-id> -r <kv>... [-p <v>...] [-o <out>] + reseller1-sandbox [options] subscriptions list [-p <v>...] [-o <out>] + reseller1-sandbox [options] subscriptions start-paid-service <customer-id> <subscription-id> [-p <v>...] [-o <out>] + reseller1-sandbox [options] subscriptions suspend <customer-id> <subscription-id> [-p <v>...] [-o <out>] reseller1-sandbox --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_reseller1_sandbox_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -100,6 +101,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -116,8 +120,95 @@ impl Engine { fn _customers_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Customer::default(); - let mut call = self.hub.customers().insert(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + fn request_postal_address_init(request: &mut api::Customer) { + if request.postal_address.is_none() { + request.postal_address = Some(Default::default()); + } + } + + match &temp_cursor.to_string()[..] { + "customer-domain" => { + request.customer_domain = Some(value.unwrap_or("").to_string()); + }, + "alternate-email" => { + request.alternate_email = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "resource-ui-url" => { + request.resource_ui_url = Some(value.unwrap_or("").to_string()); + }, + "phone-number" => { + request.phone_number = Some(value.unwrap_or("").to_string()); + }, + "postal-address.kind" => { + request_postal_address_init(&mut request); + request.postal_address.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); + }, + "postal-address.organization-name" => { + request_postal_address_init(&mut request); + request.postal_address.as_mut().unwrap().organization_name = Some(value.unwrap_or("").to_string()); + }, + "postal-address.country-code" => { + request_postal_address_init(&mut request); + request.postal_address.as_mut().unwrap().country_code = Some(value.unwrap_or("").to_string()); + }, + "postal-address.locality" => { + request_postal_address_init(&mut request); + request.postal_address.as_mut().unwrap().locality = Some(value.unwrap_or("").to_string()); + }, + "postal-address.region" => { + request_postal_address_init(&mut request); + request.postal_address.as_mut().unwrap().region = Some(value.unwrap_or("").to_string()); + }, + "postal-address.address-line2" => { + request_postal_address_init(&mut request); + request.postal_address.as_mut().unwrap().address_line2 = Some(value.unwrap_or("").to_string()); + }, + "postal-address.address-line3" => { + request_postal_address_init(&mut request); + request.postal_address.as_mut().unwrap().address_line3 = Some(value.unwrap_or("").to_string()); + }, + "postal-address.contact-name" => { + request_postal_address_init(&mut request); + request.postal_address.as_mut().unwrap().contact_name = Some(value.unwrap_or("").to_string()); + }, + "postal-address.address-line1" => { + request_postal_address_init(&mut request); + request.postal_address.as_mut().unwrap().address_line1 = Some(value.unwrap_or("").to_string()); + }, + "postal-address.postal-code" => { + request_postal_address_init(&mut request); + request.postal_address.as_mut().unwrap().postal_code = Some(value.unwrap_or("").to_string()); + }, + "customer-id" => { + request_postal_address_init(&mut request); + request.customer_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.customers().insert(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -142,89 +233,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_postal_address_init(request: &mut api::Customer) { - if request.postal_address.is_none() { - request.postal_address = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "customer-domain" => { - request.customer_domain = Some(value.unwrap_or("").to_string()); - }, - "alternate-email" => { - request.alternate_email = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "resource-ui-url" => { - request.resource_ui_url = Some(value.unwrap_or("").to_string()); - }, - "phone-number" => { - request.phone_number = Some(value.unwrap_or("").to_string()); - }, - "postal-address.kind" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); - }, - "postal-address.organization-name" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().organization_name = Some(value.unwrap_or("").to_string()); - }, - "postal-address.country-code" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().country_code = Some(value.unwrap_or("").to_string()); - }, - "postal-address.locality" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().locality = Some(value.unwrap_or("").to_string()); - }, - "postal-address.region" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().region = Some(value.unwrap_or("").to_string()); - }, - "postal-address.address-line2" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().address_line2 = Some(value.unwrap_or("").to_string()); - }, - "postal-address.address-line3" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().address_line3 = Some(value.unwrap_or("").to_string()); - }, - "postal-address.contact-name" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().contact_name = Some(value.unwrap_or("").to_string()); - }, - "postal-address.address-line1" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().address_line1 = Some(value.unwrap_or("").to_string()); - }, - "postal-address.postal-code" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().postal_code = Some(value.unwrap_or("").to_string()); - }, - "customer-id" => { - request_postal_address_init(&mut request); - request.customer_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -241,43 +257,30 @@ impl Engine { fn _customers_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Customer::default(); - let mut call = self.hub.customers().patch(&request, &self.opt.arg_customer_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Customer::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_postal_address_init(request: &mut api::Customer) { if request.postal_address.is_none() { request.postal_address = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "customer-domain" => { request.customer_domain = Some(value.unwrap_or("").to_string()); }, @@ -338,15 +341,40 @@ impl Engine { request.customer_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.customers().patch(request, &self.opt.arg_customer_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -363,43 +391,30 @@ impl Engine { fn _customers_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Customer::default(); - let mut call = self.hub.customers().update(&request, &self.opt.arg_customer_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Customer::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_postal_address_init(request: &mut api::Customer) { if request.postal_address.is_none() { request.postal_address = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "customer-domain" => { request.customer_domain = Some(value.unwrap_or("").to_string()); }, @@ -460,15 +475,40 @@ impl Engine { request.customer_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.customers().update(request, &self.opt.arg_customer_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -512,6 +552,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -528,43 +571,30 @@ impl Engine { fn _subscriptions_change_plan(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::ChangePlanRequest::default(); - let mut call = self.hub.subscriptions().change_plan(&request, &self.opt.arg_customer_id, &self.opt.arg_subscription_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ChangePlanRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_seats_init(request: &mut api::ChangePlanRequest) { if request.seats.is_none() { request.seats = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "plan-name" => { request.plan_name = Some(value.unwrap_or("").to_string()); }, @@ -592,15 +622,40 @@ impl Engine { request.purchase_order_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.subscriptions().change_plan(request, &self.opt.arg_customer_id, &self.opt.arg_subscription_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -617,8 +672,36 @@ impl Engine { fn _subscriptions_change_renewal_settings(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::RenewalSettings::default(); - let mut call = self.hub.subscriptions().change_renewal_settings(&request, &self.opt.arg_customer_id, &self.opt.arg_subscription_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "renewal-type" => { + request.renewal_type = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.subscriptions().change_renewal_settings(request, &self.opt.arg_customer_id, &self.opt.arg_subscription_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -640,30 +723,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "renewal-type" => { - request.renewal_type = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -680,8 +747,42 @@ impl Engine { fn _subscriptions_change_seats(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Seats::default(); - let mut call = self.hub.subscriptions().change_seats(&request, &self.opt.arg_customer_id, &self.opt.arg_subscription_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "number-of-seats" => { + request.number_of_seats = Some(arg_from_str(value.unwrap_or("-0"), err, "number-of-seats", "integer")); + }, + "maximum-number-of-seats" => { + request.maximum_number_of_seats = Some(arg_from_str(value.unwrap_or("-0"), err, "maximum-number-of-seats", "integer")); + }, + "licensed-number-of-seats" => { + request.licensed_number_of_seats = Some(arg_from_str(value.unwrap_or("-0"), err, "licensed-number-of-seats", "integer")); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.subscriptions().change_seats(request, &self.opt.arg_customer_id, &self.opt.arg_subscription_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -703,36 +804,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "number-of-seats" => { - request.number_of_seats = Some(arg_from_str(value.unwrap_or("-0"), err, "number-of-seats", "integer")); - }, - "maximum-number-of-seats" => { - request.maximum_number_of_seats = Some(arg_from_str(value.unwrap_or("-0"), err, "maximum-number-of-seats", "integer")); - }, - "licensed-number-of-seats" => { - request.licensed_number_of_seats = Some(arg_from_str(value.unwrap_or("-0"), err, "licensed-number-of-seats", "integer")); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -776,6 +855,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -817,6 +899,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -833,39 +918,23 @@ impl Engine { fn _subscriptions_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Subscription::default(); - let mut call = self.hub.subscriptions().insert(&request, &self.opt.arg_customer_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "customer-auth-token" => { - call = call.customer_auth_token(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Subscription::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_plan_commitment_interval_init(request: &mut api::Subscription) { request_plan_init(request); if request.plan.as_mut().unwrap().commitment_interval.is_none() { @@ -903,7 +972,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "renewal-settings.kind" => { request_renewal_settings_init(&mut request); request.renewal_settings.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); @@ -997,15 +1066,43 @@ impl Engine { request.customer_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.subscriptions().insert(request, &self.opt.arg_customer_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "customer-auth-token" => { + call = call.customer_auth_token(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1064,6 +1161,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1107,6 +1207,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1150,6 +1253,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1274,6 +1380,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -1281,8 +1388,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/reseller1_sandbox/Cargo.toml b/gen/reseller1_sandbox/Cargo.toml index 1ae491fe48..d8dd6a0470 100644 --- a/gen/reseller1_sandbox/Cargo.toml +++ b/gen/reseller1_sandbox/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-reseller1_sandbox" -version = "0.1.5+20141112" +version = "0.1.6+20141112" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with reseller (protocol v1sandbox)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/reseller1_sandbox" diff --git a/gen/reseller1_sandbox/README.md b/gen/reseller1_sandbox/README.md index 28c91eda79..7c91461c1d 100644 --- a/gen/reseller1_sandbox/README.md +++ b/gen/reseller1_sandbox/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-reseller1_sandbox` library allows access to all features of the *Google reseller* service. -This documentation was generated from *reseller* crate version *0.1.5+20141112*, where *20141112* is the exact revision of the *reseller:v1sandbox* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *reseller* crate version *0.1.6+20141112*, where *20141112* is the exact revision of the *reseller:v1sandbox* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *reseller* *v1_sandbox* API can be found at the [official documentation site](https://developers.google.com/google-apps/reseller/). @@ -115,14 +115,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/reseller1_sandbox/src/cmn.rs b/gen/reseller1_sandbox/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/reseller1_sandbox/src/cmn.rs +++ b/gen/reseller1_sandbox/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/reseller1_sandbox/src/lib.rs b/gen/reseller1_sandbox/src/lib.rs index 71e4c54c94..d960b6e033 100644 --- a/gen/reseller1_sandbox/src/lib.rs +++ b/gen/reseller1_sandbox/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *reseller* crate version *0.1.5+20141112*, where *20141112* is the exact revision of the *reseller:v1sandbox* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *reseller* crate version *0.1.6+20141112*, where *20141112* is the exact revision of the *reseller:v1sandbox* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *reseller* *v1_sandbox* API can be found at the //! [official documentation site](https://developers.google.com/google-apps/reseller/). @@ -116,14 +116,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -211,7 +212,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -294,14 +295,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -322,7 +324,7 @@ impl<'a, C, A> Reseller<C, A> Reseller { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -334,7 +336,7 @@ impl<'a, C, A> Reseller<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -715,10 +717,10 @@ impl<'a, C, A> CustomerMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `customerId` - Id of the Customer - pub fn update(&self, request: &Customer, customer_id: &str) -> CustomerUpdateCall<'a, C, A> { + pub fn update(&self, request: Customer, customer_id: &str) -> CustomerUpdateCall<'a, C, A> { CustomerUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _customer_id: customer_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -733,10 +735,10 @@ impl<'a, C, A> CustomerMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &Customer) -> CustomerInsertCall<'a, C, A> { + pub fn insert(&self, request: Customer) -> CustomerInsertCall<'a, C, A> { CustomerInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _customer_auth_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -752,10 +754,10 @@ impl<'a, C, A> CustomerMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `customerId` - Id of the Customer - pub fn patch(&self, request: &Customer, customer_id: &str) -> CustomerPatchCall<'a, C, A> { + pub fn patch(&self, request: Customer, customer_id: &str) -> CustomerPatchCall<'a, C, A> { CustomerPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _customer_id: customer_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -829,10 +831,10 @@ impl<'a, C, A> SubscriptionMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `customerId` - Id of the Customer - pub fn insert(&self, request: &Subscription, customer_id: &str) -> SubscriptionInsertCall<'a, C, A> { + pub fn insert(&self, request: Subscription, customer_id: &str) -> SubscriptionInsertCall<'a, C, A> { SubscriptionInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _customer_id: customer_id.to_string(), _customer_auth_token: Default::default(), _delegate: Default::default(), @@ -907,10 +909,10 @@ impl<'a, C, A> SubscriptionMethods<'a, C, A> { /// * `request` - No description provided. /// * `customerId` - Id of the Customer /// * `subscriptionId` - Id of the subscription, which is unique for a customer - pub fn change_renewal_settings(&self, request: &RenewalSettings, customer_id: &str, subscription_id: &str) -> SubscriptionChangeRenewalSettingCall<'a, C, A> { + pub fn change_renewal_settings(&self, request: RenewalSettings, customer_id: &str, subscription_id: &str) -> SubscriptionChangeRenewalSettingCall<'a, C, A> { SubscriptionChangeRenewalSettingCall { hub: self.hub, - _request: request.clone(), + _request: request, _customer_id: customer_id.to_string(), _subscription_id: subscription_id.to_string(), _delegate: Default::default(), @@ -947,10 +949,10 @@ impl<'a, C, A> SubscriptionMethods<'a, C, A> { /// * `request` - No description provided. /// * `customerId` - Id of the Customer /// * `subscriptionId` - Id of the subscription, which is unique for a customer - pub fn change_seats(&self, request: &Seats, customer_id: &str, subscription_id: &str) -> SubscriptionChangeSeatCall<'a, C, A> { + pub fn change_seats(&self, request: Seats, customer_id: &str, subscription_id: &str) -> SubscriptionChangeSeatCall<'a, C, A> { SubscriptionChangeSeatCall { hub: self.hub, - _request: request.clone(), + _request: request, _customer_id: customer_id.to_string(), _subscription_id: subscription_id.to_string(), _delegate: Default::default(), @@ -1006,10 +1008,10 @@ impl<'a, C, A> SubscriptionMethods<'a, C, A> { /// * `request` - No description provided. /// * `customerId` - Id of the Customer /// * `subscriptionId` - Id of the subscription, which is unique for a customer - pub fn change_plan(&self, request: &ChangePlanRequest, customer_id: &str, subscription_id: &str) -> SubscriptionChangePlanCall<'a, C, A> { + pub fn change_plan(&self, request: ChangePlanRequest, customer_id: &str, subscription_id: &str) -> SubscriptionChangePlanCall<'a, C, A> { SubscriptionChangePlanCall { hub: self.hub, - _request: request.clone(), + _request: request, _customer_id: customer_id.to_string(), _subscription_id: subscription_id.to_string(), _delegate: Default::default(), @@ -1059,7 +1061,7 @@ impl<'a, C, A> SubscriptionMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.customers().update(&req, "customerId") +/// let result = hub.customers().update(req, "customerId") /// .doit(); /// # } /// ``` @@ -1187,12 +1189,17 @@ impl<'a, C, A> CustomerUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1201,7 +1208,7 @@ impl<'a, C, A> CustomerUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1219,8 +1226,8 @@ impl<'a, C, A> CustomerUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Customer) -> CustomerUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Customer) -> CustomerUpdateCall<'a, C, A> { + self._request = new_value; self } /// Id of the Customer @@ -1317,7 +1324,7 @@ impl<'a, C, A> CustomerUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.customers().insert(&req) +/// let result = hub.customers().insert(req) /// .customer_auth_token("gubergren") /// .doit(); /// # } @@ -1424,12 +1431,17 @@ impl<'a, C, A> CustomerInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1438,7 +1450,7 @@ impl<'a, C, A> CustomerInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1456,8 +1468,8 @@ impl<'a, C, A> CustomerInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Customer) -> CustomerInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Customer) -> CustomerInsertCall<'a, C, A> { + self._request = new_value; self } /// An auth token needed for inserting a customer for which domain already exists. Can be generated at https://www.google.com/a/cpanel//TransferToken. Optional. @@ -1551,7 +1563,7 @@ impl<'a, C, A> CustomerInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.customers().patch(&req, "customerId") +/// let result = hub.customers().patch(req, "customerId") /// .doit(); /// # } /// ``` @@ -1679,12 +1691,17 @@ impl<'a, C, A> CustomerPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1693,7 +1710,7 @@ impl<'a, C, A> CustomerPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1711,8 +1728,8 @@ impl<'a, C, A> CustomerPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Customer) -> CustomerPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Customer) -> CustomerPatchCall<'a, C, A> { + self._request = new_value; self } /// Id of the Customer @@ -1922,12 +1939,17 @@ impl<'a, C, A> CustomerGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1936,7 +1958,7 @@ impl<'a, C, A> CustomerGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2043,7 +2065,7 @@ impl<'a, C, A> CustomerGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.subscriptions().insert(&req, "customerId") +/// let result = hub.subscriptions().insert(req, "customerId") /// .customer_auth_token("no") /// .doit(); /// # } @@ -2176,12 +2198,17 @@ impl<'a, C, A> SubscriptionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2190,7 +2217,7 @@ impl<'a, C, A> SubscriptionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2208,8 +2235,8 @@ impl<'a, C, A> SubscriptionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Subscription) -> SubscriptionInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Subscription) -> SubscriptionInsertCall<'a, C, A> { + self._request = new_value; self } /// Id of the Customer @@ -2429,12 +2456,17 @@ impl<'a, C, A> SubscriptionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -2675,12 +2707,17 @@ impl<'a, C, A> SubscriptionGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2689,7 +2726,7 @@ impl<'a, C, A> SubscriptionGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2918,12 +2955,17 @@ impl<'a, C, A> SubscriptionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2932,7 +2974,7 @@ impl<'a, C, A> SubscriptionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3064,7 +3106,7 @@ impl<'a, C, A> SubscriptionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.subscriptions().change_renewal_settings(&req, "customerId", "subscriptionId") +/// let result = hub.subscriptions().change_renewal_settings(req, "customerId", "subscriptionId") /// .doit(); /// # } /// ``` @@ -3194,12 +3236,17 @@ impl<'a, C, A> SubscriptionChangeRenewalSettingCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3208,7 +3255,7 @@ impl<'a, C, A> SubscriptionChangeRenewalSettingCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3226,8 +3273,8 @@ impl<'a, C, A> SubscriptionChangeRenewalSettingCall<'a, C, A> where C: BorrowMut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &RenewalSettings) -> SubscriptionChangeRenewalSettingCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: RenewalSettings) -> SubscriptionChangeRenewalSettingCall<'a, C, A> { + self._request = new_value; self } /// Id of the Customer @@ -3449,12 +3496,17 @@ impl<'a, C, A> SubscriptionStartPaidServiceCall<'a, C, A> where C: BorrowMut<hyp if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3463,7 +3515,7 @@ impl<'a, C, A> SubscriptionStartPaidServiceCall<'a, C, A> where C: BorrowMut<hyp Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3580,7 +3632,7 @@ impl<'a, C, A> SubscriptionStartPaidServiceCall<'a, C, A> where C: BorrowMut<hyp /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.subscriptions().change_seats(&req, "customerId", "subscriptionId") +/// let result = hub.subscriptions().change_seats(req, "customerId", "subscriptionId") /// .doit(); /// # } /// ``` @@ -3710,12 +3762,17 @@ impl<'a, C, A> SubscriptionChangeSeatCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3724,7 +3781,7 @@ impl<'a, C, A> SubscriptionChangeSeatCall<'a, C, A> where C: BorrowMut<hyper::Cl Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3742,8 +3799,8 @@ impl<'a, C, A> SubscriptionChangeSeatCall<'a, C, A> where C: BorrowMut<hyper::Cl /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Seats) -> SubscriptionChangeSeatCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Seats) -> SubscriptionChangeSeatCall<'a, C, A> { + self._request = new_value; self } /// Id of the Customer @@ -3965,12 +4022,17 @@ impl<'a, C, A> SubscriptionSuspendCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3979,7 +4041,7 @@ impl<'a, C, A> SubscriptionSuspendCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4211,12 +4273,17 @@ impl<'a, C, A> SubscriptionActivateCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4225,7 +4292,7 @@ impl<'a, C, A> SubscriptionActivateCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4342,7 +4409,7 @@ impl<'a, C, A> SubscriptionActivateCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.subscriptions().change_plan(&req, "customerId", "subscriptionId") +/// let result = hub.subscriptions().change_plan(req, "customerId", "subscriptionId") /// .doit(); /// # } /// ``` @@ -4472,12 +4539,17 @@ impl<'a, C, A> SubscriptionChangePlanCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4486,7 +4558,7 @@ impl<'a, C, A> SubscriptionChangePlanCall<'a, C, A> where C: BorrowMut<hyper::Cl Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4504,8 +4576,8 @@ impl<'a, C, A> SubscriptionChangePlanCall<'a, C, A> where C: BorrowMut<hyper::Cl /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ChangePlanRequest) -> SubscriptionChangePlanCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ChangePlanRequest) -> SubscriptionChangePlanCall<'a, C, A> { + self._request = new_value; self } /// Id of the Customer diff --git a/gen/resourceviews1_beta2-cli/Cargo.toml b/gen/resourceviews1_beta2-cli/Cargo.toml index 7375b1d4b8..b3299511b4 100644 --- a/gen/resourceviews1_beta2-cli/Cargo.toml +++ b/gen/resourceviews1_beta2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-resourceviews1_beta2-cli" -version = "0.0.1+20150302" +version = "0.1.0+20150302" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with resourceviews (protocol v1beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/resourceviews1_beta2-cli" diff --git a/gen/resourceviews1_beta2-cli/README.md b/gen/resourceviews1_beta2-cli/README.md index cfe961743a..c3e9f42ea4 100644 --- a/gen/resourceviews1_beta2-cli/README.md +++ b/gen/resourceviews1_beta2-cli/README.md @@ -1,4 +1,112 @@ -# HELLO RESOURCEVIEWS:V1BETA2 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `resourceviews1-beta2` command-line interface *(CLI)* allows to use most features of the *Google resourceviews* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *resourceviews* API at revision *20150302*. The CLI is at version *0.1.0*. + +```bash + resourceviews1-beta2 [options] zone-operations get <project> <zone> <operation> [-p <v>...] [-o <out>] + resourceviews1-beta2 [options] zone-operations list <project> <zone> [-p <v>...] [-o <out>] + resourceviews1-beta2 [options] zone-views add-resources <project> <zone> <resource-view> -r <kv>... [-p <v>...] [-o <out>] + resourceviews1-beta2 [options] zone-views delete <project> <zone> <resource-view> [-p <v>...] [-o <out>] + resourceviews1-beta2 [options] zone-views get <project> <zone> <resource-view> [-p <v>...] [-o <out>] + resourceviews1-beta2 [options] zone-views get-service <project> <zone> <resource-view> [-p <v>...] [-o <out>] + resourceviews1-beta2 [options] zone-views insert <project> <zone> -r <kv>... [-p <v>...] [-o <out>] + resourceviews1-beta2 [options] zone-views list <project> <zone> [-p <v>...] [-o <out>] + resourceviews1-beta2 [options] zone-views list-resources <project> <zone> <resource-view> [-p <v>...] [-o <out>] + resourceviews1-beta2 [options] zone-views remove-resources <project> <zone> <resource-view> -r <kv>... [-p <v>...] [-o <out>] + resourceviews1-beta2 [options] zone-views set-service <project> <zone> <resource-view> -r <kv>... [-p <v>...] [-o <out>] + resourceviews1-beta2 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_resourceviews1_beta2_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `resourceviews1-beta2-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/resourceviews1-beta2-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/resourceviews1-beta2-secret.json`, assuming that the required *resourceviews* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `resourceviews1-beta2 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/resourceviews1_beta2-cli/mkdocs.yml b/gen/resourceviews1_beta2-cli/mkdocs.yml index 774bb738d8..fe57850c86 100644 --- a/gen/resourceviews1_beta2-cli/mkdocs.yml +++ b/gen/resourceviews1_beta2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: resourceviews v0.0.1+20150302 +site_name: resourceviews v0.1.0+20150302 site_url: http://byron.github.io/google-apis-rs/google-resourceviews1_beta2-cli site_description: Write integrating applications with bcore diff --git a/gen/resourceviews1_beta2-cli/src/cmn.rs b/gen/resourceviews1_beta2-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/resourceviews1_beta2-cli/src/cmn.rs +++ b/gen/resourceviews1_beta2-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/resourceviews1_beta2-cli/src/main.rs b/gen/resourceviews1_beta2-cli/src/main.rs index 233e550386..e61e22f959 100644 --- a/gen/resourceviews1_beta2-cli/src/main.rs +++ b/gen/resourceviews1_beta2-cli/src/main.rs @@ -19,36 +19,37 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - resourceviews1-beta2 [options] zone-operations get <project> <zone> <operation> [-p <v>]... [-o <out>] - resourceviews1-beta2 [options] zone-operations list <project> <zone> [-p <v>]... [-o <out>] - resourceviews1-beta2 [options] zone-views add-resources <project> <zone> <resource-view> -r <kv>... [-p <v>]... [-o <out>] - resourceviews1-beta2 [options] zone-views delete <project> <zone> <resource-view> [-p <v>]... [-o <out>] - resourceviews1-beta2 [options] zone-views get <project> <zone> <resource-view> [-p <v>]... [-o <out>] - resourceviews1-beta2 [options] zone-views get-service <project> <zone> <resource-view> [-p <v>]... [-o <out>] - resourceviews1-beta2 [options] zone-views insert <project> <zone> -r <kv>... [-p <v>]... [-o <out>] - resourceviews1-beta2 [options] zone-views list <project> <zone> [-p <v>]... [-o <out>] - resourceviews1-beta2 [options] zone-views list-resources <project> <zone> <resource-view> [-p <v>]... [-o <out>] - resourceviews1-beta2 [options] zone-views remove-resources <project> <zone> <resource-view> -r <kv>... [-p <v>]... [-o <out>] - resourceviews1-beta2 [options] zone-views set-service <project> <zone> <resource-view> -r <kv>... [-p <v>]... [-o <out>] + resourceviews1-beta2 [options] zone-operations get <project> <zone> <operation> [-p <v>...] [-o <out>] + resourceviews1-beta2 [options] zone-operations list <project> <zone> [-p <v>...] [-o <out>] + resourceviews1-beta2 [options] zone-views add-resources <project> <zone> <resource-view> -r <kv>... [-p <v>...] [-o <out>] + resourceviews1-beta2 [options] zone-views delete <project> <zone> <resource-view> [-p <v>...] [-o <out>] + resourceviews1-beta2 [options] zone-views get <project> <zone> <resource-view> [-p <v>...] [-o <out>] + resourceviews1-beta2 [options] zone-views get-service <project> <zone> <resource-view> [-p <v>...] [-o <out>] + resourceviews1-beta2 [options] zone-views insert <project> <zone> -r <kv>... [-p <v>...] [-o <out>] + resourceviews1-beta2 [options] zone-views list <project> <zone> [-p <v>...] [-o <out>] + resourceviews1-beta2 [options] zone-views list-resources <project> <zone> <resource-view> [-p <v>...] [-o <out>] + resourceviews1-beta2 [options] zone-views remove-resources <project> <zone> <resource-view> -r <kv>... [-p <v>...] [-o <out>] + resourceviews1-beta2 [options] zone-views set-service <project> <zone> <resource-view> -r <kv>... [-p <v>...] [-o <out>] resourceviews1-beta2 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_resourceviews1_beta2_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -97,6 +98,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -149,6 +153,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -165,8 +172,36 @@ impl Engine { fn _zone_views_add_resources(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::ZoneViewsAddResourcesRequest::default(); - let mut call = self.hub.zone_views().add_resources(&request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_resource_view); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "resources" => { + if request.resources.is_none() { + request.resources = Some(Default::default()); + } + request.resources.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.zone_views().add_resources(request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_resource_view); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -188,30 +223,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "resources" => { - if request.resources.is_none() { - request.resources = Some(Default::default()); - } - request.resources.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -255,6 +274,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -298,6 +320,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -344,6 +369,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -360,37 +388,24 @@ impl Engine { fn _zone_views_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::ResourceView::default(); - let mut call = self.hub.zone_views().insert(&request, &self.opt.arg_project, &self.opt.arg_zone); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ResourceView::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -425,15 +440,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.zone_views().insert(request, &self.opt.arg_project, &self.opt.arg_zone); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -483,6 +523,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -541,6 +584,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -557,8 +603,36 @@ impl Engine { fn _zone_views_remove_resources(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::ZoneViewsRemoveResourcesRequest::default(); - let mut call = self.hub.zone_views().remove_resources(&request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_resource_view); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "resources" => { + if request.resources.is_none() { + request.resources = Some(Default::default()); + } + request.resources.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.zone_views().remove_resources(request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_resource_view); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -580,30 +654,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "resources" => { - if request.resources.is_none() { - request.resources = Some(Default::default()); - } - request.resources.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -620,8 +678,36 @@ impl Engine { fn _zone_views_set_service(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::ZoneViewsSetServiceRequest::default(); - let mut call = self.hub.zone_views().set_service(&request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_resource_view); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "resource-name" => { + request.resource_name = Some(value.unwrap_or("").to_string()); + }, + "fingerprint" => { + request.fingerprint = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.zone_views().set_service(request, &self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_resource_view); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -643,30 +729,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "resource-name" => { - request.resource_name = Some(value.unwrap_or("").to_string()); - }, - "fingerprint" => { - request.fingerprint = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -785,6 +855,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -792,8 +863,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/resourceviews1_beta2/Cargo.toml b/gen/resourceviews1_beta2/Cargo.toml index 235673471f..a4daa9d97b 100644 --- a/gen/resourceviews1_beta2/Cargo.toml +++ b/gen/resourceviews1_beta2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-resourceviews1_beta2" -version = "0.1.5+20150302" +version = "0.1.6+20150302" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with resourceviews (protocol v1beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/resourceviews1_beta2" diff --git a/gen/resourceviews1_beta2/README.md b/gen/resourceviews1_beta2/README.md index ba40b120eb..39de051bc3 100644 --- a/gen/resourceviews1_beta2/README.md +++ b/gen/resourceviews1_beta2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-resourceviews1_beta2` library allows access to all features of the *Google resourceviews* service. -This documentation was generated from *resourceviews* crate version *0.1.5+20150302*, where *20150302* is the exact revision of the *resourceviews:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *resourceviews* crate version *0.1.6+20150302*, where *20150302* is the exact revision of the *resourceviews:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *resourceviews* *v1_beta2* API can be found at the [official documentation site](https://developers.google.com/compute/). @@ -105,21 +105,22 @@ let mut req = ZoneViewsRemoveResourcesRequest::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.zone_views().remove_resources(&req, "project", "zone", "resourceView") +let result = hub.zone_views().remove_resources(req, "project", "zone", "resourceView") .doit(); match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/resourceviews1_beta2/src/cmn.rs b/gen/resourceviews1_beta2/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/resourceviews1_beta2/src/cmn.rs +++ b/gen/resourceviews1_beta2/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/resourceviews1_beta2/src/lib.rs b/gen/resourceviews1_beta2/src/lib.rs index e9e4119d48..14c99fc714 100644 --- a/gen/resourceviews1_beta2/src/lib.rs +++ b/gen/resourceviews1_beta2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *resourceviews* crate version *0.1.5+20150302*, where *20150302* is the exact revision of the *resourceviews:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *resourceviews* crate version *0.1.6+20150302*, where *20150302* is the exact revision of the *resourceviews:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *resourceviews* *v1_beta2* API can be found at the //! [official documentation site](https://developers.google.com/compute/). @@ -106,21 +106,22 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.zone_views().remove_resources(&req, "project", "zone", "resourceView") +//! let result = hub.zone_views().remove_resources(req, "project", "zone", "resourceView") //! .doit(); //! //! match result { //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -208,7 +209,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -297,21 +298,22 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.zone_views().remove_resources(&req, "project", "zone", "resourceView") +/// let result = hub.zone_views().remove_resources(req, "project", "zone", "resourceView") /// .doit(); /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -332,7 +334,7 @@ impl<'a, C, A> Resourceviews<C, A> Resourceviews { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -344,7 +346,7 @@ impl<'a, C, A> Resourceviews<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -799,10 +801,10 @@ impl<'a, C, A> ZoneViewMethods<'a, C, A> { /// * `project` - The project name of the resource view. /// * `zone` - The zone name of the resource view. /// * `resourceView` - The name of the resource view. - pub fn remove_resources(&self, request: &ZoneViewsRemoveResourcesRequest, project: &str, zone: &str, resource_view: &str) -> ZoneViewRemoveResourceCall<'a, C, A> { + pub fn remove_resources(&self, request: ZoneViewsRemoveResourcesRequest, project: &str, zone: &str, resource_view: &str) -> ZoneViewRemoveResourceCall<'a, C, A> { ZoneViewRemoveResourceCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _zone: zone.to_string(), _resource_view: resource_view.to_string(), @@ -822,10 +824,10 @@ impl<'a, C, A> ZoneViewMethods<'a, C, A> { /// * `project` - The project name of the resource view. /// * `zone` - The zone name of the resource view. /// * `resourceView` - The name of the resource view. - pub fn add_resources(&self, request: &ZoneViewsAddResourcesRequest, project: &str, zone: &str, resource_view: &str) -> ZoneViewAddResourceCall<'a, C, A> { + pub fn add_resources(&self, request: ZoneViewsAddResourcesRequest, project: &str, zone: &str, resource_view: &str) -> ZoneViewAddResourceCall<'a, C, A> { ZoneViewAddResourceCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _zone: zone.to_string(), _resource_view: resource_view.to_string(), @@ -912,10 +914,10 @@ impl<'a, C, A> ZoneViewMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - The project name of the resource view. /// * `zone` - The zone name of the resource view. - pub fn insert(&self, request: &ResourceView, project: &str, zone: &str) -> ZoneViewInsertCall<'a, C, A> { + pub fn insert(&self, request: ResourceView, project: &str, zone: &str) -> ZoneViewInsertCall<'a, C, A> { ZoneViewInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _zone: zone.to_string(), _delegate: Default::default(), @@ -955,10 +957,10 @@ impl<'a, C, A> ZoneViewMethods<'a, C, A> { /// * `project` - The project name of the resource view. /// * `zone` - The zone name of the resource view. /// * `resourceView` - The name of the resource view. - pub fn set_service(&self, request: &ZoneViewsSetServiceRequest, project: &str, zone: &str, resource_view: &str) -> ZoneViewSetServiceCall<'a, C, A> { + pub fn set_service(&self, request: ZoneViewsSetServiceRequest, project: &str, zone: &str, resource_view: &str) -> ZoneViewSetServiceCall<'a, C, A> { ZoneViewSetServiceCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _zone: zone.to_string(), _resource_view: resource_view.to_string(), @@ -1115,7 +1117,7 @@ impl<'a, C, A> ZoneOperationMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.zone_views().remove_resources(&req, "project", "zone", "resourceView") +/// let result = hub.zone_views().remove_resources(req, "project", "zone", "resourceView") /// .doit(); /// # } /// ``` @@ -1247,12 +1249,17 @@ impl<'a, C, A> ZoneViewRemoveResourceCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1261,7 +1268,7 @@ impl<'a, C, A> ZoneViewRemoveResourceCall<'a, C, A> where C: BorrowMut<hyper::Cl Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1279,8 +1286,8 @@ impl<'a, C, A> ZoneViewRemoveResourceCall<'a, C, A> where C: BorrowMut<hyper::Cl /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ZoneViewsRemoveResourcesRequest) -> ZoneViewRemoveResourceCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ZoneViewsRemoveResourcesRequest) -> ZoneViewRemoveResourceCall<'a, C, A> { + self._request = new_value; self } /// The project name of the resource view. @@ -1397,7 +1404,7 @@ impl<'a, C, A> ZoneViewRemoveResourceCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.zone_views().add_resources(&req, "project", "zone", "resourceView") +/// let result = hub.zone_views().add_resources(req, "project", "zone", "resourceView") /// .doit(); /// # } /// ``` @@ -1529,12 +1536,17 @@ impl<'a, C, A> ZoneViewAddResourceCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1543,7 +1555,7 @@ impl<'a, C, A> ZoneViewAddResourceCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1561,8 +1573,8 @@ impl<'a, C, A> ZoneViewAddResourceCall<'a, C, A> where C: BorrowMut<hyper::Clien /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ZoneViewsAddResourcesRequest) -> ZoneViewAddResourceCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ZoneViewsAddResourcesRequest) -> ZoneViewAddResourceCall<'a, C, A> { + self._request = new_value; self } /// The project name of the resource view. @@ -1821,12 +1833,17 @@ impl<'a, C, A> ZoneViewListResourceCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1835,7 +1852,7 @@ impl<'a, C, A> ZoneViewListResourceCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2114,12 +2131,17 @@ impl<'a, C, A> ZoneViewGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2128,7 +2150,7 @@ impl<'a, C, A> ZoneViewGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2380,12 +2402,17 @@ impl<'a, C, A> ZoneViewListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2394,7 +2421,7 @@ impl<'a, C, A> ZoneViewListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2525,7 +2552,7 @@ impl<'a, C, A> ZoneViewListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.zone_views().insert(&req, "project", "zone") +/// let result = hub.zone_views().insert(req, "project", "zone") /// .doit(); /// # } /// ``` @@ -2655,12 +2682,17 @@ impl<'a, C, A> ZoneViewInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2669,7 +2701,7 @@ impl<'a, C, A> ZoneViewInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2687,8 +2719,8 @@ impl<'a, C, A> ZoneViewInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ResourceView) -> ZoneViewInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ResourceView) -> ZoneViewInsertCall<'a, C, A> { + self._request = new_value; self } /// The project name of the resource view. @@ -2912,12 +2944,17 @@ impl<'a, C, A> ZoneViewDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2926,7 +2963,7 @@ impl<'a, C, A> ZoneViewDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3053,7 +3090,7 @@ impl<'a, C, A> ZoneViewDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.zone_views().set_service(&req, "project", "zone", "resourceView") +/// let result = hub.zone_views().set_service(req, "project", "zone", "resourceView") /// .doit(); /// # } /// ``` @@ -3185,12 +3222,17 @@ impl<'a, C, A> ZoneViewSetServiceCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3199,7 +3241,7 @@ impl<'a, C, A> ZoneViewSetServiceCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3217,8 +3259,8 @@ impl<'a, C, A> ZoneViewSetServiceCall<'a, C, A> where C: BorrowMut<hyper::Client /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ZoneViewsSetServiceRequest) -> ZoneViewSetServiceCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ZoneViewsSetServiceRequest) -> ZoneViewSetServiceCall<'a, C, A> { + self._request = new_value; self } /// The project name of the resource view. @@ -3457,12 +3499,17 @@ impl<'a, C, A> ZoneViewGetServiceCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3471,7 +3518,7 @@ impl<'a, C, A> ZoneViewGetServiceCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3722,12 +3769,17 @@ impl<'a, C, A> ZoneOperationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3736,7 +3788,7 @@ impl<'a, C, A> ZoneOperationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3993,12 +4045,17 @@ impl<'a, C, A> ZoneOperationListCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4007,7 +4064,7 @@ impl<'a, C, A> ZoneOperationListCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/siteverification1-cli/Cargo.toml b/gen/siteverification1-cli/Cargo.toml index b8bf7cfd93..fd219cdeb0 100644 --- a/gen/siteverification1-cli/Cargo.toml +++ b/gen/siteverification1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-siteverification1-cli" -version = "0.0.1+20131007" +version = "0.1.0+20131007" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with siteVerification (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/siteverification1-cli" diff --git a/gen/siteverification1-cli/README.md b/gen/siteverification1-cli/README.md index 69ad885699..5784f9d867 100644 --- a/gen/siteverification1-cli/README.md +++ b/gen/siteverification1-cli/README.md @@ -1,4 +1,108 @@ -# HELLO SITEVERIFICATION:V1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `siteverification1` command-line interface *(CLI)* allows to use most features of the *Google siteVerification* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *siteVerification* API at revision *20131007*. The CLI is at version *0.1.0*. + +```bash + siteverification1 [options] web-resource delete <id> [-p <v>...] + siteverification1 [options] web-resource get <id> [-p <v>...] [-o <out>] + siteverification1 [options] web-resource get-token -r <kv>... [-p <v>...] [-o <out>] + siteverification1 [options] web-resource insert <verification-method> -r <kv>... [-p <v>...] [-o <out>] + siteverification1 [options] web-resource list [-p <v>...] [-o <out>] + siteverification1 [options] web-resource patch <id> -r <kv>... [-p <v>...] [-o <out>] + siteverification1 [options] web-resource update <id> -r <kv>... [-p <v>...] [-o <out>] + siteverification1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_siteverification1_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `siteverification1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/siteverification1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/siteverification1-secret.json`, assuming that the required *siteVerification* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `siteverification1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/siteverification1-cli/mkdocs.yml b/gen/siteverification1-cli/mkdocs.yml index 0f293c4972..9175061b57 100644 --- a/gen/siteverification1-cli/mkdocs.yml +++ b/gen/siteverification1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: siteVerification v0.0.1+20131007 +site_name: siteVerification v0.1.0+20131007 site_url: http://byron.github.io/google-apis-rs/google-siteverification1-cli site_description: Write integrating applications with bcore diff --git a/gen/siteverification1-cli/src/cmn.rs b/gen/siteverification1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/siteverification1-cli/src/cmn.rs +++ b/gen/siteverification1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/siteverification1-cli/src/main.rs b/gen/siteverification1-cli/src/main.rs index 3cf95696f9..88e9e6712e 100644 --- a/gen/siteverification1-cli/src/main.rs +++ b/gen/siteverification1-cli/src/main.rs @@ -19,32 +19,33 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - siteverification1 [options] web-resource delete <id> [-p <v>]... - siteverification1 [options] web-resource get <id> [-p <v>]... [-o <out>] - siteverification1 [options] web-resource get-token -r <kv>... [-p <v>]... [-o <out>] - siteverification1 [options] web-resource insert <verification-method> -r <kv>... [-p <v>]... [-o <out>] - siteverification1 [options] web-resource list [-p <v>]... [-o <out>] - siteverification1 [options] web-resource patch <id> -r <kv>... [-p <v>]... [-o <out>] - siteverification1 [options] web-resource update <id> -r <kv>... [-p <v>]... [-o <out>] + siteverification1 [options] web-resource delete <id> [-p <v>...] + siteverification1 [options] web-resource get <id> [-p <v>...] [-o <out>] + siteverification1 [options] web-resource get-token -r <kv>... [-p <v>...] [-o <out>] + siteverification1 [options] web-resource insert <verification-method> -r <kv>... [-p <v>...] [-o <out>] + siteverification1 [options] web-resource list [-p <v>...] [-o <out>] + siteverification1 [options] web-resource patch <id> -r <kv>... [-p <v>...] [-o <out>] + siteverification1 [options] web-resource update <id> -r <kv>... [-p <v>...] [-o <out>] siteverification1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_siteverification1_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -93,6 +94,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -134,6 +138,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -150,8 +157,47 @@ impl Engine { fn _web_resource_get_token(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::SiteVerificationWebResourceGettokenRequest::default(); - let mut call = self.hub.web_resource().get_token(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + fn request_site_init(request: &mut api::SiteVerificationWebResourceGettokenRequest) { + if request.site.is_none() { + request.site = Some(Default::default()); + } + } + + match &temp_cursor.to_string()[..] { + "verification-method" => { + request.verification_method = Some(value.unwrap_or("").to_string()); + }, + "site.identifier" => { + request_site_init(&mut request); + request.site.as_mut().unwrap().identifier = Some(value.unwrap_or("").to_string()); + }, + "site.type" => { + request_site_init(&mut request); + request.site.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.web_resource().get_token(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -173,41 +219,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_site_init(request: &mut api::SiteVerificationWebResourceGettokenRequest) { - if request.site.is_none() { - request.site = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "verification-method" => { - request.verification_method = Some(value.unwrap_or("").to_string()); - }, - "site.identifier" => { - request_site_init(&mut request); - request.site.as_mut().unwrap().identifier = Some(value.unwrap_or("").to_string()); - }, - "site.type" => { - request_site_init(&mut request); - request.site.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -224,43 +243,30 @@ impl Engine { fn _web_resource_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::SiteVerificationWebResourceResource::default(); - let mut call = self.hub.web_resource().insert(&request, &self.opt.arg_verification_method); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::SiteVerificationWebResourceResource::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_site_init(request: &mut api::SiteVerificationWebResourceResource) { if request.site.is_none() { request.site = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "owners" => { if request.owners.is_none() { request.owners = Some(Default::default()); @@ -279,15 +285,40 @@ impl Engine { request.site.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.web_resource().insert(request, &self.opt.arg_verification_method); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -331,6 +362,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -347,8 +381,53 @@ impl Engine { fn _web_resource_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::SiteVerificationWebResourceResource::default(); - let mut call = self.hub.web_resource().patch(&request, &self.opt.arg_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + fn request_site_init(request: &mut api::SiteVerificationWebResourceResource) { + if request.site.is_none() { + request.site = Some(Default::default()); + } + } + + match &temp_cursor.to_string()[..] { + "owners" => { + if request.owners.is_none() { + request.owners = Some(Default::default()); + } + request.owners.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "site.identifier" => { + request_site_init(&mut request); + request.site.as_mut().unwrap().identifier = Some(value.unwrap_or("").to_string()); + }, + "site.type" => { + request_site_init(&mut request); + request.site.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.web_resource().patch(request, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -370,47 +449,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_site_init(request: &mut api::SiteVerificationWebResourceResource) { - if request.site.is_none() { - request.site = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "owners" => { - if request.owners.is_none() { - request.owners = Some(Default::default()); - } - request.owners.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "site.identifier" => { - request_site_init(&mut request); - request.site.as_mut().unwrap().identifier = Some(value.unwrap_or("").to_string()); - }, - "site.type" => { - request_site_init(&mut request); - request.site.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -427,8 +473,53 @@ impl Engine { fn _web_resource_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::SiteVerificationWebResourceResource::default(); - let mut call = self.hub.web_resource().update(&request, &self.opt.arg_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + fn request_site_init(request: &mut api::SiteVerificationWebResourceResource) { + if request.site.is_none() { + request.site = Some(Default::default()); + } + } + + match &temp_cursor.to_string()[..] { + "owners" => { + if request.owners.is_none() { + request.owners = Some(Default::default()); + } + request.owners.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "site.identifier" => { + request_site_init(&mut request); + request.site.as_mut().unwrap().identifier = Some(value.unwrap_or("").to_string()); + }, + "site.type" => { + request_site_init(&mut request); + request.site.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.web_resource().update(request, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -450,47 +541,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_site_init(request: &mut api::SiteVerificationWebResourceResource) { - if request.site.is_none() { - request.site = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "owners" => { - if request.owners.is_none() { - request.owners = Some(Default::default()); - } - request.owners.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "site.identifier" => { - request_site_init(&mut request); - request.site.as_mut().unwrap().identifier = Some(value.unwrap_or("").to_string()); - }, - "site.type" => { - request_site_init(&mut request); - request.site.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -596,6 +654,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -603,8 +662,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/siteverification1/Cargo.toml b/gen/siteverification1/Cargo.toml index 10679347e6..633b260513 100644 --- a/gen/siteverification1/Cargo.toml +++ b/gen/siteverification1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-siteverification1" -version = "0.1.5+20131007" +version = "0.1.6+20131007" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with siteVerification (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/siteverification1" diff --git a/gen/siteverification1/README.md b/gen/siteverification1/README.md index fd9b31fbde..760db29b23 100644 --- a/gen/siteverification1/README.md +++ b/gen/siteverification1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-siteverification1` library allows access to all features of the *Google siteVerification* service. -This documentation was generated from *siteVerification* crate version *0.1.5+20131007*, where *20131007* is the exact revision of the *siteVerification:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *siteVerification* crate version *0.1.6+20131007*, where *20131007* is the exact revision of the *siteVerification:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *siteVerification* *v1* API can be found at the [official documentation site](https://developers.google.com/site-verification/). @@ -101,21 +101,22 @@ let mut req = SiteVerificationWebResourceResource::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.web_resource().patch(&req, "id") +let result = hub.web_resource().patch(req, "id") .doit(); match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/siteverification1/src/cmn.rs b/gen/siteverification1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/siteverification1/src/cmn.rs +++ b/gen/siteverification1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/siteverification1/src/lib.rs b/gen/siteverification1/src/lib.rs index eeab0f9b26..275c7b6098 100644 --- a/gen/siteverification1/src/lib.rs +++ b/gen/siteverification1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *siteVerification* crate version *0.1.5+20131007*, where *20131007* is the exact revision of the *siteVerification:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *siteVerification* crate version *0.1.6+20131007*, where *20131007* is the exact revision of the *siteVerification:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *siteVerification* *v1* API can be found at the //! [official documentation site](https://developers.google.com/site-verification/). @@ -102,21 +102,22 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.web_resource().patch(&req, "id") +//! let result = hub.web_resource().patch(req, "id") //! .doit(); //! //! match result { //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -204,7 +205,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -281,21 +282,22 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.web_resource().patch(&req, "id") +/// let result = hub.web_resource().patch(req, "id") /// .doit(); /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -316,7 +318,7 @@ impl<'a, C, A> SiteVerification<C, A> SiteVerification { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -325,7 +327,7 @@ impl<'a, C, A> SiteVerification<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -526,10 +528,10 @@ impl<'a, C, A> WebResourceMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The id of a verified site or domain. - pub fn patch(&self, request: &SiteVerificationWebResourceResource, id: &str) -> WebResourcePatchCall<'a, C, A> { + pub fn patch(&self, request: SiteVerificationWebResourceResource, id: &str) -> WebResourcePatchCall<'a, C, A> { WebResourcePatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -573,10 +575,10 @@ impl<'a, C, A> WebResourceMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn get_token(&self, request: &SiteVerificationWebResourceGettokenRequest) -> WebResourceGetTokenCall<'a, C, A> { + pub fn get_token(&self, request: SiteVerificationWebResourceGettokenRequest) -> WebResourceGetTokenCall<'a, C, A> { WebResourceGetTokenCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -591,10 +593,10 @@ impl<'a, C, A> WebResourceMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `id` - The id of a verified site or domain. - pub fn update(&self, request: &SiteVerificationWebResourceResource, id: &str) -> WebResourceUpdateCall<'a, C, A> { + pub fn update(&self, request: SiteVerificationWebResourceResource, id: &str) -> WebResourceUpdateCall<'a, C, A> { WebResourceUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -610,10 +612,10 @@ impl<'a, C, A> WebResourceMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `verificationMethod` - The method to use for verifying a site or domain. - pub fn insert(&self, request: &SiteVerificationWebResourceResource, verification_method: &str) -> WebResourceInsertCall<'a, C, A> { + pub fn insert(&self, request: SiteVerificationWebResourceResource, verification_method: &str) -> WebResourceInsertCall<'a, C, A> { WebResourceInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _verification_method: verification_method.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -775,12 +777,17 @@ impl<'a, C, A> WebResourceGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -789,7 +796,7 @@ impl<'a, C, A> WebResourceGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -896,7 +903,7 @@ impl<'a, C, A> WebResourceGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.web_resource().patch(&req, "id") +/// let result = hub.web_resource().patch(req, "id") /// .doit(); /// # } /// ``` @@ -1024,12 +1031,17 @@ impl<'a, C, A> WebResourcePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1038,7 +1050,7 @@ impl<'a, C, A> WebResourcePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1056,8 +1068,8 @@ impl<'a, C, A> WebResourcePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &SiteVerificationWebResourceResource) -> WebResourcePatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: SiteVerificationWebResourceResource) -> WebResourcePatchCall<'a, C, A> { + self._request = new_value; self } /// The id of a verified site or domain. @@ -1241,12 +1253,17 @@ impl<'a, C, A> WebResourceListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1255,7 +1272,7 @@ impl<'a, C, A> WebResourceListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1464,12 +1481,17 @@ impl<'a, C, A> WebResourceDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -1575,7 +1597,7 @@ impl<'a, C, A> WebResourceDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.web_resource().get_token(&req) +/// let result = hub.web_resource().get_token(req) /// .doit(); /// # } /// ``` @@ -1677,12 +1699,17 @@ impl<'a, C, A> WebResourceGetTokenCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1691,7 +1718,7 @@ impl<'a, C, A> WebResourceGetTokenCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1709,8 +1736,8 @@ impl<'a, C, A> WebResourceGetTokenCall<'a, C, A> where C: BorrowMut<hyper::Clien /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &SiteVerificationWebResourceGettokenRequest) -> WebResourceGetTokenCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: SiteVerificationWebResourceGettokenRequest) -> WebResourceGetTokenCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -1797,7 +1824,7 @@ impl<'a, C, A> WebResourceGetTokenCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.web_resource().update(&req, "id") +/// let result = hub.web_resource().update(req, "id") /// .doit(); /// # } /// ``` @@ -1925,12 +1952,17 @@ impl<'a, C, A> WebResourceUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1939,7 +1971,7 @@ impl<'a, C, A> WebResourceUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1957,8 +1989,8 @@ impl<'a, C, A> WebResourceUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client> /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &SiteVerificationWebResourceResource) -> WebResourceUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: SiteVerificationWebResourceResource) -> WebResourceUpdateCall<'a, C, A> { + self._request = new_value; self } /// The id of a verified site or domain. @@ -2055,7 +2087,7 @@ impl<'a, C, A> WebResourceUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.web_resource().insert(&req, "verificationMethod") +/// let result = hub.web_resource().insert(req, "verificationMethod") /// .doit(); /// # } /// ``` @@ -2159,12 +2191,17 @@ impl<'a, C, A> WebResourceInsertCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2173,7 +2210,7 @@ impl<'a, C, A> WebResourceInsertCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2191,8 +2228,8 @@ impl<'a, C, A> WebResourceInsertCall<'a, C, A> where C: BorrowMut<hyper::Client> /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &SiteVerificationWebResourceResource) -> WebResourceInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: SiteVerificationWebResourceResource) -> WebResourceInsertCall<'a, C, A> { + self._request = new_value; self } /// The method to use for verifying a site or domain. diff --git a/gen/spectrum1_explorer-cli/Cargo.toml b/gen/spectrum1_explorer-cli/Cargo.toml index fcd39aecb4..3cd5c28a05 100644 --- a/gen/spectrum1_explorer-cli/Cargo.toml +++ b/gen/spectrum1_explorer-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-spectrum1_explorer-cli" -version = "0.0.1+20150112" +version = "0.1.0+20150112" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with spectrum (protocol v1explorer)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/spectrum1_explorer-cli" diff --git a/gen/spectrum1_explorer-cli/README.md b/gen/spectrum1_explorer-cli/README.md index 06795b20d8..4b05f938fb 100644 --- a/gen/spectrum1_explorer-cli/README.md +++ b/gen/spectrum1_explorer-cli/README.md @@ -1,4 +1,103 @@ -# HELLO SPECTRUM:V1EXPLORER +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `spectrum1-explorer` command-line interface *(CLI)* allows to use most features of the *Google spectrum* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *spectrum* API at revision *20150112*. The CLI is at version *0.1.0*. + +```bash + spectrum1-explorer [options] paws get-spectrum -r <kv>... [-p <v>...] [-o <out>] + spectrum1-explorer [options] paws get-spectrum-batch -r <kv>... [-p <v>...] [-o <out>] + spectrum1-explorer [options] paws init -r <kv>... [-p <v>...] [-o <out>] + spectrum1-explorer [options] paws notify-spectrum-use -r <kv>... [-p <v>...] [-o <out>] + spectrum1-explorer [options] paws register -r <kv>... [-p <v>...] [-o <out>] + spectrum1-explorer [options] paws verify-device -r <kv>... [-p <v>...] [-o <out>] + spectrum1-explorer --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_spectrum1_explorer_cli/index.html + +Configuration: + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `spectrum1-explorer-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/spectrum1-explorer-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/spectrum1-explorer-secret.json`, assuming that the required *spectrum* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `spectrum1-explorer --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/spectrum1_explorer-cli/mkdocs.yml b/gen/spectrum1_explorer-cli/mkdocs.yml index f03e6fd128..d066650ba1 100644 --- a/gen/spectrum1_explorer-cli/mkdocs.yml +++ b/gen/spectrum1_explorer-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: spectrum v0.0.1+20150112 +site_name: spectrum v0.1.0+20150112 site_url: http://byron.github.io/google-apis-rs/google-spectrum1_explorer-cli site_description: Write integrating applications with bcore diff --git a/gen/spectrum1_explorer-cli/src/cmn.rs b/gen/spectrum1_explorer-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/spectrum1_explorer-cli/src/cmn.rs +++ b/gen/spectrum1_explorer-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/spectrum1_explorer-cli/src/main.rs b/gen/spectrum1_explorer-cli/src/main.rs index 7d9e4eb4f6..5cd26f841d 100644 --- a/gen/spectrum1_explorer-cli/src/main.rs +++ b/gen/spectrum1_explorer-cli/src/main.rs @@ -19,27 +19,28 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - spectrum1-explorer [options] paws get-spectrum -r <kv>... [-p <v>]... [-o <out>] - spectrum1-explorer [options] paws get-spectrum-batch -r <kv>... [-p <v>]... [-o <out>] - spectrum1-explorer [options] paws init -r <kv>... [-p <v>]... [-o <out>] - spectrum1-explorer [options] paws notify-spectrum-use -r <kv>... [-p <v>]... [-o <out>] - spectrum1-explorer [options] paws register -r <kv>... [-p <v>]... [-o <out>] - spectrum1-explorer [options] paws verify-device -r <kv>... [-p <v>]... [-o <out>] + spectrum1-explorer [options] paws get-spectrum -r <kv>... [-p <v>...] [-o <out>] + spectrum1-explorer [options] paws get-spectrum-batch -r <kv>... [-p <v>...] [-o <out>] + spectrum1-explorer [options] paws init -r <kv>... [-p <v>...] [-o <out>] + spectrum1-explorer [options] paws notify-spectrum-use -r <kv>... [-p <v>...] [-o <out>] + spectrum1-explorer [options] paws register -r <kv>... [-p <v>...] [-o <out>] + spectrum1-explorer [options] paws verify-device -r <kv>... [-p <v>...] [-o <out>] spectrum1-explorer --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_spectrum1_explorer_cli/index.html Configuration: --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -61,36 +62,23 @@ struct Engine { impl Engine { fn _paws_get_spectrum(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::PawsGetSpectrumRequest::default(); - let mut call = self.hub.paws().get_spectrum(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::PawsGetSpectrumRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_antenna_init(request: &mut api::PawsGetSpectrumRequest) { if request.antenna.is_none() { request.antenna = Some(Default::default()); @@ -205,7 +193,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "device-desc.etsi-en-device-type" => { request_device_desc_init(&mut request); request.device_desc.as_mut().unwrap().etsi_en_device_type = Some(value.unwrap_or("").to_string()); @@ -421,10 +409,32 @@ impl Engine { request.type_ = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.paws().get_spectrum(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None @@ -446,36 +456,23 @@ impl Engine { fn _paws_get_spectrum_batch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::PawsGetSpectrumBatchRequest::default(); - let mut call = self.hub.paws().get_spectrum_batch(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::PawsGetSpectrumBatchRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_antenna_init(request: &mut api::PawsGetSpectrumBatchRequest) { if request.antenna.is_none() { request.antenna = Some(Default::default()); @@ -570,7 +567,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "device-desc.etsi-en-device-type" => { request_device_desc_init(&mut request); request.device_desc.as_mut().unwrap().etsi_en_device_type = Some(value.unwrap_or("").to_string()); @@ -762,10 +759,32 @@ impl Engine { request.type_ = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.paws().get_spectrum_batch(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None @@ -787,36 +806,23 @@ impl Engine { fn _paws_init(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::PawsInitRequest::default(); - let mut call = self.hub.paws().init(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::PawsInitRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_device_desc_init(request: &mut api::PawsInitRequest) { if request.device_desc.is_none() { request.device_desc = Some(Default::default()); @@ -843,7 +849,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "device-desc.etsi-en-device-type" => { request_device_desc_init(&mut request); request.device_desc.as_mut().unwrap().etsi_en_device_type = Some(value.unwrap_or("").to_string()); @@ -920,10 +926,32 @@ impl Engine { request.version = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.paws().init(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None @@ -945,36 +973,23 @@ impl Engine { fn _paws_notify_spectrum_use(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::PawsNotifySpectrumUseRequest::default(); - let mut call = self.hub.paws().notify_spectrum_use(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::PawsNotifySpectrumUseRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_device_desc_init(request: &mut api::PawsNotifySpectrumUseRequest) { if request.device_desc.is_none() { request.device_desc = Some(Default::default()); @@ -1001,7 +1016,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "device-desc.etsi-en-device-type" => { request_device_desc_init(&mut request); request.device_desc.as_mut().unwrap().etsi_en_device_type = Some(value.unwrap_or("").to_string()); @@ -1078,10 +1093,32 @@ impl Engine { request.version = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.paws().notify_spectrum_use(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None @@ -1103,36 +1140,23 @@ impl Engine { fn _paws_register(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::PawsRegisterRequest::default(); - let mut call = self.hub.paws().register(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::PawsRegisterRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_antenna_init(request: &mut api::PawsRegisterRequest) { if request.antenna.is_none() { request.antenna = Some(Default::default()); @@ -1241,7 +1265,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "device-desc.etsi-en-device-type" => { request_device_desc_init(&mut request); request.device_desc.as_mut().unwrap().etsi_en_device_type = Some(value.unwrap_or("").to_string()); @@ -1410,10 +1434,32 @@ impl Engine { request.type_ = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.paws().register(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None @@ -1435,8 +1481,36 @@ impl Engine { fn _paws_verify_device(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::PawsVerifyDeviceRequest::default(); - let mut call = self.hub.paws().verify_device(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "version" => { + request.version = Some(value.unwrap_or("").to_string()); + }, + "type" => { + request.type_ = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.paws().verify_device(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1458,25 +1532,6 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "version" => { - request.version = Some(value.unwrap_or("").to_string()); - }, - "type" => { - request.type_ = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None @@ -1585,6 +1640,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -1592,8 +1648,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/spectrum1_explorer/Cargo.toml b/gen/spectrum1_explorer/Cargo.toml index b402c2a01f..22a56a81de 100644 --- a/gen/spectrum1_explorer/Cargo.toml +++ b/gen/spectrum1_explorer/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-spectrum1_explorer" -version = "0.1.5+20150112" +version = "0.1.6+20150112" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with spectrum (protocol v1explorer)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/spectrum1_explorer" diff --git a/gen/spectrum1_explorer/README.md b/gen/spectrum1_explorer/README.md index 5be3b49180..dd3ba21f99 100644 --- a/gen/spectrum1_explorer/README.md +++ b/gen/spectrum1_explorer/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-spectrum1_explorer` library allows access to all features of the *Google spectrum* service. -This documentation was generated from *spectrum* crate version *0.1.5+20150112*, where *20150112* is the exact revision of the *spectrum:v1explorer* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *spectrum* crate version *0.1.6+20150112*, where *20150112* is the exact revision of the *spectrum:v1explorer* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *spectrum* *v1_explorer* API can be found at the [official documentation site](http://developers.google.com/spectrum). @@ -98,21 +98,22 @@ let mut req = PawsGetSpectrumBatchRequest::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.paws().get_spectrum_batch(&req) +let result = hub.paws().get_spectrum_batch(req) .doit(); match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/spectrum1_explorer/src/cmn.rs b/gen/spectrum1_explorer/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/spectrum1_explorer/src/cmn.rs +++ b/gen/spectrum1_explorer/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/spectrum1_explorer/src/lib.rs b/gen/spectrum1_explorer/src/lib.rs index 20455de0b6..2060832d1c 100644 --- a/gen/spectrum1_explorer/src/lib.rs +++ b/gen/spectrum1_explorer/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *spectrum* crate version *0.1.5+20150112*, where *20150112* is the exact revision of the *spectrum:v1explorer* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *spectrum* crate version *0.1.6+20150112*, where *20150112* is the exact revision of the *spectrum:v1explorer* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *spectrum* *v1_explorer* API can be found at the //! [official documentation site](http://developers.google.com/spectrum). @@ -99,21 +99,22 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.paws().get_spectrum_batch(&req) +//! let result = hub.paws().get_spectrum_batch(req) //! .doit(); //! //! match result { //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -201,7 +202,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -252,21 +253,22 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.paws().get_spectrum_batch(&req) +/// let result = hub.paws().get_spectrum_batch(req) /// .doit(); /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -287,7 +289,7 @@ impl<'a, C, A> Spectrum<C, A> Spectrum { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -296,7 +298,7 @@ impl<'a, C, A> Spectrum<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -1200,10 +1202,10 @@ impl<'a, C, A> PawMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn notify_spectrum_use(&self, request: &PawsNotifySpectrumUseRequest) -> PawNotifySpectrumUseCall<'a, C, A> { + pub fn notify_spectrum_use(&self, request: PawsNotifySpectrumUseRequest) -> PawNotifySpectrumUseCall<'a, C, A> { PawNotifySpectrumUseCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _additional_params: Default::default(), } @@ -1216,10 +1218,10 @@ impl<'a, C, A> PawMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn register(&self, request: &PawsRegisterRequest) -> PawRegisterCall<'a, C, A> { + pub fn register(&self, request: PawsRegisterRequest) -> PawRegisterCall<'a, C, A> { PawRegisterCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _additional_params: Default::default(), } @@ -1232,10 +1234,10 @@ impl<'a, C, A> PawMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn get_spectrum(&self, request: &PawsGetSpectrumRequest) -> PawGetSpectrumCall<'a, C, A> { + pub fn get_spectrum(&self, request: PawsGetSpectrumRequest) -> PawGetSpectrumCall<'a, C, A> { PawGetSpectrumCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _additional_params: Default::default(), } @@ -1248,10 +1250,10 @@ impl<'a, C, A> PawMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn init(&self, request: &PawsInitRequest) -> PawInitCall<'a, C, A> { + pub fn init(&self, request: PawsInitRequest) -> PawInitCall<'a, C, A> { PawInitCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _additional_params: Default::default(), } @@ -1264,10 +1266,10 @@ impl<'a, C, A> PawMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn get_spectrum_batch(&self, request: &PawsGetSpectrumBatchRequest) -> PawGetSpectrumBatchCall<'a, C, A> { + pub fn get_spectrum_batch(&self, request: PawsGetSpectrumBatchRequest) -> PawGetSpectrumBatchCall<'a, C, A> { PawGetSpectrumBatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _additional_params: Default::default(), } @@ -1280,10 +1282,10 @@ impl<'a, C, A> PawMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn verify_device(&self, request: &PawsVerifyDeviceRequest) -> PawVerifyDeviceCall<'a, C, A> { + pub fn verify_device(&self, request: PawsVerifyDeviceRequest) -> PawVerifyDeviceCall<'a, C, A> { PawVerifyDeviceCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _additional_params: Default::default(), } @@ -1330,7 +1332,7 @@ impl<'a, C, A> PawMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.paws().notify_spectrum_use(&req) +/// let result = hub.paws().notify_spectrum_use(req) /// .doit(); /// # } /// ``` @@ -1425,12 +1427,17 @@ impl<'a, C, A> PawNotifySpectrumUseCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1439,7 +1446,7 @@ impl<'a, C, A> PawNotifySpectrumUseCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1457,8 +1464,8 @@ impl<'a, C, A> PawNotifySpectrumUseCall<'a, C, A> where C: BorrowMut<hyper::Clie /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PawsNotifySpectrumUseRequest) -> PawNotifySpectrumUseCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PawsNotifySpectrumUseRequest) -> PawNotifySpectrumUseCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -1529,7 +1536,7 @@ impl<'a, C, A> PawNotifySpectrumUseCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.paws().register(&req) +/// let result = hub.paws().register(req) /// .doit(); /// # } /// ``` @@ -1624,12 +1631,17 @@ impl<'a, C, A> PawRegisterCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1638,7 +1650,7 @@ impl<'a, C, A> PawRegisterCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1656,8 +1668,8 @@ impl<'a, C, A> PawRegisterCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PawsRegisterRequest) -> PawRegisterCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PawsRegisterRequest) -> PawRegisterCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -1728,7 +1740,7 @@ impl<'a, C, A> PawRegisterCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.paws().get_spectrum(&req) +/// let result = hub.paws().get_spectrum(req) /// .doit(); /// # } /// ``` @@ -1823,12 +1835,17 @@ impl<'a, C, A> PawGetSpectrumCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1837,7 +1854,7 @@ impl<'a, C, A> PawGetSpectrumCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1855,8 +1872,8 @@ impl<'a, C, A> PawGetSpectrumCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PawsGetSpectrumRequest) -> PawGetSpectrumCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PawsGetSpectrumRequest) -> PawGetSpectrumCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -1927,7 +1944,7 @@ impl<'a, C, A> PawGetSpectrumCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.paws().init(&req) +/// let result = hub.paws().init(req) /// .doit(); /// # } /// ``` @@ -2022,12 +2039,17 @@ impl<'a, C, A> PawInitCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2036,7 +2058,7 @@ impl<'a, C, A> PawInitCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2054,8 +2076,8 @@ impl<'a, C, A> PawInitCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PawsInitRequest) -> PawInitCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PawsInitRequest) -> PawInitCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -2126,7 +2148,7 @@ impl<'a, C, A> PawInitCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.paws().get_spectrum_batch(&req) +/// let result = hub.paws().get_spectrum_batch(req) /// .doit(); /// # } /// ``` @@ -2221,12 +2243,17 @@ impl<'a, C, A> PawGetSpectrumBatchCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2235,7 +2262,7 @@ impl<'a, C, A> PawGetSpectrumBatchCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2253,8 +2280,8 @@ impl<'a, C, A> PawGetSpectrumBatchCall<'a, C, A> where C: BorrowMut<hyper::Clien /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PawsGetSpectrumBatchRequest) -> PawGetSpectrumBatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PawsGetSpectrumBatchRequest) -> PawGetSpectrumBatchCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -2325,7 +2352,7 @@ impl<'a, C, A> PawGetSpectrumBatchCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.paws().verify_device(&req) +/// let result = hub.paws().verify_device(req) /// .doit(); /// # } /// ``` @@ -2420,12 +2447,17 @@ impl<'a, C, A> PawVerifyDeviceCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2434,7 +2466,7 @@ impl<'a, C, A> PawVerifyDeviceCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2452,8 +2484,8 @@ impl<'a, C, A> PawVerifyDeviceCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &PawsVerifyDeviceRequest) -> PawVerifyDeviceCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PawsVerifyDeviceRequest) -> PawVerifyDeviceCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong diff --git a/gen/sqladmin1_beta4-cli/Cargo.toml b/gen/sqladmin1_beta4-cli/Cargo.toml index 69ad2ce1dc..dabe8a9000 100644 --- a/gen/sqladmin1_beta4-cli/Cargo.toml +++ b/gen/sqladmin1_beta4-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-sqladmin1_beta4-cli" -version = "0.0.1+20150305" +version = "0.1.0+20150305" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with SQL Admin (protocol v1beta4)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/sqladmin1_beta4-cli" diff --git a/gen/sqladmin1_beta4-cli/README.md b/gen/sqladmin1_beta4-cli/README.md index 3444fb3fd0..e9e026cfee 100644 --- a/gen/sqladmin1_beta4-cli/README.md +++ b/gen/sqladmin1_beta4-cli/README.md @@ -1,4 +1,136 @@ -# HELLO SQLADMIN:V1BETA4 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `sqladmin1-beta4` command-line interface *(CLI)* allows to use most features of the *Google SQL Admin* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *SQL Admin* API at revision *20150305*. The CLI is at version *0.1.0*. + +```bash + sqladmin1-beta4 [options] backup-runs get <project> <instance> <id> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] backup-runs list <project> <instance> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] databases delete <project> <instance> <database> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] databases get <project> <instance> <database> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] databases insert <project> <instance> -r <kv>... [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] databases list <project> <instance> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] databases patch <project> <instance> <database> -r <kv>... [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] databases update <project> <instance> <database> -r <kv>... [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] flags list [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances clone <project> <instance> -r <kv>... [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances delete <project> <instance> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances export <project> <instance> -r <kv>... [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances get <project> <instance> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances import <project> <instance> -r <kv>... [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances insert <project> -r <kv>... [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances list <project> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances patch <project> <instance> -r <kv>... [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances promote-replica <project> <instance> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances reset-ssl-config <project> <instance> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances restart <project> <instance> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances restore-backup <project> <instance> -r <kv>... [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances start-replica <project> <instance> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances stop-replica <project> <instance> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances update <project> <instance> -r <kv>... [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] operations get <project> <operation> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] operations list <project> <instance> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] ssl-certs delete <project> <instance> <sha1-fingerprint> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] ssl-certs get <project> <instance> <sha1-fingerprint> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] ssl-certs insert <project> <instance> -r <kv>... [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] ssl-certs list <project> <instance> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] tiers list <project> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] users delete <project> <instance> <host> <name> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] users insert <project> <instance> -r <kv>... [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] users list <project> <instance> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] users update <project> <instance> <host> <name> -r <kv>... [-p <v>...] [-o <out>] + sqladmin1-beta4 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_sqladmin1_beta4_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `sqladmin1-beta4-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/sqladmin1-beta4-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/sqladmin1-beta4-secret.json`, assuming that the required *sqladmin* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `sqladmin1-beta4 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/sqladmin1_beta4-cli/mkdocs.yml b/gen/sqladmin1_beta4-cli/mkdocs.yml index 8c97be9919..404678187d 100644 --- a/gen/sqladmin1_beta4-cli/mkdocs.yml +++ b/gen/sqladmin1_beta4-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: SQL Admin v0.0.1+20150305 +site_name: SQL Admin v0.1.0+20150305 site_url: http://byron.github.io/google-apis-rs/google-sqladmin1_beta4-cli site_description: Write integrating applications with bcore diff --git a/gen/sqladmin1_beta4-cli/src/cmn.rs b/gen/sqladmin1_beta4-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/sqladmin1_beta4-cli/src/cmn.rs +++ b/gen/sqladmin1_beta4-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/sqladmin1_beta4-cli/src/main.rs b/gen/sqladmin1_beta4-cli/src/main.rs index d25be95365..d12c757197 100644 --- a/gen/sqladmin1_beta4-cli/src/main.rs +++ b/gen/sqladmin1_beta4-cli/src/main.rs @@ -19,60 +19,61 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - sqladmin1-beta4 [options] backup-runs get <project> <instance> <id> [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] backup-runs list <project> <instance> [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] databases delete <project> <instance> <database> [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] databases get <project> <instance> <database> [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] databases insert <project> <instance> -r <kv>... [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] databases list <project> <instance> [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] databases patch <project> <instance> <database> -r <kv>... [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] databases update <project> <instance> <database> -r <kv>... [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] flags list [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] instances clone <project> <instance> -r <kv>... [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] instances delete <project> <instance> [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] instances export <project> <instance> -r <kv>... [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] instances get <project> <instance> [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] instances import <project> <instance> -r <kv>... [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] instances insert <project> -r <kv>... [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] instances list <project> [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] instances patch <project> <instance> -r <kv>... [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] instances promote-replica <project> <instance> [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] instances reset-ssl-config <project> <instance> [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] instances restart <project> <instance> [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] instances restore-backup <project> <instance> -r <kv>... [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] instances start-replica <project> <instance> [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] instances stop-replica <project> <instance> [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] instances update <project> <instance> -r <kv>... [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] operations get <project> <operation> [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] operations list <project> <instance> [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] ssl-certs delete <project> <instance> <sha1-fingerprint> [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] ssl-certs get <project> <instance> <sha1-fingerprint> [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] ssl-certs insert <project> <instance> -r <kv>... [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] ssl-certs list <project> <instance> [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] tiers list <project> [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] users delete <project> <instance> <host> <name> [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] users insert <project> <instance> -r <kv>... [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] users list <project> <instance> [-p <v>]... [-o <out>] - sqladmin1-beta4 [options] users update <project> <instance> <host> <name> -r <kv>... [-p <v>]... [-o <out>] + sqladmin1-beta4 [options] backup-runs get <project> <instance> <id> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] backup-runs list <project> <instance> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] databases delete <project> <instance> <database> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] databases get <project> <instance> <database> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] databases insert <project> <instance> -r <kv>... [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] databases list <project> <instance> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] databases patch <project> <instance> <database> -r <kv>... [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] databases update <project> <instance> <database> -r <kv>... [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] flags list [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances clone <project> <instance> -r <kv>... [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances delete <project> <instance> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances export <project> <instance> -r <kv>... [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances get <project> <instance> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances import <project> <instance> -r <kv>... [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances insert <project> -r <kv>... [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances list <project> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances patch <project> <instance> -r <kv>... [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances promote-replica <project> <instance> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances reset-ssl-config <project> <instance> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances restart <project> <instance> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances restore-backup <project> <instance> -r <kv>... [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances start-replica <project> <instance> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances stop-replica <project> <instance> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] instances update <project> <instance> -r <kv>... [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] operations get <project> <operation> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] operations list <project> <instance> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] ssl-certs delete <project> <instance> <sha1-fingerprint> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] ssl-certs get <project> <instance> <sha1-fingerprint> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] ssl-certs insert <project> <instance> -r <kv>... [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] ssl-certs list <project> <instance> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] tiers list <project> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] users delete <project> <instance> <host> <name> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] users insert <project> <instance> -r <kv>... [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] users list <project> <instance> [-p <v>...] [-o <out>] + sqladmin1-beta4 [options] users update <project> <instance> <host> <name> -r <kv>... [-p <v>...] [-o <out>] sqladmin1-beta4 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_sqladmin1_beta4_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -121,6 +122,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -170,6 +174,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -213,6 +220,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -256,6 +266,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -272,37 +285,24 @@ impl Engine { fn _databases_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Database::default(); - let mut call = self.hub.databases().insert(&request, &self.opt.arg_project, &self.opt.arg_instance); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Database::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -328,15 +328,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.databases().insert(request, &self.opt.arg_project, &self.opt.arg_instance); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -380,6 +405,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -396,37 +424,24 @@ impl Engine { fn _databases_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Database::default(); - let mut call = self.hub.databases().patch(&request, &self.opt.arg_project, &self.opt.arg_instance, &self.opt.arg_database); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Database::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -452,15 +467,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.databases().patch(request, &self.opt.arg_project, &self.opt.arg_instance, &self.opt.arg_database); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -477,37 +517,24 @@ impl Engine { fn _databases_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Database::default(); - let mut call = self.hub.databases().update(&request, &self.opt.arg_project, &self.opt.arg_instance, &self.opt.arg_database); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Database::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -533,15 +560,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.databases().update(request, &self.opt.arg_project, &self.opt.arg_instance, &self.opt.arg_database); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -585,6 +637,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -601,36 +656,23 @@ impl Engine { fn _instances_clone(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::InstancesCloneRequest::default(); - let mut call = self.hub.instances().clone(&request, &self.opt.arg_project, &self.opt.arg_instance); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::InstancesCloneRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_clone_context_bin_log_coordinates_init(request: &mut api::InstancesCloneRequest) { request_clone_context_init(request); if request.clone_context.as_mut().unwrap().bin_log_coordinates.is_none() { @@ -644,7 +686,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "clone-context.bin-log-coordinates.bin-log-position" => { request_clone_context_bin_log_coordinates_init(&mut request); request.clone_context.as_mut().unwrap().bin_log_coordinates.as_mut().unwrap().bin_log_position = Some(value.unwrap_or("").to_string()); @@ -666,15 +708,40 @@ impl Engine { request.clone_context.as_mut().unwrap().destination_instance_name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.instances().clone(request, &self.opt.arg_project, &self.opt.arg_instance); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -718,6 +785,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -734,36 +804,23 @@ impl Engine { fn _instances_export(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::InstancesExportRequest::default(); - let mut call = self.hub.instances().export(&request, &self.opt.arg_project, &self.opt.arg_instance); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::InstancesExportRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_export_context_csv_export_options_init(request: &mut api::InstancesExportRequest) { request_export_context_init(request); if request.export_context.as_mut().unwrap().csv_export_options.is_none() { @@ -784,7 +841,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "export-context.kind" => { request_export_context_init(&mut request); request.export_context.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); @@ -816,15 +873,40 @@ impl Engine { request.export_context.as_mut().unwrap().sql_export_options.as_mut().unwrap().tables.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.instances().export(request, &self.opt.arg_project, &self.opt.arg_instance); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -868,6 +950,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -884,36 +969,23 @@ impl Engine { fn _instances_import(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::InstancesImportRequest::default(); - let mut call = self.hub.instances().import(&request, &self.opt.arg_project, &self.opt.arg_instance); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::InstancesImportRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_import_context_csv_import_options_init(request: &mut api::InstancesImportRequest) { request_import_context_init(request); if request.import_context.as_mut().unwrap().csv_import_options.is_none() { @@ -927,7 +999,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "import-context.file-type" => { request_import_context_init(&mut request); request.import_context.as_mut().unwrap().file_type = Some(value.unwrap_or("").to_string()); @@ -956,33 +1028,11 @@ impl Engine { request.import_context.as_mut().unwrap().csv_import_options.as_mut().unwrap().columns.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _instances_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::DatabaseInstance::default(); - let mut call = self.hub.instances().insert(&request, &self.opt.arg_project); + let mut call = self.hub.instances().import(request, &self.opt.arg_project, &self.opt.arg_instance); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1004,13 +1054,47 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _instances_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::DatabaseInstance::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_on_premises_configuration_init(request: &mut api::DatabaseInstance) { if request.on_premises_configuration.is_none() { request.on_premises_configuration = Some(Default::default()); @@ -1063,7 +1147,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "on-premises-configuration.kind" => { request_on_premises_configuration_init(&mut request); request.on_premises_configuration.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); @@ -1295,15 +1379,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.instances().insert(request, &self.opt.arg_project); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1353,6 +1462,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1369,36 +1481,23 @@ impl Engine { fn _instances_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::DatabaseInstance::default(); - let mut call = self.hub.instances().patch(&request, &self.opt.arg_project, &self.opt.arg_instance); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::DatabaseInstance::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_on_premises_configuration_init(request: &mut api::DatabaseInstance) { if request.on_premises_configuration.is_none() { request.on_premises_configuration = Some(Default::default()); @@ -1451,7 +1550,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "on-premises-configuration.kind" => { request_on_premises_configuration_init(&mut request); request.on_premises_configuration.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); @@ -1683,15 +1782,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.instances().patch(request, &self.opt.arg_project, &self.opt.arg_instance); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1735,6 +1859,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1778,6 +1905,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1821,6 +1951,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1837,8 +1970,44 @@ impl Engine { fn _instances_restore_backup(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::InstancesRestoreBackupRequest::default(); - let mut call = self.hub.instances().restore_backup(&request, &self.opt.arg_project, &self.opt.arg_instance); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + fn request_restore_backup_context_init(request: &mut api::InstancesRestoreBackupRequest) { + if request.restore_backup_context.is_none() { + request.restore_backup_context = Some(Default::default()); + } + } + + match &temp_cursor.to_string()[..] { + "restore-backup-context.kind" => { + request_restore_backup_context_init(&mut request); + request.restore_backup_context.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); + }, + "restore-backup-context.backup-run-id" => { + request_restore_backup_context_init(&mut request); + request.restore_backup_context.as_mut().unwrap().backup_run_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.instances().restore_backup(request, &self.opt.arg_project, &self.opt.arg_instance); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1860,38 +2029,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_restore_backup_context_init(request: &mut api::InstancesRestoreBackupRequest) { - if request.restore_backup_context.is_none() { - request.restore_backup_context = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "restore-backup-context.kind" => { - request_restore_backup_context_init(&mut request); - request.restore_backup_context.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); - }, - "restore-backup-context.backup-run-id" => { - request_restore_backup_context_init(&mut request); - request.restore_backup_context.as_mut().unwrap().backup_run_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1935,6 +2080,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1978,6 +2126,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1994,36 +2145,23 @@ impl Engine { fn _instances_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::DatabaseInstance::default(); - let mut call = self.hub.instances().update(&request, &self.opt.arg_project, &self.opt.arg_instance); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::DatabaseInstance::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_on_premises_configuration_init(request: &mut api::DatabaseInstance) { if request.on_premises_configuration.is_none() { request.on_premises_configuration = Some(Default::default()); @@ -2076,7 +2214,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "on-premises-configuration.kind" => { request_on_premises_configuration_init(&mut request); request.on_premises_configuration.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); @@ -2308,15 +2446,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.instances().update(request, &self.opt.arg_project, &self.opt.arg_instance); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2360,6 +2523,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2409,6 +2575,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2452,6 +2621,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2495,6 +2667,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2511,8 +2686,33 @@ impl Engine { fn _ssl_certs_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::SslCertsInsertRequest::default(); - let mut call = self.hub.ssl_certs().insert(&request, &self.opt.arg_project, &self.opt.arg_instance); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "common-name" => { + request.common_name = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.ssl_certs().insert(request, &self.opt.arg_project, &self.opt.arg_instance); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2534,27 +2734,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "common-name" => { - request.common_name = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2598,6 +2785,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2641,6 +2831,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2684,6 +2877,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2700,37 +2896,24 @@ impl Engine { fn _users_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::User::default(); - let mut call = self.hub.users().insert(&request, &self.opt.arg_project, &self.opt.arg_instance); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::User::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -2753,15 +2936,40 @@ impl Engine { request.password = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.users().insert(request, &self.opt.arg_project, &self.opt.arg_instance); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2805,6 +3013,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2821,37 +3032,24 @@ impl Engine { fn _users_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::User::default(); - let mut call = self.hub.users().update(&request, &self.opt.arg_project, &self.opt.arg_instance, &self.opt.arg_host, &self.opt.arg_name); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::User::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -2874,15 +3072,40 @@ impl Engine { request.password = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.users().update(request, &self.opt.arg_project, &self.opt.arg_instance, &self.opt.arg_host, &self.opt.arg_name); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3079,6 +3302,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -3086,8 +3310,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/sqladmin1_beta4/Cargo.toml b/gen/sqladmin1_beta4/Cargo.toml index 1719e75c72..2f635edc50 100644 --- a/gen/sqladmin1_beta4/Cargo.toml +++ b/gen/sqladmin1_beta4/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-sqladmin1_beta4" -version = "0.1.5+20150305" +version = "0.1.6+20150305" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with SQL Admin (protocol v1beta4)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/sqladmin1_beta4" diff --git a/gen/sqladmin1_beta4/README.md b/gen/sqladmin1_beta4/README.md index c0a8c86c86..6704908abc 100644 --- a/gen/sqladmin1_beta4/README.md +++ b/gen/sqladmin1_beta4/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-sqladmin1_beta4` library allows access to all features of the *Google SQL Admin* service. -This documentation was generated from *SQL Admin* crate version *0.1.5+20150305*, where *20150305* is the exact revision of the *sqladmin:v1beta4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *SQL Admin* crate version *0.1.6+20150305*, where *20150305* is the exact revision of the *sqladmin:v1beta4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *SQL Admin* *v1_beta4* API can be found at the [official documentation site](https://developers.google.com/cloud-sql/docs/admin-api/). @@ -134,21 +134,22 @@ let mut req = User::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.users().update(&req, "project", "instance", "host", "name") +let result = hub.users().update(req, "project", "instance", "host", "name") .doit(); match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/sqladmin1_beta4/src/cmn.rs b/gen/sqladmin1_beta4/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/sqladmin1_beta4/src/cmn.rs +++ b/gen/sqladmin1_beta4/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/sqladmin1_beta4/src/lib.rs b/gen/sqladmin1_beta4/src/lib.rs index 32c9b1a820..a376e0e097 100644 --- a/gen/sqladmin1_beta4/src/lib.rs +++ b/gen/sqladmin1_beta4/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *SQL Admin* crate version *0.1.5+20150305*, where *20150305* is the exact revision of the *sqladmin:v1beta4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *SQL Admin* crate version *0.1.6+20150305*, where *20150305* is the exact revision of the *sqladmin:v1beta4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *SQL Admin* *v1_beta4* API can be found at the //! [official documentation site](https://developers.google.com/cloud-sql/docs/admin-api/). @@ -135,21 +135,22 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.users().update(&req, "project", "instance", "host", "name") +//! let result = hub.users().update(req, "project", "instance", "host", "name") //! .doit(); //! //! match result { //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -237,7 +238,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -314,21 +315,22 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().update(&req, "project", "instance", "host", "name") +/// let result = hub.users().update(req, "project", "instance", "host", "name") /// .doit(); /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -349,7 +351,7 @@ impl<'a, C, A> SQLAdmin<C, A> SQLAdmin { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -379,7 +381,7 @@ impl<'a, C, A> SQLAdmin<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -1739,10 +1741,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// * `instance` - Database instance ID. This does not include the project ID. /// * `host` - Host of the user in the instance. /// * `name` - Name of the user in the instance. - pub fn update(&self, request: &User, project: &str, instance: &str, host: &str, name: &str) -> UserUpdateCall<'a, C, A> { + pub fn update(&self, request: User, project: &str, instance: &str, host: &str, name: &str) -> UserUpdateCall<'a, C, A> { UserUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _instance: instance.to_string(), _host: host.to_string(), @@ -1762,10 +1764,10 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Project ID of the project that contains the instance. /// * `instance` - Database instance ID. This does not include the project ID. - pub fn insert(&self, request: &User, project: &str, instance: &str) -> UserInsertCall<'a, C, A> { + pub fn insert(&self, request: User, project: &str, instance: &str) -> UserInsertCall<'a, C, A> { UserInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _instance: instance.to_string(), _delegate: Default::default(), @@ -1881,10 +1883,10 @@ impl<'a, C, A> InstanceMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Project ID of the project that contains the instance. /// * `instance` - Cloud SQL instance ID. This does not include the project ID. - pub fn patch(&self, request: &DatabaseInstance, project: &str, instance: &str) -> InstancePatchCall<'a, C, A> { + pub fn patch(&self, request: DatabaseInstance, project: &str, instance: &str) -> InstancePatchCall<'a, C, A> { InstancePatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _instance: instance.to_string(), _delegate: Default::default(), @@ -1977,10 +1979,10 @@ impl<'a, C, A> InstanceMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `project` - Project ID of the project to which the newly created Cloud SQL instances should belong. - pub fn insert(&self, request: &DatabaseInstance, project: &str) -> InstanceInsertCall<'a, C, A> { + pub fn insert(&self, request: DatabaseInstance, project: &str) -> InstanceInsertCall<'a, C, A> { InstanceInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -2016,10 +2018,10 @@ impl<'a, C, A> InstanceMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Project ID of the project that contains the instance. /// * `instance` - Cloud SQL instance ID. This does not include the project ID. - pub fn import(&self, request: &InstancesImportRequest, project: &str, instance: &str) -> InstanceImportCall<'a, C, A> { + pub fn import(&self, request: InstancesImportRequest, project: &str, instance: &str) -> InstanceImportCall<'a, C, A> { InstanceImportCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _instance: instance.to_string(), _delegate: Default::default(), @@ -2037,10 +2039,10 @@ impl<'a, C, A> InstanceMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Project ID of the project that contains the instance. /// * `instance` - Cloud SQL instance ID. This does not include the project ID. - pub fn update(&self, request: &DatabaseInstance, project: &str, instance: &str) -> InstanceUpdateCall<'a, C, A> { + pub fn update(&self, request: DatabaseInstance, project: &str, instance: &str) -> InstanceUpdateCall<'a, C, A> { InstanceUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _instance: instance.to_string(), _delegate: Default::default(), @@ -2058,10 +2060,10 @@ impl<'a, C, A> InstanceMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Project ID of the source as well as the clone Cloud SQL instance. /// * `instance` - The ID of the Cloud SQL instance to be cloned (source). This does not include the project ID. - pub fn clone(&self, request: &InstancesCloneRequest, project: &str, instance: &str) -> InstanceCloneCall<'a, C, A> { + pub fn clone(&self, request: InstancesCloneRequest, project: &str, instance: &str) -> InstanceCloneCall<'a, C, A> { InstanceCloneCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _instance: instance.to_string(), _delegate: Default::default(), @@ -2079,10 +2081,10 @@ impl<'a, C, A> InstanceMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Project ID of the project that contains the instance to be exported. /// * `instance` - Cloud SQL instance ID. This does not include the project ID. - pub fn export(&self, request: &InstancesExportRequest, project: &str, instance: &str) -> InstanceExportCall<'a, C, A> { + pub fn export(&self, request: InstancesExportRequest, project: &str, instance: &str) -> InstanceExportCall<'a, C, A> { InstanceExportCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _instance: instance.to_string(), _delegate: Default::default(), @@ -2100,10 +2102,10 @@ impl<'a, C, A> InstanceMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Project ID of the project that contains the instance. /// * `instance` - Cloud SQL instance ID. This does not include the project ID. - pub fn restore_backup(&self, request: &InstancesRestoreBackupRequest, project: &str, instance: &str) -> InstanceRestoreBackupCall<'a, C, A> { + pub fn restore_backup(&self, request: InstancesRestoreBackupRequest, project: &str, instance: &str) -> InstanceRestoreBackupCall<'a, C, A> { InstanceRestoreBackupCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _instance: instance.to_string(), _delegate: Default::default(), @@ -2237,10 +2239,10 @@ impl<'a, C, A> DatabaseMethods<'a, C, A> { /// * `project` - Project ID of the project that contains the instance. /// * `instance` - Database instance ID. This does not include the project ID. /// * `database` - Name of the database to be updated in the instance. - pub fn patch(&self, request: &Database, project: &str, instance: &str, database: &str) -> DatabasePatchCall<'a, C, A> { + pub fn patch(&self, request: Database, project: &str, instance: &str, database: &str) -> DatabasePatchCall<'a, C, A> { DatabasePatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _instance: instance.to_string(), _database: database.to_string(), @@ -2278,10 +2280,10 @@ impl<'a, C, A> DatabaseMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Project ID of the project that contains the instance. /// * `instance` - Database instance ID. This does not include the project ID. - pub fn insert(&self, request: &Database, project: &str, instance: &str) -> DatabaseInsertCall<'a, C, A> { + pub fn insert(&self, request: Database, project: &str, instance: &str) -> DatabaseInsertCall<'a, C, A> { DatabaseInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _instance: instance.to_string(), _delegate: Default::default(), @@ -2321,10 +2323,10 @@ impl<'a, C, A> DatabaseMethods<'a, C, A> { /// * `project` - Project ID of the project that contains the instance. /// * `instance` - Database instance ID. This does not include the project ID. /// * `database` - Name of the database to be updated in the instance. - pub fn update(&self, request: &Database, project: &str, instance: &str, database: &str) -> DatabaseUpdateCall<'a, C, A> { + pub fn update(&self, request: Database, project: &str, instance: &str, database: &str) -> DatabaseUpdateCall<'a, C, A> { DatabaseUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _instance: instance.to_string(), _database: database.to_string(), @@ -2384,10 +2386,10 @@ impl<'a, C, A> SslCertMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - Project ID of the project to which the newly created Cloud SQL instances should belong. /// * `instance` - Cloud SQL instance ID. This does not include the project ID. - pub fn insert(&self, request: &SslCertsInsertRequest, project: &str, instance: &str) -> SslCertInsertCall<'a, C, A> { + pub fn insert(&self, request: SslCertsInsertRequest, project: &str, instance: &str) -> SslCertInsertCall<'a, C, A> { SslCertInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _instance: instance.to_string(), _delegate: Default::default(), @@ -2706,12 +2708,17 @@ impl<'a, C, A> OperationListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2720,7 +2727,7 @@ impl<'a, C, A> OperationListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2966,12 +2973,17 @@ impl<'a, C, A> OperationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2980,7 +2992,7 @@ impl<'a, C, A> OperationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3210,12 +3222,17 @@ impl<'a, C, A> TierListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3224,7 +3241,7 @@ impl<'a, C, A> TierListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3446,12 +3463,17 @@ impl<'a, C, A> UserListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3460,7 +3482,7 @@ impl<'a, C, A> UserListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3696,12 +3718,17 @@ impl<'a, C, A> UserDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3710,7 +3737,7 @@ impl<'a, C, A> UserDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3847,7 +3874,7 @@ impl<'a, C, A> UserDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().update(&req, "project", "instance", "host", "name") +/// let result = hub.users().update(req, "project", "instance", "host", "name") /// .doit(); /// # } /// ``` @@ -3981,12 +4008,17 @@ impl<'a, C, A> UserUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3995,7 +4027,7 @@ impl<'a, C, A> UserUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4013,8 +4045,8 @@ impl<'a, C, A> UserUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &User) -> UserUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: User) -> UserUpdateCall<'a, C, A> { + self._request = new_value; self } /// Project ID of the project that contains the instance. @@ -4141,7 +4173,7 @@ impl<'a, C, A> UserUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().insert(&req, "project", "instance") +/// let result = hub.users().insert(req, "project", "instance") /// .doit(); /// # } /// ``` @@ -4271,12 +4303,17 @@ impl<'a, C, A> UserInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4285,7 +4322,7 @@ impl<'a, C, A> UserInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4303,8 +4340,8 @@ impl<'a, C, A> UserInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &User) -> UserInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: User) -> UserInsertCall<'a, C, A> { + self._request = new_value; self } /// Project ID of the project that contains the instance. @@ -4526,12 +4563,17 @@ impl<'a, C, A> InstanceResetSslConfigCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4540,7 +4582,7 @@ impl<'a, C, A> InstanceResetSslConfigCall<'a, C, A> where C: BorrowMut<hyper::Cl Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4772,12 +4814,17 @@ impl<'a, C, A> InstancePromoteReplicaCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4786,7 +4833,7 @@ impl<'a, C, A> InstancePromoteReplicaCall<'a, C, A> where C: BorrowMut<hyper::Cl Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5018,12 +5065,17 @@ impl<'a, C, A> InstanceGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5032,7 +5084,7 @@ impl<'a, C, A> InstanceGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5149,7 +5201,7 @@ impl<'a, C, A> InstanceGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.instances().patch(&req, "project", "instance") +/// let result = hub.instances().patch(req, "project", "instance") /// .doit(); /// # } /// ``` @@ -5279,12 +5331,17 @@ impl<'a, C, A> InstancePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5293,7 +5350,7 @@ impl<'a, C, A> InstancePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5311,8 +5368,8 @@ impl<'a, C, A> InstancePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &DatabaseInstance) -> InstancePatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: DatabaseInstance) -> InstancePatchCall<'a, C, A> { + self._request = new_value; self } /// Project ID of the project that contains the instance. @@ -5534,12 +5591,17 @@ impl<'a, C, A> InstanceRestartCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5548,7 +5610,7 @@ impl<'a, C, A> InstanceRestartCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5780,12 +5842,17 @@ impl<'a, C, A> InstanceDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5794,7 +5861,7 @@ impl<'a, C, A> InstanceDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6026,12 +6093,17 @@ impl<'a, C, A> InstanceStopReplicaCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6040,7 +6112,7 @@ impl<'a, C, A> InstanceStopReplicaCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6272,12 +6344,17 @@ impl<'a, C, A> InstanceStartReplicaCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6286,7 +6363,7 @@ impl<'a, C, A> InstanceStartReplicaCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6403,7 +6480,7 @@ impl<'a, C, A> InstanceStartReplicaCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.instances().insert(&req, "project") +/// let result = hub.instances().insert(req, "project") /// .doit(); /// # } /// ``` @@ -6531,12 +6608,17 @@ impl<'a, C, A> InstanceInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6545,7 +6627,7 @@ impl<'a, C, A> InstanceInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6563,8 +6645,8 @@ impl<'a, C, A> InstanceInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &DatabaseInstance) -> InstanceInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: DatabaseInstance) -> InstanceInsertCall<'a, C, A> { + self._request = new_value; self } /// Project ID of the project to which the newly created Cloud SQL instances should belong. @@ -6784,12 +6866,17 @@ impl<'a, C, A> InstanceListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6798,7 +6885,7 @@ impl<'a, C, A> InstanceListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6919,7 +7006,7 @@ impl<'a, C, A> InstanceListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.instances().import(&req, "project", "instance") +/// let result = hub.instances().import(req, "project", "instance") /// .doit(); /// # } /// ``` @@ -7049,12 +7136,17 @@ impl<'a, C, A> InstanceImportCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7063,7 +7155,7 @@ impl<'a, C, A> InstanceImportCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7081,8 +7173,8 @@ impl<'a, C, A> InstanceImportCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &InstancesImportRequest) -> InstanceImportCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: InstancesImportRequest) -> InstanceImportCall<'a, C, A> { + self._request = new_value; self } /// Project ID of the project that contains the instance. @@ -7189,7 +7281,7 @@ impl<'a, C, A> InstanceImportCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.instances().update(&req, "project", "instance") +/// let result = hub.instances().update(req, "project", "instance") /// .doit(); /// # } /// ``` @@ -7319,12 +7411,17 @@ impl<'a, C, A> InstanceUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7333,7 +7430,7 @@ impl<'a, C, A> InstanceUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7351,8 +7448,8 @@ impl<'a, C, A> InstanceUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &DatabaseInstance) -> InstanceUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: DatabaseInstance) -> InstanceUpdateCall<'a, C, A> { + self._request = new_value; self } /// Project ID of the project that contains the instance. @@ -7459,7 +7556,7 @@ impl<'a, C, A> InstanceUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.instances().clone(&req, "project", "instance") +/// let result = hub.instances().clone(req, "project", "instance") /// .doit(); /// # } /// ``` @@ -7589,12 +7686,17 @@ impl<'a, C, A> InstanceCloneCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7603,7 +7705,7 @@ impl<'a, C, A> InstanceCloneCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7621,8 +7723,8 @@ impl<'a, C, A> InstanceCloneCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &InstancesCloneRequest) -> InstanceCloneCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: InstancesCloneRequest) -> InstanceCloneCall<'a, C, A> { + self._request = new_value; self } /// Project ID of the source as well as the clone Cloud SQL instance. @@ -7729,7 +7831,7 @@ impl<'a, C, A> InstanceCloneCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.instances().export(&req, "project", "instance") +/// let result = hub.instances().export(req, "project", "instance") /// .doit(); /// # } /// ``` @@ -7859,12 +7961,17 @@ impl<'a, C, A> InstanceExportCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7873,7 +7980,7 @@ impl<'a, C, A> InstanceExportCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7891,8 +7998,8 @@ impl<'a, C, A> InstanceExportCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &InstancesExportRequest) -> InstanceExportCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: InstancesExportRequest) -> InstanceExportCall<'a, C, A> { + self._request = new_value; self } /// Project ID of the project that contains the instance to be exported. @@ -7999,7 +8106,7 @@ impl<'a, C, A> InstanceExportCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.instances().restore_backup(&req, "project", "instance") +/// let result = hub.instances().restore_backup(req, "project", "instance") /// .doit(); /// # } /// ``` @@ -8129,12 +8236,17 @@ impl<'a, C, A> InstanceRestoreBackupCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8143,7 +8255,7 @@ impl<'a, C, A> InstanceRestoreBackupCall<'a, C, A> where C: BorrowMut<hyper::Cli Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8161,8 +8273,8 @@ impl<'a, C, A> InstanceRestoreBackupCall<'a, C, A> where C: BorrowMut<hyper::Cli /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &InstancesRestoreBackupRequest) -> InstanceRestoreBackupCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: InstancesRestoreBackupRequest) -> InstanceRestoreBackupCall<'a, C, A> { + self._request = new_value; self } /// Project ID of the project that contains the instance. @@ -8356,12 +8468,17 @@ impl<'a, C, A> FlagListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8370,7 +8487,7 @@ impl<'a, C, A> FlagListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8584,12 +8701,17 @@ impl<'a, C, A> DatabaseDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8598,7 +8720,7 @@ impl<'a, C, A> DatabaseDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8725,7 +8847,7 @@ impl<'a, C, A> DatabaseDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.databases().patch(&req, "project", "instance", "database") +/// let result = hub.databases().patch(req, "project", "instance", "database") /// .doit(); /// # } /// ``` @@ -8857,12 +8979,17 @@ impl<'a, C, A> DatabasePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8871,7 +8998,7 @@ impl<'a, C, A> DatabasePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8889,8 +9016,8 @@ impl<'a, C, A> DatabasePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Database) -> DatabasePatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Database) -> DatabasePatchCall<'a, C, A> { + self._request = new_value; self } /// Project ID of the project that contains the instance. @@ -9122,12 +9249,17 @@ impl<'a, C, A> DatabaseListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9136,7 +9268,7 @@ impl<'a, C, A> DatabaseListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9253,7 +9385,7 @@ impl<'a, C, A> DatabaseListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.databases().insert(&req, "project", "instance") +/// let result = hub.databases().insert(req, "project", "instance") /// .doit(); /// # } /// ``` @@ -9383,12 +9515,17 @@ impl<'a, C, A> DatabaseInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9397,7 +9534,7 @@ impl<'a, C, A> DatabaseInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9415,8 +9552,8 @@ impl<'a, C, A> DatabaseInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Database) -> DatabaseInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Database) -> DatabaseInsertCall<'a, C, A> { + self._request = new_value; self } /// Project ID of the project that contains the instance. @@ -9640,12 +9777,17 @@ impl<'a, C, A> DatabaseGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9654,7 +9796,7 @@ impl<'a, C, A> DatabaseGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9781,7 +9923,7 @@ impl<'a, C, A> DatabaseGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.databases().update(&req, "project", "instance", "database") +/// let result = hub.databases().update(req, "project", "instance", "database") /// .doit(); /// # } /// ``` @@ -9913,12 +10055,17 @@ impl<'a, C, A> DatabaseUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9927,7 +10074,7 @@ impl<'a, C, A> DatabaseUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9945,8 +10092,8 @@ impl<'a, C, A> DatabaseUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Database) -> DatabaseUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Database) -> DatabaseUpdateCall<'a, C, A> { + self._request = new_value; self } /// Project ID of the project that contains the instance. @@ -10063,7 +10210,7 @@ impl<'a, C, A> DatabaseUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.ssl_certs().insert(&req, "project", "instance") +/// let result = hub.ssl_certs().insert(req, "project", "instance") /// .doit(); /// # } /// ``` @@ -10193,12 +10340,17 @@ impl<'a, C, A> SslCertInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10207,7 +10359,7 @@ impl<'a, C, A> SslCertInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10225,8 +10377,8 @@ impl<'a, C, A> SslCertInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &SslCertsInsertRequest) -> SslCertInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: SslCertsInsertRequest) -> SslCertInsertCall<'a, C, A> { + self._request = new_value; self } /// Project ID of the project to which the newly created Cloud SQL instances should belong. @@ -10450,12 +10602,17 @@ impl<'a, C, A> SslCertDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10464,7 +10621,7 @@ impl<'a, C, A> SslCertDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10708,12 +10865,17 @@ impl<'a, C, A> SslCertGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10722,7 +10884,7 @@ impl<'a, C, A> SslCertGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10964,12 +11126,17 @@ impl<'a, C, A> SslCertListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10978,7 +11145,7 @@ impl<'a, C, A> SslCertListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11220,12 +11387,17 @@ impl<'a, C, A> BackupRunListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11234,7 +11406,7 @@ impl<'a, C, A> BackupRunListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11482,12 +11654,17 @@ impl<'a, C, A> BackupRunGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11496,7 +11673,7 @@ impl<'a, C, A> BackupRunGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/storage1-cli/Cargo.toml b/gen/storage1-cli/Cargo.toml index feec34a55c..ab2b99c112 100644 --- a/gen/storage1-cli/Cargo.toml +++ b/gen/storage1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-storage1-cli" -version = "0.0.1+20150326" +version = "0.1.0+20150326" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with storage (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/storage1-cli" diff --git a/gen/storage1-cli/README.md b/gen/storage1-cli/README.md index fd4488293c..7ebe19a76e 100644 --- a/gen/storage1-cli/README.md +++ b/gen/storage1-cli/README.md @@ -1,4 +1,136 @@ -# HELLO STORAGE:V1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `storage1` command-line interface *(CLI)* allows to use most features of the *Google storage* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *storage* API at revision *20150326*. The CLI is at version *0.1.0*. + +```bash + storage1 [options] bucket-access-controls delete <bucket> <entity> [-p <v>...] + storage1 [options] bucket-access-controls get <bucket> <entity> [-p <v>...] [-o <out>] + storage1 [options] bucket-access-controls insert <bucket> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] bucket-access-controls list <bucket> [-p <v>...] [-o <out>] + storage1 [options] bucket-access-controls patch <bucket> <entity> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] bucket-access-controls update <bucket> <entity> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] buckets delete <bucket> [-p <v>...] + storage1 [options] buckets get <bucket> [-p <v>...] [-o <out>] + storage1 [options] buckets insert <project> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] buckets list <project> [-p <v>...] [-o <out>] + storage1 [options] buckets patch <bucket> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] buckets update <bucket> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] channels stop -r <kv>... [-p <v>...] + storage1 [options] default-object-access-controls delete <bucket> <entity> [-p <v>...] + storage1 [options] default-object-access-controls get <bucket> <entity> [-p <v>...] [-o <out>] + storage1 [options] default-object-access-controls insert <bucket> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] default-object-access-controls list <bucket> [-p <v>...] [-o <out>] + storage1 [options] default-object-access-controls patch <bucket> <entity> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] default-object-access-controls update <bucket> <entity> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] object-access-controls delete <bucket> <object> <entity> [-p <v>...] + storage1 [options] object-access-controls get <bucket> <object> <entity> [-p <v>...] [-o <out>] + storage1 [options] object-access-controls insert <bucket> <object> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] object-access-controls list <bucket> <object> [-p <v>...] [-o <out>] + storage1 [options] object-access-controls patch <bucket> <object> <entity> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] object-access-controls update <bucket> <object> <entity> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] objects compose <destination-bucket> <destination-object> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] objects copy <source-bucket> <source-object> <destination-bucket> <destination-object> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] objects delete <bucket> <object> [-p <v>...] + storage1 [options] objects get <bucket> <object> [-p <v>...] [-o <out>] + storage1 [options] objects insert <bucket> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + storage1 [options] objects list <bucket> [-p <v>...] [-o <out>] + storage1 [options] objects patch <bucket> <object> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] objects rewrite <source-bucket> <source-object> <destination-bucket> <destination-object> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] objects update <bucket> <object> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] objects watch-all <bucket> -r <kv>... [-p <v>...] [-o <out>] + storage1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_storage1_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `storage1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/storage1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/storage1-secret.json`, assuming that the required *storage* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `storage1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/storage1-cli/mkdocs.yml b/gen/storage1-cli/mkdocs.yml index e03db8afcf..c08fdc09fe 100644 --- a/gen/storage1-cli/mkdocs.yml +++ b/gen/storage1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: storage v0.0.1+20150326 +site_name: storage v0.1.0+20150326 site_url: http://byron.github.io/google-apis-rs/google-storage1-cli site_description: Write integrating applications with bcore diff --git a/gen/storage1-cli/src/cmn.rs b/gen/storage1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/storage1-cli/src/cmn.rs +++ b/gen/storage1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/storage1-cli/src/main.rs b/gen/storage1-cli/src/main.rs index c822056b2b..4390ccf1d4 100644 --- a/gen/storage1-cli/src/main.rs +++ b/gen/storage1-cli/src/main.rs @@ -19,60 +19,61 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - storage1 [options] bucket-access-controls delete <bucket> <entity> [-p <v>]... - storage1 [options] bucket-access-controls get <bucket> <entity> [-p <v>]... [-o <out>] - storage1 [options] bucket-access-controls insert <bucket> -r <kv>... [-p <v>]... [-o <out>] - storage1 [options] bucket-access-controls list <bucket> [-p <v>]... [-o <out>] - storage1 [options] bucket-access-controls patch <bucket> <entity> -r <kv>... [-p <v>]... [-o <out>] - storage1 [options] bucket-access-controls update <bucket> <entity> -r <kv>... [-p <v>]... [-o <out>] - storage1 [options] buckets delete <bucket> [-p <v>]... - storage1 [options] buckets get <bucket> [-p <v>]... [-o <out>] - storage1 [options] buckets insert <project> -r <kv>... [-p <v>]... [-o <out>] - storage1 [options] buckets list <project> [-p <v>]... [-o <out>] - storage1 [options] buckets patch <bucket> -r <kv>... [-p <v>]... [-o <out>] - storage1 [options] buckets update <bucket> -r <kv>... [-p <v>]... [-o <out>] - storage1 [options] channels stop -r <kv>... [-p <v>]... - storage1 [options] default-object-access-controls delete <bucket> <entity> [-p <v>]... - storage1 [options] default-object-access-controls get <bucket> <entity> [-p <v>]... [-o <out>] - storage1 [options] default-object-access-controls insert <bucket> -r <kv>... [-p <v>]... [-o <out>] - storage1 [options] default-object-access-controls list <bucket> [-p <v>]... [-o <out>] - storage1 [options] default-object-access-controls patch <bucket> <entity> -r <kv>... [-p <v>]... [-o <out>] - storage1 [options] default-object-access-controls update <bucket> <entity> -r <kv>... [-p <v>]... [-o <out>] - storage1 [options] object-access-controls delete <bucket> <object> <entity> [-p <v>]... - storage1 [options] object-access-controls get <bucket> <object> <entity> [-p <v>]... [-o <out>] - storage1 [options] object-access-controls insert <bucket> <object> -r <kv>... [-p <v>]... [-o <out>] - storage1 [options] object-access-controls list <bucket> <object> [-p <v>]... [-o <out>] - storage1 [options] object-access-controls patch <bucket> <object> <entity> -r <kv>... [-p <v>]... [-o <out>] - storage1 [options] object-access-controls update <bucket> <object> <entity> -r <kv>... [-p <v>]... [-o <out>] - storage1 [options] objects compose <destination-bucket> <destination-object> -r <kv>... [-p <v>]... [-o <out>] - storage1 [options] objects copy <source-bucket> <source-object> <destination-bucket> <destination-object> -r <kv>... [-p <v>]... [-o <out>] - storage1 [options] objects delete <bucket> <object> [-p <v>]... - storage1 [options] objects get <bucket> <object> [-p <v>]... [-o <out>] - storage1 [options] objects insert <bucket> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] - storage1 [options] objects list <bucket> [-p <v>]... [-o <out>] - storage1 [options] objects patch <bucket> <object> -r <kv>... [-p <v>]... [-o <out>] - storage1 [options] objects rewrite <source-bucket> <source-object> <destination-bucket> <destination-object> -r <kv>... [-p <v>]... [-o <out>] - storage1 [options] objects update <bucket> <object> -r <kv>... [-p <v>]... [-o <out>] - storage1 [options] objects watch-all <bucket> -r <kv>... [-p <v>]... [-o <out>] + storage1 [options] bucket-access-controls delete <bucket> <entity> [-p <v>...] + storage1 [options] bucket-access-controls get <bucket> <entity> [-p <v>...] [-o <out>] + storage1 [options] bucket-access-controls insert <bucket> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] bucket-access-controls list <bucket> [-p <v>...] [-o <out>] + storage1 [options] bucket-access-controls patch <bucket> <entity> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] bucket-access-controls update <bucket> <entity> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] buckets delete <bucket> [-p <v>...] + storage1 [options] buckets get <bucket> [-p <v>...] [-o <out>] + storage1 [options] buckets insert <project> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] buckets list <project> [-p <v>...] [-o <out>] + storage1 [options] buckets patch <bucket> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] buckets update <bucket> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] channels stop -r <kv>... [-p <v>...] + storage1 [options] default-object-access-controls delete <bucket> <entity> [-p <v>...] + storage1 [options] default-object-access-controls get <bucket> <entity> [-p <v>...] [-o <out>] + storage1 [options] default-object-access-controls insert <bucket> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] default-object-access-controls list <bucket> [-p <v>...] [-o <out>] + storage1 [options] default-object-access-controls patch <bucket> <entity> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] default-object-access-controls update <bucket> <entity> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] object-access-controls delete <bucket> <object> <entity> [-p <v>...] + storage1 [options] object-access-controls get <bucket> <object> <entity> [-p <v>...] [-o <out>] + storage1 [options] object-access-controls insert <bucket> <object> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] object-access-controls list <bucket> <object> [-p <v>...] [-o <out>] + storage1 [options] object-access-controls patch <bucket> <object> <entity> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] object-access-controls update <bucket> <object> <entity> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] objects compose <destination-bucket> <destination-object> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] objects copy <source-bucket> <source-object> <destination-bucket> <destination-object> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] objects delete <bucket> <object> [-p <v>...] + storage1 [options] objects get <bucket> <object> [-p <v>...] [-o <out>] + storage1 [options] objects insert <bucket> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + storage1 [options] objects list <bucket> [-p <v>...] [-o <out>] + storage1 [options] objects patch <bucket> <object> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] objects rewrite <source-bucket> <source-object> <destination-bucket> <destination-object> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] objects update <bucket> <object> -r <kv>... [-p <v>...] [-o <out>] + storage1 [options] objects watch-all <bucket> -r <kv>... [-p <v>...] [-o <out>] storage1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_storage1_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -121,6 +122,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -162,6 +166,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -178,43 +185,30 @@ impl Engine { fn _bucket_access_controls_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::BucketAccessControl::default(); - let mut call = self.hub.bucket_access_controls().insert(&request, &self.opt.arg_bucket); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::BucketAccessControl::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_project_team_init(request: &mut api::BucketAccessControl) { if request.project_team.is_none() { request.project_team = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "domain" => { request.domain = Some(value.unwrap_or("").to_string()); }, @@ -256,15 +250,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.bucket_access_controls().insert(request, &self.opt.arg_bucket); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -308,6 +327,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -324,43 +346,30 @@ impl Engine { fn _bucket_access_controls_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::BucketAccessControl::default(); - let mut call = self.hub.bucket_access_controls().patch(&request, &self.opt.arg_bucket, &self.opt.arg_entity); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::BucketAccessControl::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_project_team_init(request: &mut api::BucketAccessControl) { if request.project_team.is_none() { request.project_team = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "domain" => { request.domain = Some(value.unwrap_or("").to_string()); }, @@ -402,15 +411,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.bucket_access_controls().patch(request, &self.opt.arg_bucket, &self.opt.arg_entity); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -427,43 +461,30 @@ impl Engine { fn _bucket_access_controls_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::BucketAccessControl::default(); - let mut call = self.hub.bucket_access_controls().update(&request, &self.opt.arg_bucket, &self.opt.arg_entity); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::BucketAccessControl::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_project_team_init(request: &mut api::BucketAccessControl) { if request.project_team.is_none() { request.project_team = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "domain" => { request.domain = Some(value.unwrap_or("").to_string()); }, @@ -505,15 +526,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.bucket_access_controls().update(request, &self.opt.arg_bucket, &self.opt.arg_entity); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -563,6 +609,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -613,6 +662,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -629,45 +681,23 @@ impl Engine { fn _buckets_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Bucket::default(); - let mut call = self.hub.buckets().insert(&request, &self.opt.arg_project); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "projection" => { - call = call.projection(value.unwrap_or("")); - }, - "predefined-default-object-acl" => { - call = call.predefined_default_object_acl(value.unwrap_or("")); - }, - "predefined-acl" => { - call = call.predefined_acl(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Bucket::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_logging_init(request: &mut api::Bucket) { if request.logging.is_none() { request.logging = Some(Default::default()); @@ -692,7 +722,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "website.not-found-page" => { request_website_init(&mut request); request.website.as_mut().unwrap().not_found_page = Some(value.unwrap_or("").to_string()); @@ -762,15 +792,49 @@ impl Engine { request.storage_class = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.buckets().insert(request, &self.opt.arg_project); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "projection" => { + call = call.projection(value.unwrap_or("")); + }, + "predefined-default-object-acl" => { + call = call.predefined_default_object_acl(value.unwrap_or("")); + }, + "predefined-acl" => { + call = call.predefined_acl(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -826,6 +890,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -842,51 +909,23 @@ impl Engine { fn _buckets_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Bucket::default(); - let mut call = self.hub.buckets().patch(&request, &self.opt.arg_bucket); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "projection" => { - call = call.projection(value.unwrap_or("")); - }, - "predefined-default-object-acl" => { - call = call.predefined_default_object_acl(value.unwrap_or("")); - }, - "predefined-acl" => { - call = call.predefined_acl(value.unwrap_or("")); - }, - "if-metageneration-not-match" => { - call = call.if_metageneration_not_match(value.unwrap_or("")); - }, - "if-metageneration-match" => { - call = call.if_metageneration_match(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Bucket::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_logging_init(request: &mut api::Bucket) { if request.logging.is_none() { request.logging = Some(Default::default()); @@ -911,7 +950,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "website.not-found-page" => { request_website_init(&mut request); request.website.as_mut().unwrap().not_found_page = Some(value.unwrap_or("").to_string()); @@ -981,15 +1020,55 @@ impl Engine { request.storage_class = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.buckets().patch(request, &self.opt.arg_bucket); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "projection" => { + call = call.projection(value.unwrap_or("")); + }, + "predefined-default-object-acl" => { + call = call.predefined_default_object_acl(value.unwrap_or("")); + }, + "predefined-acl" => { + call = call.predefined_acl(value.unwrap_or("")); + }, + "if-metageneration-not-match" => { + call = call.if_metageneration_not_match(value.unwrap_or("")); + }, + "if-metageneration-match" => { + call = call.if_metageneration_match(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1006,51 +1085,23 @@ impl Engine { fn _buckets_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Bucket::default(); - let mut call = self.hub.buckets().update(&request, &self.opt.arg_bucket); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "projection" => { - call = call.projection(value.unwrap_or("")); - }, - "predefined-default-object-acl" => { - call = call.predefined_default_object_acl(value.unwrap_or("")); - }, - "predefined-acl" => { - call = call.predefined_acl(value.unwrap_or("")); - }, - "if-metageneration-not-match" => { - call = call.if_metageneration_not_match(value.unwrap_or("")); - }, - "if-metageneration-match" => { - call = call.if_metageneration_match(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Bucket::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_logging_init(request: &mut api::Bucket) { if request.logging.is_none() { request.logging = Some(Default::default()); @@ -1075,7 +1126,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "website.not-found-page" => { request_website_init(&mut request); request.website.as_mut().unwrap().not_found_page = Some(value.unwrap_or("").to_string()); @@ -1145,36 +1196,29 @@ impl Engine { request.storage_class = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _channels_stop(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::Channel::default(); - let mut call = self.hub.channels().stop(&request); + let mut call = self.hub.buckets().update(request, &self.opt.arg_bucket); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "projection" => { + call = call.projection(value.unwrap_or("")); + }, + "predefined-default-object-acl" => { + call = call.predefined_default_object_acl(value.unwrap_or("")); + }, + "predefined-acl" => { + call = call.predefined_acl(value.unwrap_or("")); + }, + "if-metageneration-not-match" => { + call = call.if_metageneration_not_match(value.unwrap_or("")); + }, + "if-metageneration-match" => { + call = call.if_metageneration_match(value.unwrap_or("")); + }, "alt" |"fields" |"key" @@ -1193,14 +1237,48 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _channels_stop(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::Channel::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "resource-uri" => { request.resource_uri = Some(value.unwrap_or("").to_string()); }, @@ -1236,15 +1314,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.channels().stop(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1286,6 +1389,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1327,6 +1433,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1343,43 +1452,30 @@ impl Engine { fn _default_object_access_controls_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::ObjectAccessControl::default(); - let mut call = self.hub.default_object_access_controls().insert(&request, &self.opt.arg_bucket); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ObjectAccessControl::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_project_team_init(request: &mut api::ObjectAccessControl) { if request.project_team.is_none() { request.project_team = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "domain" => { request.domain = Some(value.unwrap_or("").to_string()); }, @@ -1427,15 +1523,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.default_object_access_controls().insert(request, &self.opt.arg_bucket); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1485,6 +1606,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1501,43 +1625,30 @@ impl Engine { fn _default_object_access_controls_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::ObjectAccessControl::default(); - let mut call = self.hub.default_object_access_controls().patch(&request, &self.opt.arg_bucket, &self.opt.arg_entity); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ObjectAccessControl::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_project_team_init(request: &mut api::ObjectAccessControl) { if request.project_team.is_none() { request.project_team = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "domain" => { request.domain = Some(value.unwrap_or("").to_string()); }, @@ -1585,15 +1696,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.default_object_access_controls().patch(request, &self.opt.arg_bucket, &self.opt.arg_entity); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1610,43 +1746,30 @@ impl Engine { fn _default_object_access_controls_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::ObjectAccessControl::default(); - let mut call = self.hub.default_object_access_controls().update(&request, &self.opt.arg_bucket, &self.opt.arg_entity); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ObjectAccessControl::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_project_team_init(request: &mut api::ObjectAccessControl) { if request.project_team.is_none() { request.project_team = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "domain" => { request.domain = Some(value.unwrap_or("").to_string()); }, @@ -1694,15 +1817,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.default_object_access_controls().update(request, &self.opt.arg_bucket, &self.opt.arg_entity); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1749,6 +1897,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1793,6 +1944,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1809,46 +1963,30 @@ impl Engine { fn _object_access_controls_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::ObjectAccessControl::default(); - let mut call = self.hub.object_access_controls().insert(&request, &self.opt.arg_bucket, &self.opt.arg_object); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "generation" => { - call = call.generation(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ObjectAccessControl::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_project_team_init(request: &mut api::ObjectAccessControl) { if request.project_team.is_none() { request.project_team = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "domain" => { request.domain = Some(value.unwrap_or("").to_string()); }, @@ -1896,15 +2034,43 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.object_access_controls().insert(request, &self.opt.arg_bucket, &self.opt.arg_object); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "generation" => { + call = call.generation(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1951,6 +2117,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1967,46 +2136,30 @@ impl Engine { fn _object_access_controls_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::ObjectAccessControl::default(); - let mut call = self.hub.object_access_controls().patch(&request, &self.opt.arg_bucket, &self.opt.arg_object, &self.opt.arg_entity); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "generation" => { - call = call.generation(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ObjectAccessControl::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_project_team_init(request: &mut api::ObjectAccessControl) { if request.project_team.is_none() { request.project_team = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "domain" => { request.domain = Some(value.unwrap_or("").to_string()); }, @@ -2054,15 +2207,43 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.object_access_controls().patch(request, &self.opt.arg_bucket, &self.opt.arg_object, &self.opt.arg_entity); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "generation" => { + call = call.generation(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2079,46 +2260,30 @@ impl Engine { fn _object_access_controls_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::ObjectAccessControl::default(); - let mut call = self.hub.object_access_controls().update(&request, &self.opt.arg_bucket, &self.opt.arg_object, &self.opt.arg_entity); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "generation" => { - call = call.generation(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ObjectAccessControl::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_project_team_init(request: &mut api::ObjectAccessControl) { if request.project_team.is_none() { request.project_team = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "domain" => { request.domain = Some(value.unwrap_or("").to_string()); }, @@ -2166,15 +2331,43 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.object_access_controls().update(request, &self.opt.arg_bucket, &self.opt.arg_object, &self.opt.arg_entity); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "generation" => { + call = call.generation(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2191,49 +2384,23 @@ impl Engine { fn _objects_compose(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::ComposeRequest::default(); - let mut download_mode = false; - let mut call = self.hub.objects().compose(&request, &self.opt.arg_destination_bucket, &self.opt.arg_destination_object); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "if-metageneration-match" => { - call = call.if_metageneration_match(value.unwrap_or("")); - }, - "if-generation-match" => { - call = call.if_generation_match(value.unwrap_or("")); - }, - "destination-predefined-acl" => { - call = call.destination_predefined_acl(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - if key == "alt" && value.unwrap_or("unset") == "media" { - download_mode = true; - } - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ComposeRequest::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_destination_init(request: &mut api::ComposeRequest) { if request.destination.is_none() { request.destination = Some(Default::default()); @@ -2247,7 +2414,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -2352,68 +2519,18 @@ impl Engine { request.destination.as_mut().unwrap().content_disposition = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - if !download_mode { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - } else { - io::copy(&mut response, &mut ostream).unwrap(); - } - None - } - } - } - } - - fn _objects_copy(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::Object::default(); let mut download_mode = false; - let mut call = self.hub.objects().copy(&request, &self.opt.arg_source_bucket, &self.opt.arg_source_object, &self.opt.arg_destination_bucket, &self.opt.arg_destination_object); + let mut call = self.hub.objects().compose(request, &self.opt.arg_destination_bucket, &self.opt.arg_destination_object); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { - "source-generation" => { - call = call.source_generation(value.unwrap_or("")); - }, - "projection" => { - call = call.projection(value.unwrap_or("")); - }, - "if-source-metageneration-not-match" => { - call = call.if_source_metageneration_not_match(value.unwrap_or("")); - }, - "if-source-metageneration-match" => { - call = call.if_source_metageneration_match(value.unwrap_or("")); - }, - "if-source-generation-not-match" => { - call = call.if_source_generation_not_match(value.unwrap_or("")); - }, - "if-source-generation-match" => { - call = call.if_source_generation_match(value.unwrap_or("")); - }, - "if-metageneration-not-match" => { - call = call.if_metageneration_not_match(value.unwrap_or("")); - }, "if-metageneration-match" => { call = call.if_metageneration_match(value.unwrap_or("")); }, - "if-generation-not-match" => { - call = call.if_generation_not_match(value.unwrap_or("")); - }, "if-generation-match" => { call = call.if_generation_match(value.unwrap_or("")); }, @@ -2441,20 +2558,58 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + if !download_mode { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + } else { + io::copy(&mut response, &mut ostream).unwrap(); + } + None + } + } + } + } + + fn _objects_copy(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::Object::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_owner_init(request: &mut api::Object) { if request.owner.is_none() { request.owner = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "self-link" => { request.self_link = Some(value.unwrap_or("").to_string()); }, @@ -2552,15 +2707,77 @@ impl Engine { request.content_disposition = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut download_mode = false; + let mut call = self.hub.objects().copy(request, &self.opt.arg_source_bucket, &self.opt.arg_source_object, &self.opt.arg_destination_bucket, &self.opt.arg_destination_object); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "source-generation" => { + call = call.source_generation(value.unwrap_or("")); + }, + "projection" => { + call = call.projection(value.unwrap_or("")); + }, + "if-source-metageneration-not-match" => { + call = call.if_source_metageneration_not_match(value.unwrap_or("")); + }, + "if-source-metageneration-match" => { + call = call.if_source_metageneration_match(value.unwrap_or("")); + }, + "if-source-generation-not-match" => { + call = call.if_source_generation_not_match(value.unwrap_or("")); + }, + "if-source-generation-match" => { + call = call.if_source_generation_match(value.unwrap_or("")); + }, + "if-metageneration-not-match" => { + call = call.if_metageneration_not_match(value.unwrap_or("")); + }, + "if-metageneration-match" => { + call = call.if_metageneration_match(value.unwrap_or("")); + }, + "if-generation-not-match" => { + call = call.if_generation_not_match(value.unwrap_or("")); + }, + "if-generation-match" => { + call = call.if_generation_match(value.unwrap_or("")); + }, + "destination-predefined-acl" => { + call = call.destination_predefined_acl(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + if key == "alt" && value.unwrap_or("unset") == "media" { + download_mode = true; + } + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2623,6 +2840,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2686,6 +2906,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2706,67 +2929,30 @@ impl Engine { fn _objects_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Object::default(); - let mut call = self.hub.objects().insert(&request, &self.opt.arg_bucket); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "projection" => { - call = call.projection(value.unwrap_or("")); - }, - "predefined-acl" => { - call = call.predefined_acl(value.unwrap_or("")); - }, - "name" => { - call = call.name(value.unwrap_or("")); - }, - "if-metageneration-not-match" => { - call = call.if_metageneration_not_match(value.unwrap_or("")); - }, - "if-metageneration-match" => { - call = call.if_metageneration_match(value.unwrap_or("")); - }, - "if-generation-not-match" => { - call = call.if_generation_not_match(value.unwrap_or("")); - }, - "if-generation-match" => { - call = call.if_generation_match(value.unwrap_or("")); - }, - "content-encoding" => { - call = call.content_encoding(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Object::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_owner_init(request: &mut api::Object) { if request.owner.is_none() { request.owner = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "self-link" => { request.self_link = Some(value.unwrap_or("").to_string()); }, @@ -2864,10 +3050,56 @@ impl Engine { request.content_disposition = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.objects().insert(request, &self.opt.arg_bucket); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "projection" => { + call = call.projection(value.unwrap_or("")); + }, + "predefined-acl" => { + call = call.predefined_acl(value.unwrap_or("")); + }, + "name" => { + call = call.name(value.unwrap_or("")); + }, + "if-metageneration-not-match" => { + call = call.if_metageneration_not_match(value.unwrap_or("")); + }, + "if-metageneration-match" => { + call = call.if_metageneration_match(value.unwrap_or("")); + }, + "if-generation-not-match" => { + call = call.if_generation_not_match(value.unwrap_or("")); + }, + "if-generation-match" => { + call = call.if_generation_match(value.unwrap_or("")); + }, + "content-encoding" => { + call = call.content_encoding(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = if self.opt.cmd_simple { "simple" @@ -2882,6 +3114,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -2945,6 +3180,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2961,64 +3199,30 @@ impl Engine { fn _objects_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Object::default(); - let mut call = self.hub.objects().patch(&request, &self.opt.arg_bucket, &self.opt.arg_object); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "projection" => { - call = call.projection(value.unwrap_or("")); - }, - "predefined-acl" => { - call = call.predefined_acl(value.unwrap_or("")); - }, - "if-metageneration-not-match" => { - call = call.if_metageneration_not_match(value.unwrap_or("")); - }, - "if-metageneration-match" => { - call = call.if_metageneration_match(value.unwrap_or("")); - }, - "if-generation-not-match" => { - call = call.if_generation_not_match(value.unwrap_or("")); - }, - "if-generation-match" => { - call = call.if_generation_match(value.unwrap_or("")); - }, - "generation" => { - call = call.generation(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Object::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_owner_init(request: &mut api::Object) { if request.owner.is_none() { request.owner = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "self-link" => { request.self_link = Some(value.unwrap_or("").to_string()); }, @@ -3116,15 +3320,61 @@ impl Engine { request.content_disposition = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.objects().patch(request, &self.opt.arg_bucket, &self.opt.arg_object); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "projection" => { + call = call.projection(value.unwrap_or("")); + }, + "predefined-acl" => { + call = call.predefined_acl(value.unwrap_or("")); + }, + "if-metageneration-not-match" => { + call = call.if_metageneration_not_match(value.unwrap_or("")); + }, + "if-metageneration-match" => { + call = call.if_metageneration_match(value.unwrap_or("")); + }, + "if-generation-not-match" => { + call = call.if_generation_not_match(value.unwrap_or("")); + }, + "if-generation-match" => { + call = call.if_generation_match(value.unwrap_or("")); + }, + "generation" => { + call = call.generation(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3141,8 +3391,132 @@ impl Engine { fn _objects_rewrite(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Object::default(); - let mut call = self.hub.objects().rewrite(&request, &self.opt.arg_source_bucket, &self.opt.arg_source_object, &self.opt.arg_destination_bucket, &self.opt.arg_destination_object); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + fn request_owner_init(request: &mut api::Object) { + if request.owner.is_none() { + request.owner = Some(Default::default()); + } + } + + match &temp_cursor.to_string()[..] { + "self-link" => { + request.self_link = Some(value.unwrap_or("").to_string()); + }, + "generation" => { + request.generation = Some(value.unwrap_or("").to_string()); + }, + "component-count" => { + request.component_count = Some(arg_from_str(value.unwrap_or("-0"), err, "component-count", "integer")); + }, + "media-link" => { + request.media_link = Some(value.unwrap_or("").to_string()); + }, + "owner.entity-id" => { + request_owner_init(&mut request); + request.owner.as_mut().unwrap().entity_id = Some(value.unwrap_or("").to_string()); + }, + "owner.entity" => { + request_owner_init(&mut request); + request.owner.as_mut().unwrap().entity = Some(value.unwrap_or("").to_string()); + }, + "cache-control" => { + request_owner_init(&mut request); + request.cache_control = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request_owner_init(&mut request); + request.id = Some(value.unwrap_or("").to_string()); + }, + "size" => { + request_owner_init(&mut request); + request.size = Some(value.unwrap_or("").to_string()); + }, + "time-deleted" => { + request_owner_init(&mut request); + request.time_deleted = Some(value.unwrap_or("").to_string()); + }, + "md5-hash" => { + request_owner_init(&mut request); + request.md5_hash = Some(value.unwrap_or("").to_string()); + }, + "crc32c" => { + request_owner_init(&mut request); + request.crc32c = Some(value.unwrap_or("").to_string()); + }, + "etag" => { + request_owner_init(&mut request); + request.etag = Some(value.unwrap_or("").to_string()); + }, + "metadata" => { + request_owner_init(&mut request); + if request.metadata.is_none() { + request.metadata = Some(Default::default()); + } + let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); + request.metadata.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); + }, + "updated" => { + request_owner_init(&mut request); + request.updated = Some(value.unwrap_or("").to_string()); + }, + "content-type" => { + request_owner_init(&mut request); + request.content_type = Some(value.unwrap_or("").to_string()); + }, + "content-language" => { + request_owner_init(&mut request); + request.content_language = Some(value.unwrap_or("").to_string()); + }, + "metageneration" => { + request_owner_init(&mut request); + request.metageneration = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request_owner_init(&mut request); + request.kind = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request_owner_init(&mut request); + request.name = Some(value.unwrap_or("").to_string()); + }, + "bucket" => { + request_owner_init(&mut request); + request.bucket = Some(value.unwrap_or("").to_string()); + }, + "content-encoding" => { + request_owner_init(&mut request); + request.content_encoding = Some(value.unwrap_or("").to_string()); + }, + "storage-class" => { + request_owner_init(&mut request); + request.storage_class = Some(value.unwrap_or("").to_string()); + }, + "content-disposition" => { + request_owner_init(&mut request); + request.content_disposition = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.objects().rewrite(request, &self.opt.arg_source_bucket, &self.opt.arg_source_object, &self.opt.arg_destination_bucket, &self.opt.arg_destination_object); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -3203,20 +3577,54 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _objects_update(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::Object::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_owner_init(request: &mut api::Object) { if request.owner.is_none() { request.owner = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "self-link" => { request.self_link = Some(value.unwrap_or("").to_string()); }, @@ -3314,34 +3722,12 @@ impl Engine { request.content_disposition = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _objects_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::Object::default(); let mut download_mode = false; - let mut call = self.hub.objects().update(&request, &self.opt.arg_bucket, &self.opt.arg_object); + let mut call = self.hub.objects().update(request, &self.opt.arg_bucket, &self.opt.arg_object); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -3387,126 +3773,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_owner_init(request: &mut api::Object) { - if request.owner.is_none() { - request.owner = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "self-link" => { - request.self_link = Some(value.unwrap_or("").to_string()); - }, - "generation" => { - request.generation = Some(value.unwrap_or("").to_string()); - }, - "component-count" => { - request.component_count = Some(arg_from_str(value.unwrap_or("-0"), err, "component-count", "integer")); - }, - "media-link" => { - request.media_link = Some(value.unwrap_or("").to_string()); - }, - "owner.entity-id" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().entity_id = Some(value.unwrap_or("").to_string()); - }, - "owner.entity" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().entity = Some(value.unwrap_or("").to_string()); - }, - "cache-control" => { - request_owner_init(&mut request); - request.cache_control = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request_owner_init(&mut request); - request.id = Some(value.unwrap_or("").to_string()); - }, - "size" => { - request_owner_init(&mut request); - request.size = Some(value.unwrap_or("").to_string()); - }, - "time-deleted" => { - request_owner_init(&mut request); - request.time_deleted = Some(value.unwrap_or("").to_string()); - }, - "md5-hash" => { - request_owner_init(&mut request); - request.md5_hash = Some(value.unwrap_or("").to_string()); - }, - "crc32c" => { - request_owner_init(&mut request); - request.crc32c = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request_owner_init(&mut request); - request.etag = Some(value.unwrap_or("").to_string()); - }, - "metadata" => { - request_owner_init(&mut request); - if request.metadata.is_none() { - request.metadata = Some(Default::default()); - } - let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); - request.metadata.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); - }, - "updated" => { - request_owner_init(&mut request); - request.updated = Some(value.unwrap_or("").to_string()); - }, - "content-type" => { - request_owner_init(&mut request); - request.content_type = Some(value.unwrap_or("").to_string()); - }, - "content-language" => { - request_owner_init(&mut request); - request.content_language = Some(value.unwrap_or("").to_string()); - }, - "metageneration" => { - request_owner_init(&mut request); - request.metageneration = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request_owner_init(&mut request); - request.kind = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request_owner_init(&mut request); - request.name = Some(value.unwrap_or("").to_string()); - }, - "bucket" => { - request_owner_init(&mut request); - request.bucket = Some(value.unwrap_or("").to_string()); - }, - "content-encoding" => { - request_owner_init(&mut request); - request.content_encoding = Some(value.unwrap_or("").to_string()); - }, - "storage-class" => { - request_owner_init(&mut request); - request.storage_class = Some(value.unwrap_or("").to_string()); - }, - "content-disposition" => { - request_owner_init(&mut request); - request.content_disposition = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3527,8 +3801,64 @@ impl Engine { fn _objects_watch_all(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Channel::default(); - let mut call = self.hub.objects().watch_all(&request, &self.opt.arg_bucket); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "resource-uri" => { + request.resource_uri = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "resource-id" => { + request.resource_id = Some(value.unwrap_or("").to_string()); + }, + "payload" => { + request.payload = Some(arg_from_str(value.unwrap_or("false"), err, "payload", "boolean")); + }, + "token" => { + request.token = Some(value.unwrap_or("").to_string()); + }, + "params" => { + if request.params.is_none() { + request.params = Some(Default::default()); + } + let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); + request.params.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); + }, + "expiration" => { + request.expiration = Some(value.unwrap_or("").to_string()); + }, + "address" => { + request.address = Some(value.unwrap_or("").to_string()); + }, + "type" => { + request.type_ = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.objects().watch_all(request, &self.opt.arg_bucket); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -3568,58 +3898,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "resource-uri" => { - request.resource_uri = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "resource-id" => { - request.resource_id = Some(value.unwrap_or("").to_string()); - }, - "payload" => { - request.payload = Some(arg_from_str(value.unwrap_or("false"), err, "payload", "boolean")); - }, - "token" => { - request.token = Some(value.unwrap_or("").to_string()); - }, - "params" => { - if request.params.is_none() { - request.params = Some(Default::default()); - } - let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); - request.params.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); - }, - "expiration" => { - request.expiration = Some(value.unwrap_or("").to_string()); - }, - "address" => { - request.address = Some(value.unwrap_or("").to_string()); - }, - "type" => { - request.type_ = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3806,6 +4092,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -3813,8 +4100,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/storage1/Cargo.toml b/gen/storage1/Cargo.toml index 71e5e3126b..7aeedba8f0 100644 --- a/gen/storage1/Cargo.toml +++ b/gen/storage1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-storage1" -version = "0.1.5+20150326" +version = "0.1.6+20150326" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with storage (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/storage1" diff --git a/gen/storage1/README.md b/gen/storage1/README.md index 74249f20e6..c6e12dbf8b 100644 --- a/gen/storage1/README.md +++ b/gen/storage1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-storage1` library allows access to all features of the *Google storage* service. -This documentation was generated from *storage* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *storage:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *storage* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *storage:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *storage* *v1* API can be found at the [official documentation site](https://developers.google.com/storage/docs/json_api/). @@ -134,7 +134,7 @@ let mut req = Object::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.objects().rewrite(&req, "sourceBucket", "sourceObject", "destinationBucket", "destinationObject") +let result = hub.objects().rewrite(req, "sourceBucket", "sourceObject", "destinationBucket", "destinationObject") .source_generation("et") .rewrite_token("dolores") .projection("kasd") @@ -154,14 +154,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/storage1/src/cmn.rs b/gen/storage1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/storage1/src/cmn.rs +++ b/gen/storage1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/storage1/src/lib.rs b/gen/storage1/src/lib.rs index 6bbae2024b..d3ec828830 100644 --- a/gen/storage1/src/lib.rs +++ b/gen/storage1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *storage* crate version *0.1.5+20150326*, where *20150326* is the exact revision of the *storage:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *storage* crate version *0.1.6+20150326*, where *20150326* is the exact revision of the *storage:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *storage* *v1* API can be found at the //! [official documentation site](https://developers.google.com/storage/docs/json_api/). @@ -135,7 +135,7 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.objects().rewrite(&req, "sourceBucket", "sourceObject", "destinationBucket", "destinationObject") +//! let result = hub.objects().rewrite(req, "sourceBucket", "sourceObject", "destinationBucket", "destinationObject") //! .source_generation("justo") //! .rewrite_token("justo") //! .projection("et") @@ -155,14 +155,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -250,7 +251,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -335,7 +336,7 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.objects().rewrite(&req, "sourceBucket", "sourceObject", "destinationBucket", "destinationObject") +/// let result = hub.objects().rewrite(req, "sourceBucket", "sourceObject", "destinationBucket", "destinationObject") /// .source_generation("elitr") /// .rewrite_token("amet") /// .projection("no") @@ -355,14 +356,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -383,7 +385,7 @@ impl<'a, C, A> Storage<C, A> Storage { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -407,7 +409,7 @@ impl<'a, C, A> Storage<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -1175,10 +1177,10 @@ impl<'a, C, A> DefaultObjectAccessControlMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `bucket` - Name of a bucket. - pub fn insert(&self, request: &ObjectAccessControl, bucket: &str) -> DefaultObjectAccessControlInsertCall<'a, C, A> { + pub fn insert(&self, request: ObjectAccessControl, bucket: &str) -> DefaultObjectAccessControlInsertCall<'a, C, A> { DefaultObjectAccessControlInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _bucket: bucket.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1195,10 +1197,10 @@ impl<'a, C, A> DefaultObjectAccessControlMethods<'a, C, A> { /// * `request` - No description provided. /// * `bucket` - Name of a bucket. /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers. - pub fn update(&self, request: &ObjectAccessControl, bucket: &str, entity: &str) -> DefaultObjectAccessControlUpdateCall<'a, C, A> { + pub fn update(&self, request: ObjectAccessControl, bucket: &str, entity: &str) -> DefaultObjectAccessControlUpdateCall<'a, C, A> { DefaultObjectAccessControlUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _bucket: bucket.to_string(), _entity: entity.to_string(), _delegate: Default::default(), @@ -1235,10 +1237,10 @@ impl<'a, C, A> DefaultObjectAccessControlMethods<'a, C, A> { /// * `request` - No description provided. /// * `bucket` - Name of a bucket. /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers. - pub fn patch(&self, request: &ObjectAccessControl, bucket: &str, entity: &str) -> DefaultObjectAccessControlPatchCall<'a, C, A> { + pub fn patch(&self, request: ObjectAccessControl, bucket: &str, entity: &str) -> DefaultObjectAccessControlPatchCall<'a, C, A> { DefaultObjectAccessControlPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _bucket: bucket.to_string(), _entity: entity.to_string(), _delegate: Default::default(), @@ -1335,10 +1337,10 @@ impl<'a, C, A> BucketAccessControlMethods<'a, C, A> { /// * `request` - No description provided. /// * `bucket` - Name of a bucket. /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers. - pub fn patch(&self, request: &BucketAccessControl, bucket: &str, entity: &str) -> BucketAccessControlPatchCall<'a, C, A> { + pub fn patch(&self, request: BucketAccessControl, bucket: &str, entity: &str) -> BucketAccessControlPatchCall<'a, C, A> { BucketAccessControlPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _bucket: bucket.to_string(), _entity: entity.to_string(), _delegate: Default::default(), @@ -1374,10 +1376,10 @@ impl<'a, C, A> BucketAccessControlMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `bucket` - Name of a bucket. - pub fn insert(&self, request: &BucketAccessControl, bucket: &str) -> BucketAccessControlInsertCall<'a, C, A> { + pub fn insert(&self, request: BucketAccessControl, bucket: &str) -> BucketAccessControlInsertCall<'a, C, A> { BucketAccessControlInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _bucket: bucket.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1413,10 +1415,10 @@ impl<'a, C, A> BucketAccessControlMethods<'a, C, A> { /// * `request` - No description provided. /// * `bucket` - Name of a bucket. /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers. - pub fn update(&self, request: &BucketAccessControl, bucket: &str, entity: &str) -> BucketAccessControlUpdateCall<'a, C, A> { + pub fn update(&self, request: BucketAccessControl, bucket: &str, entity: &str) -> BucketAccessControlUpdateCall<'a, C, A> { BucketAccessControlUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _bucket: bucket.to_string(), _entity: entity.to_string(), _delegate: Default::default(), @@ -1490,10 +1492,10 @@ impl<'a, C, A> ChannelMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn stop(&self, request: &Channel) -> ChannelStopCall<'a, C, A> { + pub fn stop(&self, request: Channel) -> ChannelStopCall<'a, C, A> { ChannelStopCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1552,10 +1554,10 @@ impl<'a, C, A> ObjectMethods<'a, C, A> { /// * `sourceObject` - Name of the source object. /// * `destinationBucket` - Name of the bucket in which to store the new object. Overrides the provided object metadata's bucket value, if any. /// * `destinationObject` - Name of the new object. Required when the object metadata is not otherwise provided. Overrides the object metadata's name value, if any. - pub fn rewrite(&self, request: &Object, source_bucket: &str, source_object: &str, destination_bucket: &str, destination_object: &str) -> ObjectRewriteCall<'a, C, A> { + pub fn rewrite(&self, request: Object, source_bucket: &str, source_object: &str, destination_bucket: &str, destination_object: &str) -> ObjectRewriteCall<'a, C, A> { ObjectRewriteCall { hub: self.hub, - _request: request.clone(), + _request: request, _source_bucket: source_bucket.to_string(), _source_object: source_object.to_string(), _destination_bucket: destination_bucket.to_string(), @@ -1613,10 +1615,10 @@ impl<'a, C, A> ObjectMethods<'a, C, A> { /// * `request` - No description provided. /// * `bucket` - Name of the bucket in which the object resides. /// * `object` - Name of the object. - pub fn update(&self, request: &Object, bucket: &str, object: &str) -> ObjectUpdateCall<'a, C, A> { + pub fn update(&self, request: Object, bucket: &str, object: &str) -> ObjectUpdateCall<'a, C, A> { ObjectUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _bucket: bucket.to_string(), _object: object.to_string(), _projection: Default::default(), @@ -1640,10 +1642,10 @@ impl<'a, C, A> ObjectMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `bucket` - Name of the bucket in which to look for objects. - pub fn watch_all(&self, request: &Channel, bucket: &str) -> ObjectWatchAllCall<'a, C, A> { + pub fn watch_all(&self, request: Channel, bucket: &str) -> ObjectWatchAllCall<'a, C, A> { ObjectWatchAllCall { hub: self.hub, - _request: request.clone(), + _request: request, _bucket: bucket.to_string(), _versions: Default::default(), _projection: Default::default(), @@ -1665,10 +1667,10 @@ impl<'a, C, A> ObjectMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `bucket` - Name of the bucket in which to store the new object. Overrides the provided object metadata's bucket value, if any. - pub fn insert(&self, request: &Object, bucket: &str) -> ObjectInsertCall<'a, C, A> { + pub fn insert(&self, request: Object, bucket: &str) -> ObjectInsertCall<'a, C, A> { ObjectInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _bucket: bucket.to_string(), _projection: Default::default(), _predefined_acl: Default::default(), @@ -1693,10 +1695,10 @@ impl<'a, C, A> ObjectMethods<'a, C, A> { /// * `request` - No description provided. /// * `destinationBucket` - Name of the bucket in which to store the new object. /// * `destinationObject` - Name of the new object. - pub fn compose(&self, request: &ComposeRequest, destination_bucket: &str, destination_object: &str) -> ObjectComposeCall<'a, C, A> { + pub fn compose(&self, request: ComposeRequest, destination_bucket: &str, destination_object: &str) -> ObjectComposeCall<'a, C, A> { ObjectComposeCall { hub: self.hub, - _request: request.clone(), + _request: request, _destination_bucket: destination_bucket.to_string(), _destination_object: destination_object.to_string(), _if_metageneration_match: Default::default(), @@ -1766,10 +1768,10 @@ impl<'a, C, A> ObjectMethods<'a, C, A> { /// * `sourceObject` - Name of the source object. /// * `destinationBucket` - Name of the bucket in which to store the new object. Overrides the provided object metadata's bucket value, if any. /// * `destinationObject` - Name of the new object. Required when the object metadata is not otherwise provided. Overrides the object metadata's name value, if any. - pub fn copy(&self, request: &Object, source_bucket: &str, source_object: &str, destination_bucket: &str, destination_object: &str) -> ObjectCopyCall<'a, C, A> { + pub fn copy(&self, request: Object, source_bucket: &str, source_object: &str, destination_bucket: &str, destination_object: &str) -> ObjectCopyCall<'a, C, A> { ObjectCopyCall { hub: self.hub, - _request: request.clone(), + _request: request, _source_bucket: source_bucket.to_string(), _source_object: source_object.to_string(), _destination_bucket: destination_bucket.to_string(), @@ -1800,10 +1802,10 @@ impl<'a, C, A> ObjectMethods<'a, C, A> { /// * `request` - No description provided. /// * `bucket` - Name of the bucket in which the object resides. /// * `object` - Name of the object. - pub fn patch(&self, request: &Object, bucket: &str, object: &str) -> ObjectPatchCall<'a, C, A> { + pub fn patch(&self, request: Object, bucket: &str, object: &str) -> ObjectPatchCall<'a, C, A> { ObjectPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _bucket: bucket.to_string(), _object: object.to_string(), _projection: Default::default(), @@ -1869,10 +1871,10 @@ impl<'a, C, A> ObjectAccessControlMethods<'a, C, A> { /// * `request` - No description provided. /// * `bucket` - Name of a bucket. /// * `object` - Name of the object. - pub fn insert(&self, request: &ObjectAccessControl, bucket: &str, object: &str) -> ObjectAccessControlInsertCall<'a, C, A> { + pub fn insert(&self, request: ObjectAccessControl, bucket: &str, object: &str) -> ObjectAccessControlInsertCall<'a, C, A> { ObjectAccessControlInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _bucket: bucket.to_string(), _object: object.to_string(), _generation: Default::default(), @@ -1892,10 +1894,10 @@ impl<'a, C, A> ObjectAccessControlMethods<'a, C, A> { /// * `bucket` - Name of a bucket. /// * `object` - Name of the object. /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers. - pub fn patch(&self, request: &ObjectAccessControl, bucket: &str, object: &str, entity: &str) -> ObjectAccessControlPatchCall<'a, C, A> { + pub fn patch(&self, request: ObjectAccessControl, bucket: &str, object: &str, entity: &str) -> ObjectAccessControlPatchCall<'a, C, A> { ObjectAccessControlPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _bucket: bucket.to_string(), _object: object.to_string(), _entity: entity.to_string(), @@ -1980,10 +1982,10 @@ impl<'a, C, A> ObjectAccessControlMethods<'a, C, A> { /// * `bucket` - Name of a bucket. /// * `object` - Name of the object. /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers. - pub fn update(&self, request: &ObjectAccessControl, bucket: &str, object: &str, entity: &str) -> ObjectAccessControlUpdateCall<'a, C, A> { + pub fn update(&self, request: ObjectAccessControl, bucket: &str, object: &str, entity: &str) -> ObjectAccessControlUpdateCall<'a, C, A> { ObjectAccessControlUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _bucket: bucket.to_string(), _object: object.to_string(), _entity: entity.to_string(), @@ -2043,10 +2045,10 @@ impl<'a, C, A> BucketMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `bucket` - Name of a bucket. - pub fn update(&self, request: &Bucket, bucket: &str) -> BucketUpdateCall<'a, C, A> { + pub fn update(&self, request: Bucket, bucket: &str) -> BucketUpdateCall<'a, C, A> { BucketUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _bucket: bucket.to_string(), _projection: Default::default(), _predefined_default_object_acl: Default::default(), @@ -2106,10 +2108,10 @@ impl<'a, C, A> BucketMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `project` - A valid API project identifier. - pub fn insert(&self, request: &Bucket, project: &str) -> BucketInsertCall<'a, C, A> { + pub fn insert(&self, request: Bucket, project: &str) -> BucketInsertCall<'a, C, A> { BucketInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _projection: Default::default(), _predefined_default_object_acl: Default::default(), @@ -2128,10 +2130,10 @@ impl<'a, C, A> BucketMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `bucket` - Name of a bucket. - pub fn patch(&self, request: &Bucket, bucket: &str) -> BucketPatchCall<'a, C, A> { + pub fn patch(&self, request: Bucket, bucket: &str) -> BucketPatchCall<'a, C, A> { BucketPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _bucket: bucket.to_string(), _projection: Default::default(), _predefined_default_object_acl: Default::default(), @@ -2206,7 +2208,7 @@ impl<'a, C, A> BucketMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.default_object_access_controls().insert(&req, "bucket") +/// let result = hub.default_object_access_controls().insert(req, "bucket") /// .doit(); /// # } /// ``` @@ -2334,12 +2336,17 @@ impl<'a, C, A> DefaultObjectAccessControlInsertCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2348,7 +2355,7 @@ impl<'a, C, A> DefaultObjectAccessControlInsertCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2366,8 +2373,8 @@ impl<'a, C, A> DefaultObjectAccessControlInsertCall<'a, C, A> where C: BorrowMut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ObjectAccessControl) -> DefaultObjectAccessControlInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ObjectAccessControl) -> DefaultObjectAccessControlInsertCall<'a, C, A> { + self._request = new_value; self } /// Name of a bucket. @@ -2464,7 +2471,7 @@ impl<'a, C, A> DefaultObjectAccessControlInsertCall<'a, C, A> where C: BorrowMut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.default_object_access_controls().update(&req, "bucket", "entity") +/// let result = hub.default_object_access_controls().update(req, "bucket", "entity") /// .doit(); /// # } /// ``` @@ -2594,12 +2601,17 @@ impl<'a, C, A> DefaultObjectAccessControlUpdateCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2608,7 +2620,7 @@ impl<'a, C, A> DefaultObjectAccessControlUpdateCall<'a, C, A> where C: BorrowMut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2626,8 +2638,8 @@ impl<'a, C, A> DefaultObjectAccessControlUpdateCall<'a, C, A> where C: BorrowMut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ObjectAccessControl) -> DefaultObjectAccessControlUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ObjectAccessControl) -> DefaultObjectAccessControlUpdateCall<'a, C, A> { + self._request = new_value; self } /// Name of a bucket. @@ -2857,12 +2869,17 @@ impl<'a, C, A> DefaultObjectAccessControlListCall<'a, C, A> where C: BorrowMut<h if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2871,7 +2888,7 @@ impl<'a, C, A> DefaultObjectAccessControlListCall<'a, C, A> where C: BorrowMut<h Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2992,7 +3009,7 @@ impl<'a, C, A> DefaultObjectAccessControlListCall<'a, C, A> where C: BorrowMut<h /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.default_object_access_controls().patch(&req, "bucket", "entity") +/// let result = hub.default_object_access_controls().patch(req, "bucket", "entity") /// .doit(); /// # } /// ``` @@ -3122,12 +3139,17 @@ impl<'a, C, A> DefaultObjectAccessControlPatchCall<'a, C, A> where C: BorrowMut< if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3136,7 +3158,7 @@ impl<'a, C, A> DefaultObjectAccessControlPatchCall<'a, C, A> where C: BorrowMut< Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3154,8 +3176,8 @@ impl<'a, C, A> DefaultObjectAccessControlPatchCall<'a, C, A> where C: BorrowMut< /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ObjectAccessControl) -> DefaultObjectAccessControlPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ObjectAccessControl) -> DefaultObjectAccessControlPatchCall<'a, C, A> { + self._request = new_value; self } /// Name of a bucket. @@ -3376,12 +3398,17 @@ impl<'a, C, A> DefaultObjectAccessControlDeleteCall<'a, C, A> where C: BorrowMut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -3612,12 +3639,17 @@ impl<'a, C, A> DefaultObjectAccessControlGetCall<'a, C, A> where C: BorrowMut<hy if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3626,7 +3658,7 @@ impl<'a, C, A> DefaultObjectAccessControlGetCall<'a, C, A> where C: BorrowMut<hy Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3743,7 +3775,7 @@ impl<'a, C, A> DefaultObjectAccessControlGetCall<'a, C, A> where C: BorrowMut<hy /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.bucket_access_controls().patch(&req, "bucket", "entity") +/// let result = hub.bucket_access_controls().patch(req, "bucket", "entity") /// .doit(); /// # } /// ``` @@ -3873,12 +3905,17 @@ impl<'a, C, A> BucketAccessControlPatchCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3887,7 +3924,7 @@ impl<'a, C, A> BucketAccessControlPatchCall<'a, C, A> where C: BorrowMut<hyper:: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3905,8 +3942,8 @@ impl<'a, C, A> BucketAccessControlPatchCall<'a, C, A> where C: BorrowMut<hyper:: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &BucketAccessControl) -> BucketAccessControlPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: BucketAccessControl) -> BucketAccessControlPatchCall<'a, C, A> { + self._request = new_value; self } /// Name of a bucket. @@ -4127,12 +4164,17 @@ impl<'a, C, A> BucketAccessControlDeleteCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -4248,7 +4290,7 @@ impl<'a, C, A> BucketAccessControlDeleteCall<'a, C, A> where C: BorrowMut<hyper: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.bucket_access_controls().insert(&req, "bucket") +/// let result = hub.bucket_access_controls().insert(req, "bucket") /// .doit(); /// # } /// ``` @@ -4376,12 +4418,17 @@ impl<'a, C, A> BucketAccessControlInsertCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4390,7 +4437,7 @@ impl<'a, C, A> BucketAccessControlInsertCall<'a, C, A> where C: BorrowMut<hyper: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4408,8 +4455,8 @@ impl<'a, C, A> BucketAccessControlInsertCall<'a, C, A> where C: BorrowMut<hyper: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &BucketAccessControl) -> BucketAccessControlInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: BucketAccessControl) -> BucketAccessControlInsertCall<'a, C, A> { + self._request = new_value; self } /// Name of a bucket. @@ -4621,12 +4668,17 @@ impl<'a, C, A> BucketAccessControlGetCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4635,7 +4687,7 @@ impl<'a, C, A> BucketAccessControlGetCall<'a, C, A> where C: BorrowMut<hyper::Cl Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4752,7 +4804,7 @@ impl<'a, C, A> BucketAccessControlGetCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.bucket_access_controls().update(&req, "bucket", "entity") +/// let result = hub.bucket_access_controls().update(req, "bucket", "entity") /// .doit(); /// # } /// ``` @@ -4882,12 +4934,17 @@ impl<'a, C, A> BucketAccessControlUpdateCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4896,7 +4953,7 @@ impl<'a, C, A> BucketAccessControlUpdateCall<'a, C, A> where C: BorrowMut<hyper: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4914,8 +4971,8 @@ impl<'a, C, A> BucketAccessControlUpdateCall<'a, C, A> where C: BorrowMut<hyper: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &BucketAccessControl) -> BucketAccessControlUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: BucketAccessControl) -> BucketAccessControlUpdateCall<'a, C, A> { + self._request = new_value; self } /// Name of a bucket. @@ -5135,12 +5192,17 @@ impl<'a, C, A> BucketAccessControlListCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5149,7 +5211,7 @@ impl<'a, C, A> BucketAccessControlListCall<'a, C, A> where C: BorrowMut<hyper::C Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5256,7 +5318,7 @@ impl<'a, C, A> BucketAccessControlListCall<'a, C, A> where C: BorrowMut<hyper::C /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.channels().stop(&req) +/// let result = hub.channels().stop(req) /// .doit(); /// # } /// ``` @@ -5357,12 +5419,17 @@ impl<'a, C, A> ChannelStopCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -5379,8 +5446,8 @@ impl<'a, C, A> ChannelStopCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Channel) -> ChannelStopCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Channel) -> ChannelStopCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -5467,7 +5534,7 @@ impl<'a, C, A> ChannelStopCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.objects().rewrite(&req, "sourceBucket", "sourceObject", "destinationBucket", "destinationObject") +/// let result = hub.objects().rewrite(req, "sourceBucket", "sourceObject", "destinationBucket", "destinationObject") /// .source_generation("vero") /// .rewrite_token("sadipscing") /// .projection("invidunt") @@ -5666,12 +5733,17 @@ impl<'a, C, A> ObjectRewriteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5680,7 +5752,7 @@ impl<'a, C, A> ObjectRewriteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5698,8 +5770,8 @@ impl<'a, C, A> ObjectRewriteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Object) -> ObjectRewriteCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Object) -> ObjectRewriteCall<'a, C, A> { + self._request = new_value; self } /// Name of the bucket in which to find the source object. @@ -6083,12 +6155,17 @@ impl<'a, C, A> ObjectGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = if enable_resource_parsing { let mut json_response = String::new(); @@ -6097,7 +6174,7 @@ impl<'a, C, A> ObjectGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } } else { (res, Default::default()) }; @@ -6261,7 +6338,7 @@ impl<'a, C, A> ObjectGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.objects().update(&req, "bucket", "object") +/// let result = hub.objects().update(req, "bucket", "object") /// .projection("nonumy") /// .predefined_acl("sed") /// .if_metageneration_not_match("aliquyam") @@ -6442,12 +6519,17 @@ impl<'a, C, A> ObjectUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = if enable_resource_parsing { let mut json_response = String::new(); @@ -6456,7 +6538,7 @@ impl<'a, C, A> ObjectUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } } else { (res, Default::default()) }; @@ -6474,8 +6556,8 @@ impl<'a, C, A> ObjectUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Object) -> ObjectUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Object) -> ObjectUpdateCall<'a, C, A> { + self._request = new_value; self } /// Name of the bucket in which the object resides. @@ -6631,7 +6713,7 @@ impl<'a, C, A> ObjectUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.objects().watch_all(&req, "bucket") +/// let result = hub.objects().watch_all(req, "bucket") /// .versions(true) /// .projection("gubergren") /// .prefix("aliquyam") @@ -6789,12 +6871,17 @@ impl<'a, C, A> ObjectWatchAllCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6803,7 +6890,7 @@ impl<'a, C, A> ObjectWatchAllCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6821,8 +6908,8 @@ impl<'a, C, A> ObjectWatchAllCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Channel) -> ObjectWatchAllCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Channel) -> ObjectWatchAllCall<'a, C, A> { + self._request = new_value; self } /// Name of the bucket in which to look for objects. @@ -6967,7 +7054,7 @@ impl<'a, C, A> ObjectWatchAllCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.objects().insert(&req, "bucket") +/// let result = hub.objects().insert(req, "bucket") /// .projection("ipsum") /// .predefined_acl("aliquyam") /// .name("dolores") @@ -7069,14 +7156,15 @@ impl<'a, C, A> ObjectInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: params.push(("alt", "json".to_string())); } - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/storage/v1/b/{bucket}/o".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/storage/v1/b/{bucket}/o".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/storage/v1/b/{bucket}/o".to_string() + ("https://www.googleapis.com/resumable/upload/storage/v1/b/{bucket}/o".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); } @@ -7193,12 +7281,17 @@ impl<'a, C, A> ObjectInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -7206,9 +7299,9 @@ impl<'a, C, A> ObjectInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -7218,7 +7311,7 @@ impl<'a, C, A> ObjectInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -7249,7 +7342,7 @@ impl<'a, C, A> ObjectInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } } else { (res, Default::default()) }; @@ -7293,8 +7386,8 @@ impl<'a, C, A> ObjectInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Object) -> ObjectInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Object) -> ObjectInsertCall<'a, C, A> { + self._request = new_value; self } /// Name of the bucket in which to store the new object. Overrides the provided object metadata's bucket value, if any. @@ -7452,7 +7545,7 @@ impl<'a, C, A> ObjectInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.objects().compose(&req, "destinationBucket", "destinationObject") +/// let result = hub.objects().compose(req, "destinationBucket", "destinationObject") /// .if_metageneration_match("clita") /// .if_generation_match("diam") /// .destination_predefined_acl("justo") @@ -7613,12 +7706,17 @@ impl<'a, C, A> ObjectComposeCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = if enable_resource_parsing { let mut json_response = String::new(); @@ -7627,7 +7725,7 @@ impl<'a, C, A> ObjectComposeCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } } else { (res, Default::default()) }; @@ -7645,8 +7743,8 @@ impl<'a, C, A> ObjectComposeCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ComposeRequest) -> ObjectComposeCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ComposeRequest) -> ObjectComposeCall<'a, C, A> { + self._request = new_value; self } /// Name of the bucket in which to store the new object. @@ -7913,12 +8011,17 @@ impl<'a, C, A> ObjectDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -8212,12 +8315,17 @@ impl<'a, C, A> ObjectListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8226,7 +8334,7 @@ impl<'a, C, A> ObjectListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8380,7 +8488,7 @@ impl<'a, C, A> ObjectListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.objects().copy(&req, "sourceBucket", "sourceObject", "destinationBucket", "destinationObject") +/// let result = hub.objects().copy(req, "sourceBucket", "sourceObject", "destinationBucket", "destinationObject") /// .source_generation("Lorem") /// .projection("clita") /// .if_source_metageneration_not_match("invidunt") @@ -8585,12 +8693,17 @@ impl<'a, C, A> ObjectCopyCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = if enable_resource_parsing { let mut json_response = String::new(); @@ -8599,7 +8712,7 @@ impl<'a, C, A> ObjectCopyCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } } else { (res, Default::default()) }; @@ -8617,8 +8730,8 @@ impl<'a, C, A> ObjectCopyCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Object) -> ObjectCopyCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Object) -> ObjectCopyCall<'a, C, A> { + self._request = new_value; self } /// Name of the bucket in which to find the source object. @@ -8822,7 +8935,7 @@ impl<'a, C, A> ObjectCopyCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.objects().patch(&req, "bucket", "object") +/// let result = hub.objects().patch(req, "bucket", "object") /// .projection("Lorem") /// .predefined_acl("Lorem") /// .if_metageneration_not_match("diam") @@ -8987,12 +9100,17 @@ impl<'a, C, A> ObjectPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9001,7 +9119,7 @@ impl<'a, C, A> ObjectPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9019,8 +9137,8 @@ impl<'a, C, A> ObjectPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Object) -> ObjectPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Object) -> ObjectPatchCall<'a, C, A> { + self._request = new_value; self } /// Name of the bucket in which the object resides. @@ -9176,7 +9294,7 @@ impl<'a, C, A> ObjectPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.object_access_controls().insert(&req, "bucket", "object") +/// let result = hub.object_access_controls().insert(req, "bucket", "object") /// .generation("sea") /// .doit(); /// # } @@ -9311,12 +9429,17 @@ impl<'a, C, A> ObjectAccessControlInsertCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9325,7 +9448,7 @@ impl<'a, C, A> ObjectAccessControlInsertCall<'a, C, A> where C: BorrowMut<hyper: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9343,8 +9466,8 @@ impl<'a, C, A> ObjectAccessControlInsertCall<'a, C, A> where C: BorrowMut<hyper: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ObjectAccessControl) -> ObjectAccessControlInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ObjectAccessControl) -> ObjectAccessControlInsertCall<'a, C, A> { + self._request = new_value; self } /// Name of a bucket. @@ -9458,7 +9581,7 @@ impl<'a, C, A> ObjectAccessControlInsertCall<'a, C, A> where C: BorrowMut<hyper: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.object_access_controls().patch(&req, "bucket", "object", "entity") +/// let result = hub.object_access_controls().patch(req, "bucket", "object", "entity") /// .generation("voluptua.") /// .doit(); /// # } @@ -9595,12 +9718,17 @@ impl<'a, C, A> ObjectAccessControlPatchCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9609,7 +9737,7 @@ impl<'a, C, A> ObjectAccessControlPatchCall<'a, C, A> where C: BorrowMut<hyper:: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9627,8 +9755,8 @@ impl<'a, C, A> ObjectAccessControlPatchCall<'a, C, A> where C: BorrowMut<hyper:: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ObjectAccessControl) -> ObjectAccessControlPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ObjectAccessControl) -> ObjectAccessControlPatchCall<'a, C, A> { + self._request = new_value; self } /// Name of a bucket. @@ -9872,12 +10000,17 @@ impl<'a, C, A> ObjectAccessControlListCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9886,7 +10019,7 @@ impl<'a, C, A> ObjectAccessControlListCall<'a, C, A> where C: BorrowMut<hyper::C Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10131,12 +10264,17 @@ impl<'a, C, A> ObjectAccessControlDeleteCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -10391,12 +10529,17 @@ impl<'a, C, A> ObjectAccessControlGetCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10405,7 +10548,7 @@ impl<'a, C, A> ObjectAccessControlGetCall<'a, C, A> where C: BorrowMut<hyper::Cl Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10539,7 +10682,7 @@ impl<'a, C, A> ObjectAccessControlGetCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.object_access_controls().update(&req, "bucket", "object", "entity") +/// let result = hub.object_access_controls().update(req, "bucket", "object", "entity") /// .generation("nonumy") /// .doit(); /// # } @@ -10676,12 +10819,17 @@ impl<'a, C, A> ObjectAccessControlUpdateCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10690,7 +10838,7 @@ impl<'a, C, A> ObjectAccessControlUpdateCall<'a, C, A> where C: BorrowMut<hyper: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10708,8 +10856,8 @@ impl<'a, C, A> ObjectAccessControlUpdateCall<'a, C, A> where C: BorrowMut<hyper: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ObjectAccessControl) -> ObjectAccessControlUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ObjectAccessControl) -> ObjectAccessControlUpdateCall<'a, C, A> { + self._request = new_value; self } /// Name of a bucket. @@ -10833,7 +10981,7 @@ impl<'a, C, A> ObjectAccessControlUpdateCall<'a, C, A> where C: BorrowMut<hyper: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.buckets().update(&req, "bucket") +/// let result = hub.buckets().update(req, "bucket") /// .projection("sed") /// .predefined_default_object_acl("no") /// .predefined_acl("invidunt") @@ -10986,12 +11134,17 @@ impl<'a, C, A> BucketUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11000,7 +11153,7 @@ impl<'a, C, A> BucketUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11018,8 +11171,8 @@ impl<'a, C, A> BucketUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Bucket) -> BucketUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Bucket) -> BucketUpdateCall<'a, C, A> { + self._request = new_value; self } /// Name of a bucket. @@ -11279,12 +11432,17 @@ impl<'a, C, A> BucketGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11293,7 +11451,7 @@ impl<'a, C, A> BucketGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11543,12 +11701,17 @@ impl<'a, C, A> BucketDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -11668,7 +11831,7 @@ impl<'a, C, A> BucketDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.buckets().insert(&req, "project") +/// let result = hub.buckets().insert(req, "project") /// .projection("diam") /// .predefined_default_object_acl("accusam") /// .predefined_acl("dolores") @@ -11787,12 +11950,17 @@ impl<'a, C, A> BucketInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11801,7 +11969,7 @@ impl<'a, C, A> BucketInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11819,8 +11987,8 @@ impl<'a, C, A> BucketInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Bucket) -> BucketInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Bucket) -> BucketInsertCall<'a, C, A> { + self._request = new_value; self } /// A valid API project identifier. @@ -11938,7 +12106,7 @@ impl<'a, C, A> BucketInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.buckets().patch(&req, "bucket") +/// let result = hub.buckets().patch(req, "bucket") /// .projection("dolor") /// .predefined_default_object_acl("aliquyam") /// .predefined_acl("elitr") @@ -12091,12 +12259,17 @@ impl<'a, C, A> BucketPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12105,7 +12278,7 @@ impl<'a, C, A> BucketPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12123,8 +12296,8 @@ impl<'a, C, A> BucketPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Bucket) -> BucketPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Bucket) -> BucketPatchCall<'a, C, A> { + self._request = new_value; self } /// Name of a bucket. @@ -12365,12 +12538,17 @@ impl<'a, C, A> BucketListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12379,7 +12557,7 @@ impl<'a, C, A> BucketListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/tagmanager1-cli/Cargo.toml b/gen/tagmanager1-cli/Cargo.toml index fec8c34906..e484797a32 100644 --- a/gen/tagmanager1-cli/Cargo.toml +++ b/gen/tagmanager1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-tagmanager1-cli" -version = "0.0.1+20150121" +version = "0.1.0+20150121" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with Tag Manager (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/tagmanager1-cli" diff --git a/gen/tagmanager1-cli/README.md b/gen/tagmanager1-cli/README.md index 1fcc018979..3845151fc5 100644 --- a/gen/tagmanager1-cli/README.md +++ b/gen/tagmanager1-cli/README.md @@ -1,4 +1,147 @@ -# HELLO TAGMANAGER:V1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `tagmanager1` command-line interface *(CLI)* allows to use most features of the *Google Tag Manager* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *Tag Manager* API at revision *20150121*. The CLI is at version *0.1.0*. + +```bash + tagmanager1 [options] accounts containers-create <account-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-delete <account-id> <container-id> [-p <v>...] + tagmanager1 [options] accounts containers-get <account-id> <container-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-list <account-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-macros-create <account-id> <container-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-macros-delete <account-id> <container-id> <macro-id> [-p <v>...] + tagmanager1 [options] accounts containers-macros-get <account-id> <container-id> <macro-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-macros-list <account-id> <container-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-macros-update <account-id> <container-id> <macro-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-rules-create <account-id> <container-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-rules-delete <account-id> <container-id> <rule-id> [-p <v>...] + tagmanager1 [options] accounts containers-rules-get <account-id> <container-id> <rule-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-rules-list <account-id> <container-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-rules-update <account-id> <container-id> <rule-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-tags-create <account-id> <container-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-tags-delete <account-id> <container-id> <tag-id> [-p <v>...] + tagmanager1 [options] accounts containers-tags-get <account-id> <container-id> <tag-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-tags-list <account-id> <container-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-tags-update <account-id> <container-id> <tag-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-triggers-create <account-id> <container-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-triggers-delete <account-id> <container-id> <trigger-id> [-p <v>...] + tagmanager1 [options] accounts containers-triggers-get <account-id> <container-id> <trigger-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-triggers-list <account-id> <container-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-triggers-update <account-id> <container-id> <trigger-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-update <account-id> <container-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-variables-create <account-id> <container-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-variables-delete <account-id> <container-id> <variable-id> [-p <v>...] + tagmanager1 [options] accounts containers-variables-get <account-id> <container-id> <variable-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-variables-list <account-id> <container-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-variables-update <account-id> <container-id> <variable-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-versions-create <account-id> <container-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-versions-delete <account-id> <container-id> <container-version-id> [-p <v>...] + tagmanager1 [options] accounts containers-versions-get <account-id> <container-id> <container-version-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-versions-list <account-id> <container-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-versions-publish <account-id> <container-id> <container-version-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-versions-restore <account-id> <container-id> <container-version-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-versions-undelete <account-id> <container-id> <container-version-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-versions-update <account-id> <container-id> <container-version-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts get <account-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts list [-p <v>...] [-o <out>] + tagmanager1 [options] accounts permissions-create <account-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts permissions-delete <account-id> <permission-id> [-p <v>...] + tagmanager1 [options] accounts permissions-get <account-id> <permission-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts permissions-list <account-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts permissions-update <account-id> <permission-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts update <account-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_tagmanager1_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `tagmanager1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/tagmanager1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/tagmanager1-secret.json`, assuming that the required *tagmanager* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `tagmanager1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/tagmanager1-cli/mkdocs.yml b/gen/tagmanager1-cli/mkdocs.yml index 5344c3a6d5..ac7cda7588 100644 --- a/gen/tagmanager1-cli/mkdocs.yml +++ b/gen/tagmanager1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Tag Manager v0.0.1+20150121 +site_name: Tag Manager v0.1.0+20150121 site_url: http://byron.github.io/google-apis-rs/google-tagmanager1-cli site_description: Write integrating applications with bcore diff --git a/gen/tagmanager1-cli/src/cmn.rs b/gen/tagmanager1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/tagmanager1-cli/src/cmn.rs +++ b/gen/tagmanager1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/tagmanager1-cli/src/main.rs b/gen/tagmanager1-cli/src/main.rs index f9f4422d65..c649ab231e 100644 --- a/gen/tagmanager1-cli/src/main.rs +++ b/gen/tagmanager1-cli/src/main.rs @@ -19,71 +19,72 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - tagmanager1 [options] accounts containers-create <account-id> -r <kv>... [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-delete <account-id> <container-id> [-p <v>]... - tagmanager1 [options] accounts containers-get <account-id> <container-id> [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-list <account-id> [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-macros-create <account-id> <container-id> -r <kv>... [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-macros-delete <account-id> <container-id> <macro-id> [-p <v>]... - tagmanager1 [options] accounts containers-macros-get <account-id> <container-id> <macro-id> [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-macros-list <account-id> <container-id> [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-macros-update <account-id> <container-id> <macro-id> -r <kv>... [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-rules-create <account-id> <container-id> -r <kv>... [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-rules-delete <account-id> <container-id> <rule-id> [-p <v>]... - tagmanager1 [options] accounts containers-rules-get <account-id> <container-id> <rule-id> [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-rules-list <account-id> <container-id> [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-rules-update <account-id> <container-id> <rule-id> -r <kv>... [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-tags-create <account-id> <container-id> -r <kv>... [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-tags-delete <account-id> <container-id> <tag-id> [-p <v>]... - tagmanager1 [options] accounts containers-tags-get <account-id> <container-id> <tag-id> [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-tags-list <account-id> <container-id> [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-tags-update <account-id> <container-id> <tag-id> -r <kv>... [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-triggers-create <account-id> <container-id> -r <kv>... [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-triggers-delete <account-id> <container-id> <trigger-id> [-p <v>]... - tagmanager1 [options] accounts containers-triggers-get <account-id> <container-id> <trigger-id> [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-triggers-list <account-id> <container-id> [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-triggers-update <account-id> <container-id> <trigger-id> -r <kv>... [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-update <account-id> <container-id> -r <kv>... [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-variables-create <account-id> <container-id> -r <kv>... [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-variables-delete <account-id> <container-id> <variable-id> [-p <v>]... - tagmanager1 [options] accounts containers-variables-get <account-id> <container-id> <variable-id> [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-variables-list <account-id> <container-id> [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-variables-update <account-id> <container-id> <variable-id> -r <kv>... [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-versions-create <account-id> <container-id> -r <kv>... [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-versions-delete <account-id> <container-id> <container-version-id> [-p <v>]... - tagmanager1 [options] accounts containers-versions-get <account-id> <container-id> <container-version-id> [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-versions-list <account-id> <container-id> [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-versions-publish <account-id> <container-id> <container-version-id> [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-versions-restore <account-id> <container-id> <container-version-id> [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-versions-undelete <account-id> <container-id> <container-version-id> [-p <v>]... [-o <out>] - tagmanager1 [options] accounts containers-versions-update <account-id> <container-id> <container-version-id> -r <kv>... [-p <v>]... [-o <out>] - tagmanager1 [options] accounts get <account-id> [-p <v>]... [-o <out>] - tagmanager1 [options] accounts list [-p <v>]... [-o <out>] - tagmanager1 [options] accounts permissions-create <account-id> -r <kv>... [-p <v>]... [-o <out>] - tagmanager1 [options] accounts permissions-delete <account-id> <permission-id> [-p <v>]... - tagmanager1 [options] accounts permissions-get <account-id> <permission-id> [-p <v>]... [-o <out>] - tagmanager1 [options] accounts permissions-list <account-id> [-p <v>]... [-o <out>] - tagmanager1 [options] accounts permissions-update <account-id> <permission-id> -r <kv>... [-p <v>]... [-o <out>] - tagmanager1 [options] accounts update <account-id> -r <kv>... [-p <v>]... [-o <out>] + tagmanager1 [options] accounts containers-create <account-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-delete <account-id> <container-id> [-p <v>...] + tagmanager1 [options] accounts containers-get <account-id> <container-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-list <account-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-macros-create <account-id> <container-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-macros-delete <account-id> <container-id> <macro-id> [-p <v>...] + tagmanager1 [options] accounts containers-macros-get <account-id> <container-id> <macro-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-macros-list <account-id> <container-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-macros-update <account-id> <container-id> <macro-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-rules-create <account-id> <container-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-rules-delete <account-id> <container-id> <rule-id> [-p <v>...] + tagmanager1 [options] accounts containers-rules-get <account-id> <container-id> <rule-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-rules-list <account-id> <container-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-rules-update <account-id> <container-id> <rule-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-tags-create <account-id> <container-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-tags-delete <account-id> <container-id> <tag-id> [-p <v>...] + tagmanager1 [options] accounts containers-tags-get <account-id> <container-id> <tag-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-tags-list <account-id> <container-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-tags-update <account-id> <container-id> <tag-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-triggers-create <account-id> <container-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-triggers-delete <account-id> <container-id> <trigger-id> [-p <v>...] + tagmanager1 [options] accounts containers-triggers-get <account-id> <container-id> <trigger-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-triggers-list <account-id> <container-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-triggers-update <account-id> <container-id> <trigger-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-update <account-id> <container-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-variables-create <account-id> <container-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-variables-delete <account-id> <container-id> <variable-id> [-p <v>...] + tagmanager1 [options] accounts containers-variables-get <account-id> <container-id> <variable-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-variables-list <account-id> <container-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-variables-update <account-id> <container-id> <variable-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-versions-create <account-id> <container-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-versions-delete <account-id> <container-id> <container-version-id> [-p <v>...] + tagmanager1 [options] accounts containers-versions-get <account-id> <container-id> <container-version-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-versions-list <account-id> <container-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-versions-publish <account-id> <container-id> <container-version-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-versions-restore <account-id> <container-id> <container-version-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-versions-undelete <account-id> <container-id> <container-version-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts containers-versions-update <account-id> <container-id> <container-version-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts get <account-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts list [-p <v>...] [-o <out>] + tagmanager1 [options] accounts permissions-create <account-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts permissions-delete <account-id> <permission-id> [-p <v>...] + tagmanager1 [options] accounts permissions-get <account-id> <permission-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts permissions-list <account-id> [-p <v>...] [-o <out>] + tagmanager1 [options] accounts permissions-update <account-id> <permission-id> -r <kv>... [-p <v>...] [-o <out>] + tagmanager1 [options] accounts update <account-id> -r <kv>... [-p <v>...] [-o <out>] tagmanager1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_tagmanager1_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -105,37 +106,24 @@ struct Engine { impl Engine { fn _accounts_containers_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Container::default(); - let mut call = self.hub.accounts().containers_create(&request, &self.opt.arg_account_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Container::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "time-zone-id" => { request.time_zone_id = Some(value.unwrap_or("").to_string()); }, @@ -179,15 +167,40 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.accounts().containers_create(request, &self.opt.arg_account_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -231,6 +244,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -272,6 +288,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -315,6 +334,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -331,37 +353,24 @@ impl Engine { fn _accounts_containers_macros_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Macro::default(); - let mut call = self.hub.accounts().containers_macros_create(&request, &self.opt.arg_account_id, &self.opt.arg_container_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Macro::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "schedule-start-ms" => { request.schedule_start_ms = Some(value.unwrap_or("").to_string()); }, @@ -402,15 +411,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.accounts().containers_macros_create(request, &self.opt.arg_account_id, &self.opt.arg_container_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -454,6 +488,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -495,6 +532,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -538,6 +578,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -554,40 +597,24 @@ impl Engine { fn _accounts_containers_macros_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Macro::default(); - let mut call = self.hub.accounts().containers_macros_update(&request, &self.opt.arg_account_id, &self.opt.arg_container_id, &self.opt.arg_macro_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "fingerprint" => { - call = call.fingerprint(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Macro::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "schedule-start-ms" => { request.schedule_start_ms = Some(value.unwrap_or("").to_string()); }, @@ -628,15 +655,43 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.accounts().containers_macros_update(request, &self.opt.arg_account_id, &self.opt.arg_container_id, &self.opt.arg_macro_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "fingerprint" => { + call = call.fingerprint(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -653,8 +708,48 @@ impl Engine { fn _accounts_containers_rules_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Rule::default(); - let mut call = self.hub.accounts().containers_rules_create(&request, &self.opt.arg_account_id, &self.opt.arg_container_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "container-id" => { + request.container_id = Some(value.unwrap_or("").to_string()); + }, + "rule-id" => { + request.rule_id = Some(value.unwrap_or("").to_string()); + }, + "notes" => { + request.notes = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + "fingerprint" => { + request.fingerprint = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request.account_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.accounts().containers_rules_create(request, &self.opt.arg_account_id, &self.opt.arg_container_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -676,42 +771,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "container-id" => { - request.container_id = Some(value.unwrap_or("").to_string()); - }, - "rule-id" => { - request.rule_id = Some(value.unwrap_or("").to_string()); - }, - "notes" => { - request.notes = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "fingerprint" => { - request.fingerprint = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request.account_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -755,6 +822,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -796,6 +866,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -839,6 +912,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -855,8 +931,48 @@ impl Engine { fn _accounts_containers_rules_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Rule::default(); - let mut call = self.hub.accounts().containers_rules_update(&request, &self.opt.arg_account_id, &self.opt.arg_container_id, &self.opt.arg_rule_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "container-id" => { + request.container_id = Some(value.unwrap_or("").to_string()); + }, + "rule-id" => { + request.rule_id = Some(value.unwrap_or("").to_string()); + }, + "notes" => { + request.notes = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + "fingerprint" => { + request.fingerprint = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request.account_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.accounts().containers_rules_update(request, &self.opt.arg_account_id, &self.opt.arg_container_id, &self.opt.arg_rule_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -881,42 +997,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "container-id" => { - request.container_id = Some(value.unwrap_or("").to_string()); - }, - "rule-id" => { - request.rule_id = Some(value.unwrap_or("").to_string()); - }, - "notes" => { - request.notes = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "fingerprint" => { - request.fingerprint = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request.account_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -933,43 +1021,30 @@ impl Engine { fn _accounts_containers_tags_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Tag::default(); - let mut call = self.hub.accounts().containers_tags_create(&request, &self.opt.arg_account_id, &self.opt.arg_container_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Tag::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_priority_init(request: &mut api::Tag) { if request.priority.is_none() { request.priority = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "schedule-start-ms" => { request.schedule_start_ms = Some(value.unwrap_or("").to_string()); }, @@ -1045,15 +1120,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.accounts().containers_tags_create(request, &self.opt.arg_account_id, &self.opt.arg_container_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1097,6 +1197,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1138,6 +1241,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1181,6 +1287,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1197,46 +1306,30 @@ impl Engine { fn _accounts_containers_tags_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Tag::default(); - let mut call = self.hub.accounts().containers_tags_update(&request, &self.opt.arg_account_id, &self.opt.arg_container_id, &self.opt.arg_tag_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "fingerprint" => { - call = call.fingerprint(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Tag::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_priority_init(request: &mut api::Tag) { if request.priority.is_none() { request.priority = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "schedule-start-ms" => { request.schedule_start_ms = Some(value.unwrap_or("").to_string()); }, @@ -1312,36 +1405,17 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_triggers_create(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::Trigger::default(); - let mut call = self.hub.accounts().containers_triggers_create(&request, &self.opt.arg_account_id, &self.opt.arg_container_id); + let mut call = self.hub.accounts().containers_tags_update(request, &self.opt.arg_account_id, &self.opt.arg_container_id, &self.opt.arg_tag_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "fingerprint" => { + call = call.fingerprint(value.unwrap_or("")); + }, "alt" |"fields" |"key" @@ -1360,13 +1434,47 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _accounts_containers_triggers_create(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::Trigger::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_check_validation_init(request: &mut api::Trigger) { if request.check_validation.is_none() { request.check_validation = Some(Default::default()); @@ -1421,7 +1529,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "video-percentage-list.type" => { request_video_percentage_list_init(&mut request); request.video_percentage_list.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); @@ -1555,15 +1663,40 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.accounts().containers_triggers_create(request, &self.opt.arg_account_id, &self.opt.arg_container_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1607,6 +1740,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1648,6 +1784,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1691,6 +1830,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1707,39 +1849,23 @@ impl Engine { fn _accounts_containers_triggers_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Trigger::default(); - let mut call = self.hub.accounts().containers_triggers_update(&request, &self.opt.arg_account_id, &self.opt.arg_container_id, &self.opt.arg_trigger_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "fingerprint" => { - call = call.fingerprint(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Trigger::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_check_validation_init(request: &mut api::Trigger) { if request.check_validation.is_none() { request.check_validation = Some(Default::default()); @@ -1794,7 +1920,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "video-percentage-list.type" => { request_video_percentage_list_init(&mut request); request.video_percentage_list.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); @@ -1928,33 +2054,11 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::Container::default(); - let mut call = self.hub.accounts().containers_update(&request, &self.opt.arg_account_id, &self.opt.arg_container_id); + let mut call = self.hub.accounts().containers_triggers_update(request, &self.opt.arg_account_id, &self.opt.arg_container_id, &self.opt.arg_trigger_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1979,14 +2083,48 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _accounts_containers_update(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::Container::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "time-zone-id" => { request.time_zone_id = Some(value.unwrap_or("").to_string()); }, @@ -2030,36 +2168,17 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_variables_create(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::Variable::default(); - let mut call = self.hub.accounts().containers_variables_create(&request, &self.opt.arg_account_id, &self.opt.arg_container_id); + let mut call = self.hub.accounts().containers_update(request, &self.opt.arg_account_id, &self.opt.arg_container_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "fingerprint" => { + call = call.fingerprint(value.unwrap_or("")); + }, "alt" |"fields" |"key" @@ -2078,14 +2197,48 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _accounts_containers_variables_create(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::Variable::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "schedule-start-ms" => { request.schedule_start_ms = Some(value.unwrap_or("").to_string()); }, @@ -2126,15 +2279,40 @@ impl Engine { request.container_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.accounts().containers_variables_create(request, &self.opt.arg_account_id, &self.opt.arg_container_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2178,6 +2356,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2219,6 +2400,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2262,6 +2446,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2278,40 +2465,24 @@ impl Engine { fn _accounts_containers_variables_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Variable::default(); - let mut call = self.hub.accounts().containers_variables_update(&request, &self.opt.arg_account_id, &self.opt.arg_container_id, &self.opt.arg_variable_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "fingerprint" => { - call = call.fingerprint(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Variable::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "schedule-start-ms" => { request.schedule_start_ms = Some(value.unwrap_or("").to_string()); }, @@ -2352,15 +2523,43 @@ impl Engine { request.container_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.accounts().containers_variables_update(request, &self.opt.arg_account_id, &self.opt.arg_container_id, &self.opt.arg_variable_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "fingerprint" => { + call = call.fingerprint(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2377,8 +2576,39 @@ impl Engine { fn _accounts_containers_versions_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::CreateContainerVersionRequestVersionOptions::default(); - let mut call = self.hub.accounts().containers_versions_create(&request, &self.opt.arg_account_id, &self.opt.arg_container_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "notes" => { + request.notes = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + "quick-preview" => { + request.quick_preview = Some(arg_from_str(value.unwrap_or("false"), err, "quick-preview", "boolean")); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.accounts().containers_versions_create(request, &self.opt.arg_account_id, &self.opt.arg_container_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2400,33 +2630,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "notes" => { - request.notes = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "quick-preview" => { - request.quick_preview = Some(arg_from_str(value.unwrap_or("false"), err, "quick-preview", "boolean")); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2470,6 +2681,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2511,6 +2725,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2557,6 +2774,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2603,6 +2823,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2646,6 +2869,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2689,6 +2915,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2705,46 +2934,30 @@ impl Engine { fn _accounts_containers_versions_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::ContainerVersion::default(); - let mut call = self.hub.accounts().containers_versions_update(&request, &self.opt.arg_account_id, &self.opt.arg_container_id, &self.opt.arg_container_version_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "fingerprint" => { - call = call.fingerprint(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ContainerVersion::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_container_init(request: &mut api::ContainerVersion) { if request.container.is_none() { request.container = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "container.time-zone-id" => { request_container_init(&mut request); request.container.as_mut().unwrap().time_zone_id = Some(value.unwrap_or("").to_string()); @@ -2827,15 +3040,43 @@ impl Engine { request.account_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.accounts().containers_versions_update(request, &self.opt.arg_account_id, &self.opt.arg_container_id, &self.opt.arg_container_version_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "fingerprint" => { + call = call.fingerprint(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2879,6 +3120,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2922,6 +3166,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2938,8 +3185,55 @@ impl Engine { fn _accounts_permissions_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::UserAccess::default(); - let mut call = self.hub.accounts().permissions_create(&request, &self.opt.arg_account_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + fn request_account_access_init(request: &mut api::UserAccess) { + if request.account_access.is_none() { + request.account_access = Some(Default::default()); + } + } + + match &temp_cursor.to_string()[..] { + "account-access.permission" => { + request_account_access_init(&mut request); + if request.account_access.as_mut().unwrap().permission.is_none() { + request.account_access.as_mut().unwrap().permission = Some(Default::default()); + } + request.account_access.as_mut().unwrap().permission.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "email-address" => { + request_account_access_init(&mut request); + request.email_address = Some(value.unwrap_or("").to_string()); + }, + "permission-id" => { + request_account_access_init(&mut request); + request.permission_id = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request_account_access_init(&mut request); + request.account_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.accounts().permissions_create(request, &self.opt.arg_account_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -2961,49 +3255,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_account_access_init(request: &mut api::UserAccess) { - if request.account_access.is_none() { - request.account_access = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "account-access.permission" => { - request_account_access_init(&mut request); - if request.account_access.as_mut().unwrap().permission.is_none() { - request.account_access.as_mut().unwrap().permission = Some(Default::default()); - } - request.account_access.as_mut().unwrap().permission.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "email-address" => { - request_account_access_init(&mut request); - request.email_address = Some(value.unwrap_or("").to_string()); - }, - "permission-id" => { - request_account_access_init(&mut request); - request.permission_id = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request_account_access_init(&mut request); - request.account_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3047,6 +3306,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -3088,6 +3350,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3131,6 +3396,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3147,8 +3415,55 @@ impl Engine { fn _accounts_permissions_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::UserAccess::default(); - let mut call = self.hub.accounts().permissions_update(&request, &self.opt.arg_account_id, &self.opt.arg_permission_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + fn request_account_access_init(request: &mut api::UserAccess) { + if request.account_access.is_none() { + request.account_access = Some(Default::default()); + } + } + + match &temp_cursor.to_string()[..] { + "account-access.permission" => { + request_account_access_init(&mut request); + if request.account_access.as_mut().unwrap().permission.is_none() { + request.account_access.as_mut().unwrap().permission = Some(Default::default()); + } + request.account_access.as_mut().unwrap().permission.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "email-address" => { + request_account_access_init(&mut request); + request.email_address = Some(value.unwrap_or("").to_string()); + }, + "permission-id" => { + request_account_access_init(&mut request); + request.permission_id = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request_account_access_init(&mut request); + request.account_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.accounts().permissions_update(request, &self.opt.arg_account_id, &self.opt.arg_permission_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -3170,49 +3485,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_account_access_init(request: &mut api::UserAccess) { - if request.account_access.is_none() { - request.account_access = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "account-access.permission" => { - request_account_access_init(&mut request); - if request.account_access.as_mut().unwrap().permission.is_none() { - request.account_access.as_mut().unwrap().permission = Some(Default::default()); - } - request.account_access.as_mut().unwrap().permission.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "email-address" => { - request_account_access_init(&mut request); - request.email_address = Some(value.unwrap_or("").to_string()); - }, - "permission-id" => { - request_account_access_init(&mut request); - request.permission_id = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request_account_access_init(&mut request); - request.account_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3229,8 +3509,42 @@ impl Engine { fn _accounts_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::Account::default(); - let mut call = self.hub.accounts().update(&request, &self.opt.arg_account_id); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "share-data" => { + request.share_data = Some(arg_from_str(value.unwrap_or("false"), err, "share-data", "boolean")); + }, + "fingerprint" => { + request.fingerprint = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request.name = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request.account_id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.accounts().update(request, &self.opt.arg_account_id); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -3255,36 +3569,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "share-data" => { - request.share_data = Some(arg_from_str(value.unwrap_or("false"), err, "share-data", "boolean")); - }, - "fingerprint" => { - request.fingerprint = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request.account_id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3468,6 +3760,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -3475,8 +3768,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/tagmanager1/Cargo.toml b/gen/tagmanager1/Cargo.toml index 6b8c7b1e77..617a0c2250 100644 --- a/gen/tagmanager1/Cargo.toml +++ b/gen/tagmanager1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-tagmanager1" -version = "0.1.5+20150121" +version = "0.1.6+20150121" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with Tag Manager (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/tagmanager1" diff --git a/gen/tagmanager1/README.md b/gen/tagmanager1/README.md index 350b4d2aeb..e3ac82075b 100644 --- a/gen/tagmanager1/README.md +++ b/gen/tagmanager1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-tagmanager1` library allows access to all features of the *Google Tag Manager* service. -This documentation was generated from *Tag Manager* crate version *0.1.5+20150121*, where *20150121* is the exact revision of the *tagmanager:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *Tag Manager* crate version *0.1.6+20150121*, where *20150121* is the exact revision of the *tagmanager:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *Tag Manager* *v1* API can be found at the [official documentation site](https://developers.google.com/tag-manager/api/v1/). @@ -143,7 +143,7 @@ let mut req = Trigger::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! -let result = hub.accounts().containers_triggers_update(&req, "accountId", "containerId", "triggerId") +let result = hub.accounts().containers_triggers_update(req, "accountId", "containerId", "triggerId") .fingerprint("sed") .doit(); @@ -151,14 +151,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/tagmanager1/src/cmn.rs b/gen/tagmanager1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/tagmanager1/src/cmn.rs +++ b/gen/tagmanager1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/tagmanager1/src/lib.rs b/gen/tagmanager1/src/lib.rs index 7da6223121..c5bf297df5 100644 --- a/gen/tagmanager1/src/lib.rs +++ b/gen/tagmanager1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Tag Manager* crate version *0.1.5+20150121*, where *20150121* is the exact revision of the *tagmanager:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *Tag Manager* crate version *0.1.6+20150121*, where *20150121* is the exact revision of the *tagmanager:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *Tag Manager* *v1* API can be found at the //! [official documentation site](https://developers.google.com/tag-manager/api/v1/). @@ -144,7 +144,7 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.accounts().containers_triggers_update(&req, "accountId", "containerId", "triggerId") +//! let result = hub.accounts().containers_triggers_update(req, "accountId", "containerId", "triggerId") //! .fingerprint("accusam") //! .doit(); //! @@ -152,14 +152,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -247,7 +248,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -344,7 +345,7 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().containers_triggers_update(&req, "accountId", "containerId", "triggerId") +/// let result = hub.accounts().containers_triggers_update(req, "accountId", "containerId", "triggerId") /// .fingerprint("erat") /// .doit(); /// @@ -352,14 +353,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -380,7 +382,7 @@ impl<'a, C, A> TagManager<C, A> TagManager { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -389,7 +391,7 @@ impl<'a, C, A> TagManager<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -1332,10 +1334,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. - pub fn permissions_create(&self, request: &UserAccess, account_id: &str) -> AccountPermissionCreateCall<'a, C, A> { + pub fn permissions_create(&self, request: UserAccess, account_id: &str) -> AccountPermissionCreateCall<'a, C, A> { AccountPermissionCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1411,10 +1413,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `triggerId` - The GTM Trigger ID. - pub fn containers_triggers_update(&self, request: &Trigger, account_id: &str, container_id: &str, trigger_id: &str) -> AccountContainerTriggerUpdateCall<'a, C, A> { + pub fn containers_triggers_update(&self, request: Trigger, account_id: &str, container_id: &str, trigger_id: &str) -> AccountContainerTriggerUpdateCall<'a, C, A> { AccountContainerTriggerUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _trigger_id: trigger_id.to_string(), @@ -1473,10 +1475,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. - pub fn containers_create(&self, request: &Container, account_id: &str) -> AccountContainerCreateCall<'a, C, A> { + pub fn containers_create(&self, request: Container, account_id: &str) -> AccountContainerCreateCall<'a, C, A> { AccountContainerCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -1515,10 +1517,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `ruleId` - The GTM Rule ID. - pub fn containers_rules_update(&self, request: &Rule, account_id: &str, container_id: &str, rule_id: &str) -> AccountContainerRuleUpdateCall<'a, C, A> { + pub fn containers_rules_update(&self, request: Rule, account_id: &str, container_id: &str, rule_id: &str) -> AccountContainerRuleUpdateCall<'a, C, A> { AccountContainerRuleUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _rule_id: rule_id.to_string(), @@ -1600,10 +1602,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. - pub fn containers_tags_create(&self, request: &Tag, account_id: &str, container_id: &str) -> AccountContainerTagCreateCall<'a, C, A> { + pub fn containers_tags_create(&self, request: Tag, account_id: &str, container_id: &str) -> AccountContainerTagCreateCall<'a, C, A> { AccountContainerTagCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _delegate: Default::default(), @@ -1660,10 +1662,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. - pub fn update(&self, request: &Account, account_id: &str) -> AccountUpdateCall<'a, C, A> { + pub fn update(&self, request: Account, account_id: &str) -> AccountUpdateCall<'a, C, A> { AccountUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _fingerprint: Default::default(), _delegate: Default::default(), @@ -1702,10 +1704,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. - pub fn containers_versions_create(&self, request: &CreateContainerVersionRequestVersionOptions, account_id: &str, container_id: &str) -> AccountContainerVersionCreateCall<'a, C, A> { + pub fn containers_versions_create(&self, request: CreateContainerVersionRequestVersionOptions, account_id: &str, container_id: &str) -> AccountContainerVersionCreateCall<'a, C, A> { AccountContainerVersionCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _delegate: Default::default(), @@ -1742,10 +1744,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. - pub fn containers_rules_create(&self, request: &Rule, account_id: &str, container_id: &str) -> AccountContainerRuleCreateCall<'a, C, A> { + pub fn containers_rules_create(&self, request: Rule, account_id: &str, container_id: &str) -> AccountContainerRuleCreateCall<'a, C, A> { AccountContainerRuleCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _delegate: Default::default(), @@ -1805,10 +1807,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. - pub fn containers_variables_create(&self, request: &Variable, account_id: &str, container_id: &str) -> AccountContainerVariableCreateCall<'a, C, A> { + pub fn containers_variables_create(&self, request: Variable, account_id: &str, container_id: &str) -> AccountContainerVariableCreateCall<'a, C, A> { AccountContainerVariableCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _delegate: Default::default(), @@ -1845,10 +1847,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. - pub fn containers_macros_create(&self, request: &Macro, account_id: &str, container_id: &str) -> AccountContainerMacroCreateCall<'a, C, A> { + pub fn containers_macros_create(&self, request: Macro, account_id: &str, container_id: &str) -> AccountContainerMacroCreateCall<'a, C, A> { AccountContainerMacroCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _delegate: Default::default(), @@ -1948,10 +1950,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. - pub fn containers_triggers_create(&self, request: &Trigger, account_id: &str, container_id: &str) -> AccountContainerTriggerCreateCall<'a, C, A> { + pub fn containers_triggers_create(&self, request: Trigger, account_id: &str, container_id: &str) -> AccountContainerTriggerCreateCall<'a, C, A> { AccountContainerTriggerCreateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _delegate: Default::default(), @@ -1970,10 +1972,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `macroId` - The GTM Macro ID. - pub fn containers_macros_update(&self, request: &Macro, account_id: &str, container_id: &str, macro_id: &str) -> AccountContainerMacroUpdateCall<'a, C, A> { + pub fn containers_macros_update(&self, request: Macro, account_id: &str, container_id: &str, macro_id: &str) -> AccountContainerMacroUpdateCall<'a, C, A> { AccountContainerMacroUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _macro_id: macro_id.to_string(), @@ -2005,10 +2007,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. /// * `permissionId` - The GTM User ID. - pub fn permissions_update(&self, request: &UserAccess, account_id: &str, permission_id: &str) -> AccountPermissionUpdateCall<'a, C, A> { + pub fn permissions_update(&self, request: UserAccess, account_id: &str, permission_id: &str) -> AccountPermissionUpdateCall<'a, C, A> { AccountPermissionUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _permission_id: permission_id.to_string(), _delegate: Default::default(), @@ -2064,10 +2066,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. - pub fn containers_update(&self, request: &Container, account_id: &str, container_id: &str) -> AccountContainerUpdateCall<'a, C, A> { + pub fn containers_update(&self, request: Container, account_id: &str, container_id: &str) -> AccountContainerUpdateCall<'a, C, A> { AccountContainerUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _fingerprint: Default::default(), @@ -2106,10 +2108,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `tagId` - The GTM Tag ID. - pub fn containers_tags_update(&self, request: &Tag, account_id: &str, container_id: &str, tag_id: &str) -> AccountContainerTagUpdateCall<'a, C, A> { + pub fn containers_tags_update(&self, request: Tag, account_id: &str, container_id: &str, tag_id: &str) -> AccountContainerTagUpdateCall<'a, C, A> { AccountContainerTagUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _tag_id: tag_id.to_string(), @@ -2151,10 +2153,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `containerVersionId` - The GTM Container Version ID. - pub fn containers_versions_update(&self, request: &ContainerVersion, account_id: &str, container_id: &str, container_version_id: &str) -> AccountContainerVersionUpdateCall<'a, C, A> { + pub fn containers_versions_update(&self, request: ContainerVersion, account_id: &str, container_id: &str, container_version_id: &str) -> AccountContainerVersionUpdateCall<'a, C, A> { AccountContainerVersionUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _container_version_id: container_version_id.to_string(), @@ -2175,10 +2177,10 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `variableId` - The GTM Variable ID. - pub fn containers_variables_update(&self, request: &Variable, account_id: &str, container_id: &str, variable_id: &str) -> AccountContainerVariableUpdateCall<'a, C, A> { + pub fn containers_variables_update(&self, request: Variable, account_id: &str, container_id: &str, variable_id: &str) -> AccountContainerVariableUpdateCall<'a, C, A> { AccountContainerVariableUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _variable_id: variable_id.to_string(), @@ -2364,12 +2366,17 @@ impl<'a, C, A> AccountContainerListCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2378,7 +2385,7 @@ impl<'a, C, A> AccountContainerListCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2598,12 +2605,17 @@ impl<'a, C, A> AccountPermissionListCall<'a, C, A> where C: BorrowMut<hyper::Cli if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2612,7 +2624,7 @@ impl<'a, C, A> AccountPermissionListCall<'a, C, A> where C: BorrowMut<hyper::Cli Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2836,12 +2848,17 @@ impl<'a, C, A> AccountContainerVersionUndeleteCall<'a, C, A> where C: BorrowMut< if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2850,7 +2867,7 @@ impl<'a, C, A> AccountContainerVersionUndeleteCall<'a, C, A> where C: BorrowMut< Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2977,7 +2994,7 @@ impl<'a, C, A> AccountContainerVersionUndeleteCall<'a, C, A> where C: BorrowMut< /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().permissions_create(&req, "accountId") +/// let result = hub.accounts().permissions_create(req, "accountId") /// .doit(); /// # } /// ``` @@ -3105,12 +3122,17 @@ impl<'a, C, A> AccountPermissionCreateCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3119,7 +3141,7 @@ impl<'a, C, A> AccountPermissionCreateCall<'a, C, A> where C: BorrowMut<hyper::C Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3137,8 +3159,8 @@ impl<'a, C, A> AccountPermissionCreateCall<'a, C, A> where C: BorrowMut<hyper::C /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &UserAccess) -> AccountPermissionCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: UserAccess) -> AccountPermissionCreateCall<'a, C, A> { + self._request = new_value; self } /// The GTM Account ID. @@ -3349,12 +3371,17 @@ impl<'a, C, A> AccountPermissionDeleteCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -3585,12 +3612,17 @@ impl<'a, C, A> AccountContainerGetCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3599,7 +3631,7 @@ impl<'a, C, A> AccountContainerGetCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3836,12 +3868,17 @@ impl<'a, C, A> AccountContainerVersionListCall<'a, C, A> where C: BorrowMut<hype if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3850,7 +3887,7 @@ impl<'a, C, A> AccountContainerVersionListCall<'a, C, A> where C: BorrowMut<hype Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3974,7 +4011,7 @@ impl<'a, C, A> AccountContainerVersionListCall<'a, C, A> where C: BorrowMut<hype /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().containers_triggers_update(&req, "accountId", "containerId", "triggerId") +/// let result = hub.accounts().containers_triggers_update(req, "accountId", "containerId", "triggerId") /// .fingerprint("et") /// .doit(); /// # } @@ -4111,12 +4148,17 @@ impl<'a, C, A> AccountContainerTriggerUpdateCall<'a, C, A> where C: BorrowMut<hy if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4125,7 +4167,7 @@ impl<'a, C, A> AccountContainerTriggerUpdateCall<'a, C, A> where C: BorrowMut<hy Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4143,8 +4185,8 @@ impl<'a, C, A> AccountContainerTriggerUpdateCall<'a, C, A> where C: BorrowMut<hy /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Trigger) -> AccountContainerTriggerUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Trigger) -> AccountContainerTriggerUpdateCall<'a, C, A> { + self._request = new_value; self } /// The GTM Account ID. @@ -4385,12 +4427,17 @@ impl<'a, C, A> AccountContainerTriggerGetCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4399,7 +4446,7 @@ impl<'a, C, A> AccountContainerTriggerGetCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4640,12 +4687,17 @@ impl<'a, C, A> AccountContainerDeleteCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -4761,7 +4813,7 @@ impl<'a, C, A> AccountContainerDeleteCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().containers_create(&req, "accountId") +/// let result = hub.accounts().containers_create(req, "accountId") /// .doit(); /// # } /// ``` @@ -4889,12 +4941,17 @@ impl<'a, C, A> AccountContainerCreateCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4903,7 +4960,7 @@ impl<'a, C, A> AccountContainerCreateCall<'a, C, A> where C: BorrowMut<hyper::Cl Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4921,8 +4978,8 @@ impl<'a, C, A> AccountContainerCreateCall<'a, C, A> where C: BorrowMut<hyper::Cl /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Container) -> AccountContainerCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Container) -> AccountContainerCreateCall<'a, C, A> { + self._request = new_value; self } /// The GTM Account ID. @@ -5135,12 +5192,17 @@ impl<'a, C, A> AccountContainerTagDeleteCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -5266,7 +5328,7 @@ impl<'a, C, A> AccountContainerTagDeleteCall<'a, C, A> where C: BorrowMut<hyper: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().containers_rules_update(&req, "accountId", "containerId", "ruleId") +/// let result = hub.accounts().containers_rules_update(req, "accountId", "containerId", "ruleId") /// .fingerprint("labore") /// .doit(); /// # } @@ -5403,12 +5465,17 @@ impl<'a, C, A> AccountContainerRuleUpdateCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5417,7 +5484,7 @@ impl<'a, C, A> AccountContainerRuleUpdateCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -5435,8 +5502,8 @@ impl<'a, C, A> AccountContainerRuleUpdateCall<'a, C, A> where C: BorrowMut<hyper /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Rule) -> AccountContainerRuleUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Rule) -> AccountContainerRuleUpdateCall<'a, C, A> { + self._request = new_value; self } /// The GTM Account ID. @@ -5676,12 +5743,17 @@ impl<'a, C, A> AccountContainerRuleDeleteCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -5922,12 +5994,17 @@ impl<'a, C, A> AccountContainerTagListCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -5936,7 +6013,7 @@ impl<'a, C, A> AccountContainerTagListCall<'a, C, A> where C: BorrowMut<hyper::C Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6175,12 +6252,17 @@ impl<'a, C, A> AccountContainerVersionPublishCall<'a, C, A> where C: BorrowMut<h if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6189,7 +6271,7 @@ impl<'a, C, A> AccountContainerVersionPublishCall<'a, C, A> where C: BorrowMut<h Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6323,7 +6405,7 @@ impl<'a, C, A> AccountContainerVersionPublishCall<'a, C, A> where C: BorrowMut<h /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().containers_tags_create(&req, "accountId", "containerId") +/// let result = hub.accounts().containers_tags_create(req, "accountId", "containerId") /// .doit(); /// # } /// ``` @@ -6453,12 +6535,17 @@ impl<'a, C, A> AccountContainerTagCreateCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6467,7 +6554,7 @@ impl<'a, C, A> AccountContainerTagCreateCall<'a, C, A> where C: BorrowMut<hyper: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6485,8 +6572,8 @@ impl<'a, C, A> AccountContainerTagCreateCall<'a, C, A> where C: BorrowMut<hyper: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Tag) -> AccountContainerTagCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Tag) -> AccountContainerTagCreateCall<'a, C, A> { + self._request = new_value; self } /// The GTM Account ID. @@ -6708,12 +6795,17 @@ impl<'a, C, A> AccountContainerTriggerListCall<'a, C, A> where C: BorrowMut<hype if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -6722,7 +6814,7 @@ impl<'a, C, A> AccountContainerTriggerListCall<'a, C, A> where C: BorrowMut<hype Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -6955,12 +7047,17 @@ impl<'a, C, A> AccountContainerVersionDeleteCall<'a, C, A> where C: BorrowMut<hy if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -7086,7 +7183,7 @@ impl<'a, C, A> AccountContainerVersionDeleteCall<'a, C, A> where C: BorrowMut<hy /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().update(&req, "accountId") +/// let result = hub.accounts().update(req, "accountId") /// .fingerprint("ea") /// .doit(); /// # } @@ -7219,12 +7316,17 @@ impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7233,7 +7335,7 @@ impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7251,8 +7353,8 @@ impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Account) -> AccountUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Account) -> AccountUpdateCall<'a, C, A> { + self._request = new_value; self } /// The GTM Account ID. @@ -7472,12 +7574,17 @@ impl<'a, C, A> AccountContainerMacroDeleteCall<'a, C, A> where C: BorrowMut<hype if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -7603,7 +7710,7 @@ impl<'a, C, A> AccountContainerMacroDeleteCall<'a, C, A> where C: BorrowMut<hype /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().containers_versions_create(&req, "accountId", "containerId") +/// let result = hub.accounts().containers_versions_create(req, "accountId", "containerId") /// .doit(); /// # } /// ``` @@ -7733,12 +7840,17 @@ impl<'a, C, A> AccountContainerVersionCreateCall<'a, C, A> where C: BorrowMut<hy if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7747,7 +7859,7 @@ impl<'a, C, A> AccountContainerVersionCreateCall<'a, C, A> where C: BorrowMut<hy Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7765,8 +7877,8 @@ impl<'a, C, A> AccountContainerVersionCreateCall<'a, C, A> where C: BorrowMut<hy /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &CreateContainerVersionRequestVersionOptions) -> AccountContainerVersionCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CreateContainerVersionRequestVersionOptions) -> AccountContainerVersionCreateCall<'a, C, A> { + self._request = new_value; self } /// The GTM Account ID. @@ -7988,12 +8100,17 @@ impl<'a, C, A> AccountPermissionGetCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8002,7 +8119,7 @@ impl<'a, C, A> AccountPermissionGetCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8119,7 +8236,7 @@ impl<'a, C, A> AccountPermissionGetCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().containers_rules_create(&req, "accountId", "containerId") +/// let result = hub.accounts().containers_rules_create(req, "accountId", "containerId") /// .doit(); /// # } /// ``` @@ -8249,12 +8366,17 @@ impl<'a, C, A> AccountContainerRuleCreateCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8263,7 +8385,7 @@ impl<'a, C, A> AccountContainerRuleCreateCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8281,8 +8403,8 @@ impl<'a, C, A> AccountContainerRuleCreateCall<'a, C, A> where C: BorrowMut<hyper /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Rule) -> AccountContainerRuleCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Rule) -> AccountContainerRuleCreateCall<'a, C, A> { + self._request = new_value; self } /// The GTM Account ID. @@ -8506,12 +8628,17 @@ impl<'a, C, A> AccountContainerVersionRestoreCall<'a, C, A> where C: BorrowMut<h if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8520,7 +8647,7 @@ impl<'a, C, A> AccountContainerVersionRestoreCall<'a, C, A> where C: BorrowMut<h Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8764,12 +8891,17 @@ impl<'a, C, A> AccountContainerRuleGetCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8778,7 +8910,7 @@ impl<'a, C, A> AccountContainerRuleGetCall<'a, C, A> where C: BorrowMut<hyper::C Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8905,7 +9037,7 @@ impl<'a, C, A> AccountContainerRuleGetCall<'a, C, A> where C: BorrowMut<hyper::C /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().containers_variables_create(&req, "accountId", "containerId") +/// let result = hub.accounts().containers_variables_create(req, "accountId", "containerId") /// .doit(); /// # } /// ``` @@ -9035,12 +9167,17 @@ impl<'a, C, A> AccountContainerVariableCreateCall<'a, C, A> where C: BorrowMut<h if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9049,7 +9186,7 @@ impl<'a, C, A> AccountContainerVariableCreateCall<'a, C, A> where C: BorrowMut<h Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9067,8 +9204,8 @@ impl<'a, C, A> AccountContainerVariableCreateCall<'a, C, A> where C: BorrowMut<h /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Variable) -> AccountContainerVariableCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Variable) -> AccountContainerVariableCreateCall<'a, C, A> { + self._request = new_value; self } /// The GTM Account ID. @@ -9290,12 +9427,17 @@ impl<'a, C, A> AccountContainerVariableListCall<'a, C, A> where C: BorrowMut<hyp if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9304,7 +9446,7 @@ impl<'a, C, A> AccountContainerVariableListCall<'a, C, A> where C: BorrowMut<hyp Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9421,7 +9563,7 @@ impl<'a, C, A> AccountContainerVariableListCall<'a, C, A> where C: BorrowMut<hyp /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().containers_macros_create(&req, "accountId", "containerId") +/// let result = hub.accounts().containers_macros_create(req, "accountId", "containerId") /// .doit(); /// # } /// ``` @@ -9551,12 +9693,17 @@ impl<'a, C, A> AccountContainerMacroCreateCall<'a, C, A> where C: BorrowMut<hype if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9565,7 +9712,7 @@ impl<'a, C, A> AccountContainerMacroCreateCall<'a, C, A> where C: BorrowMut<hype Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9583,8 +9730,8 @@ impl<'a, C, A> AccountContainerMacroCreateCall<'a, C, A> where C: BorrowMut<hype /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Macro) -> AccountContainerMacroCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Macro) -> AccountContainerMacroCreateCall<'a, C, A> { + self._request = new_value; self } /// The GTM Account ID. @@ -9808,12 +9955,17 @@ impl<'a, C, A> AccountContainerTagGetCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9822,7 +9974,7 @@ impl<'a, C, A> AccountContainerTagGetCall<'a, C, A> where C: BorrowMut<hyper::Cl Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10066,12 +10218,17 @@ impl<'a, C, A> AccountContainerVariableGetCall<'a, C, A> where C: BorrowMut<hype if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10080,7 +10237,7 @@ impl<'a, C, A> AccountContainerVariableGetCall<'a, C, A> where C: BorrowMut<hype Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10323,12 +10480,17 @@ impl<'a, C, A> AccountContainerTriggerDeleteCall<'a, C, A> where C: BorrowMut<hy if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -10569,12 +10731,17 @@ impl<'a, C, A> AccountContainerMacroListCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10583,7 +10750,7 @@ impl<'a, C, A> AccountContainerMacroListCall<'a, C, A> where C: BorrowMut<hyper: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10700,7 +10867,7 @@ impl<'a, C, A> AccountContainerMacroListCall<'a, C, A> where C: BorrowMut<hyper: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().containers_triggers_create(&req, "accountId", "containerId") +/// let result = hub.accounts().containers_triggers_create(req, "accountId", "containerId") /// .doit(); /// # } /// ``` @@ -10830,12 +10997,17 @@ impl<'a, C, A> AccountContainerTriggerCreateCall<'a, C, A> where C: BorrowMut<hy if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10844,7 +11016,7 @@ impl<'a, C, A> AccountContainerTriggerCreateCall<'a, C, A> where C: BorrowMut<hy Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10862,8 +11034,8 @@ impl<'a, C, A> AccountContainerTriggerCreateCall<'a, C, A> where C: BorrowMut<hy /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Trigger) -> AccountContainerTriggerCreateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Trigger) -> AccountContainerTriggerCreateCall<'a, C, A> { + self._request = new_value; self } /// The GTM Account ID. @@ -10970,7 +11142,7 @@ impl<'a, C, A> AccountContainerTriggerCreateCall<'a, C, A> where C: BorrowMut<hy /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().containers_macros_update(&req, "accountId", "containerId", "macroId") +/// let result = hub.accounts().containers_macros_update(req, "accountId", "containerId", "macroId") /// .fingerprint("sadipscing") /// .doit(); /// # } @@ -11107,12 +11279,17 @@ impl<'a, C, A> AccountContainerMacroUpdateCall<'a, C, A> where C: BorrowMut<hype if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11121,7 +11298,7 @@ impl<'a, C, A> AccountContainerMacroUpdateCall<'a, C, A> where C: BorrowMut<hype Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11139,8 +11316,8 @@ impl<'a, C, A> AccountContainerMacroUpdateCall<'a, C, A> where C: BorrowMut<hype /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Macro) -> AccountContainerMacroUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Macro) -> AccountContainerMacroUpdateCall<'a, C, A> { + self._request = new_value; self } /// The GTM Account ID. @@ -11351,12 +11528,17 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11365,7 +11547,7 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11462,7 +11644,7 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().permissions_update(&req, "accountId", "permissionId") +/// let result = hub.accounts().permissions_update(req, "accountId", "permissionId") /// .doit(); /// # } /// ``` @@ -11592,12 +11774,17 @@ impl<'a, C, A> AccountPermissionUpdateCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11606,7 +11793,7 @@ impl<'a, C, A> AccountPermissionUpdateCall<'a, C, A> where C: BorrowMut<hyper::C Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11624,8 +11811,8 @@ impl<'a, C, A> AccountPermissionUpdateCall<'a, C, A> where C: BorrowMut<hyper::C /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &UserAccess) -> AccountPermissionUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: UserAccess) -> AccountPermissionUpdateCall<'a, C, A> { + self._request = new_value; self } /// The GTM Account ID. @@ -11848,12 +12035,17 @@ impl<'a, C, A> AccountContainerVariableDeleteCall<'a, C, A> where C: BorrowMut<h if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -12092,12 +12284,17 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12106,7 +12303,7 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12213,7 +12410,7 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().containers_update(&req, "accountId", "containerId") +/// let result = hub.accounts().containers_update(req, "accountId", "containerId") /// .fingerprint("labore") /// .doit(); /// # } @@ -12348,12 +12545,17 @@ impl<'a, C, A> AccountContainerUpdateCall<'a, C, A> where C: BorrowMut<hyper::Cl if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12362,7 +12564,7 @@ impl<'a, C, A> AccountContainerUpdateCall<'a, C, A> where C: BorrowMut<hyper::Cl Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12380,8 +12582,8 @@ impl<'a, C, A> AccountContainerUpdateCall<'a, C, A> where C: BorrowMut<hyper::Cl /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Container) -> AccountContainerUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Container) -> AccountContainerUpdateCall<'a, C, A> { + self._request = new_value; self } /// The GTM Account ID. @@ -12610,12 +12812,17 @@ impl<'a, C, A> AccountContainerRuleListCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12624,7 +12831,7 @@ impl<'a, C, A> AccountContainerRuleListCall<'a, C, A> where C: BorrowMut<hyper:: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12741,7 +12948,7 @@ impl<'a, C, A> AccountContainerRuleListCall<'a, C, A> where C: BorrowMut<hyper:: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().containers_tags_update(&req, "accountId", "containerId", "tagId") +/// let result = hub.accounts().containers_tags_update(req, "accountId", "containerId", "tagId") /// .fingerprint("tempor") /// .doit(); /// # } @@ -12878,12 +13085,17 @@ impl<'a, C, A> AccountContainerTagUpdateCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12892,7 +13104,7 @@ impl<'a, C, A> AccountContainerTagUpdateCall<'a, C, A> where C: BorrowMut<hyper: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12910,8 +13122,8 @@ impl<'a, C, A> AccountContainerTagUpdateCall<'a, C, A> where C: BorrowMut<hyper: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Tag) -> AccountContainerTagUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Tag) -> AccountContainerTagUpdateCall<'a, C, A> { + self._request = new_value; self } /// The GTM Account ID. @@ -13152,12 +13364,17 @@ impl<'a, C, A> AccountContainerMacroGetCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13166,7 +13383,7 @@ impl<'a, C, A> AccountContainerMacroGetCall<'a, C, A> where C: BorrowMut<hyper:: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13293,7 +13510,7 @@ impl<'a, C, A> AccountContainerMacroGetCall<'a, C, A> where C: BorrowMut<hyper:: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().containers_versions_update(&req, "accountId", "containerId", "containerVersionId") +/// let result = hub.accounts().containers_versions_update(req, "accountId", "containerId", "containerVersionId") /// .fingerprint("diam") /// .doit(); /// # } @@ -13430,12 +13647,17 @@ impl<'a, C, A> AccountContainerVersionUpdateCall<'a, C, A> where C: BorrowMut<hy if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13444,7 +13666,7 @@ impl<'a, C, A> AccountContainerVersionUpdateCall<'a, C, A> where C: BorrowMut<hy Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13462,8 +13684,8 @@ impl<'a, C, A> AccountContainerVersionUpdateCall<'a, C, A> where C: BorrowMut<hy /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ContainerVersion) -> AccountContainerVersionUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ContainerVersion) -> AccountContainerVersionUpdateCall<'a, C, A> { + self._request = new_value; self } /// The GTM Account ID. @@ -13587,7 +13809,7 @@ impl<'a, C, A> AccountContainerVersionUpdateCall<'a, C, A> where C: BorrowMut<hy /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().containers_variables_update(&req, "accountId", "containerId", "variableId") +/// let result = hub.accounts().containers_variables_update(req, "accountId", "containerId", "variableId") /// .fingerprint("amet") /// .doit(); /// # } @@ -13724,12 +13946,17 @@ impl<'a, C, A> AccountContainerVariableUpdateCall<'a, C, A> where C: BorrowMut<h if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13738,7 +13965,7 @@ impl<'a, C, A> AccountContainerVariableUpdateCall<'a, C, A> where C: BorrowMut<h Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13756,8 +13983,8 @@ impl<'a, C, A> AccountContainerVariableUpdateCall<'a, C, A> where C: BorrowMut<h /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Variable) -> AccountContainerVariableUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Variable) -> AccountContainerVariableUpdateCall<'a, C, A> { + self._request = new_value; self } /// The GTM Account ID. @@ -13998,12 +14225,17 @@ impl<'a, C, A> AccountContainerVersionGetCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14012,7 +14244,7 @@ impl<'a, C, A> AccountContainerVersionGetCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/taskqueue1_beta2-cli/Cargo.toml b/gen/taskqueue1_beta2-cli/Cargo.toml index 9790921b57..f60db23222 100644 --- a/gen/taskqueue1_beta2-cli/Cargo.toml +++ b/gen/taskqueue1_beta2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-taskqueue1_beta2-cli" -version = "0.0.1+20141111" +version = "0.1.0+20141111" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with taskqueue (protocol v1beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/taskqueue1_beta2-cli" diff --git a/gen/taskqueue1_beta2-cli/README.md b/gen/taskqueue1_beta2-cli/README.md index 7baaf70b4b..c987877232 100644 --- a/gen/taskqueue1_beta2-cli/README.md +++ b/gen/taskqueue1_beta2-cli/README.md @@ -1,4 +1,109 @@ -# HELLO TASKQUEUE:V1BETA2 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `taskqueue1-beta2` command-line interface *(CLI)* allows to use most features of the *Google taskqueue* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *taskqueue* API at revision *20141111*. The CLI is at version *0.1.0*. + +```bash + taskqueue1-beta2 [options] taskqueues get <project> <taskqueue> [-p <v>...] [-o <out>] + taskqueue1-beta2 [options] tasks delete <project> <taskqueue> <task> [-p <v>...] + taskqueue1-beta2 [options] tasks get <project> <taskqueue> <task> [-p <v>...] [-o <out>] + taskqueue1-beta2 [options] tasks insert <project> <taskqueue> -r <kv>... [-p <v>...] [-o <out>] + taskqueue1-beta2 [options] tasks lease <project> <taskqueue> <num-tasks> <lease-secs> [-p <v>...] [-o <out>] + taskqueue1-beta2 [options] tasks list <project> <taskqueue> [-p <v>...] [-o <out>] + taskqueue1-beta2 [options] tasks patch <project> <taskqueue> <task> <new-lease-seconds> -r <kv>... [-p <v>...] [-o <out>] + taskqueue1-beta2 [options] tasks update <project> <taskqueue> <task> <new-lease-seconds> -r <kv>... [-p <v>...] [-o <out>] + taskqueue1-beta2 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_taskqueue1_beta2_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `taskqueue1-beta2-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/taskqueue1-beta2-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/taskqueue1-beta2-secret.json`, assuming that the required *taskqueue* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `taskqueue1-beta2 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/taskqueue1_beta2-cli/mkdocs.yml b/gen/taskqueue1_beta2-cli/mkdocs.yml index 88e631eedb..56925c90d3 100644 --- a/gen/taskqueue1_beta2-cli/mkdocs.yml +++ b/gen/taskqueue1_beta2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: taskqueue v0.0.1+20141111 +site_name: taskqueue v0.1.0+20141111 site_url: http://byron.github.io/google-apis-rs/google-taskqueue1_beta2-cli site_description: Write integrating applications with bcore diff --git a/gen/taskqueue1_beta2-cli/src/cmn.rs b/gen/taskqueue1_beta2-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/taskqueue1_beta2-cli/src/cmn.rs +++ b/gen/taskqueue1_beta2-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/taskqueue1_beta2-cli/src/main.rs b/gen/taskqueue1_beta2-cli/src/main.rs index ed62ba55f3..9a1adeb66c 100644 --- a/gen/taskqueue1_beta2-cli/src/main.rs +++ b/gen/taskqueue1_beta2-cli/src/main.rs @@ -19,33 +19,34 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - taskqueue1-beta2 [options] taskqueues get <project> <taskqueue> [-p <v>]... [-o <out>] - taskqueue1-beta2 [options] tasks delete <project> <taskqueue> <task> [-p <v>]... - taskqueue1-beta2 [options] tasks get <project> <taskqueue> <task> [-p <v>]... [-o <out>] - taskqueue1-beta2 [options] tasks insert <project> <taskqueue> -r <kv>... [-p <v>]... [-o <out>] - taskqueue1-beta2 [options] tasks lease <project> <taskqueue> <num-tasks> <lease-secs> [-p <v>]... [-o <out>] - taskqueue1-beta2 [options] tasks list <project> <taskqueue> [-p <v>]... [-o <out>] - taskqueue1-beta2 [options] tasks patch <project> <taskqueue> <task> <new-lease-seconds> -r <kv>... [-p <v>]... [-o <out>] - taskqueue1-beta2 [options] tasks update <project> <taskqueue> <task> <new-lease-seconds> -r <kv>... [-p <v>]... [-o <out>] + taskqueue1-beta2 [options] taskqueues get <project> <taskqueue> [-p <v>...] [-o <out>] + taskqueue1-beta2 [options] tasks delete <project> <taskqueue> <task> [-p <v>...] + taskqueue1-beta2 [options] tasks get <project> <taskqueue> <task> [-p <v>...] [-o <out>] + taskqueue1-beta2 [options] tasks insert <project> <taskqueue> -r <kv>... [-p <v>...] [-o <out>] + taskqueue1-beta2 [options] tasks lease <project> <taskqueue> <num-tasks> <lease-secs> [-p <v>...] [-o <out>] + taskqueue1-beta2 [options] tasks list <project> <taskqueue> [-p <v>...] [-o <out>] + taskqueue1-beta2 [options] tasks patch <project> <taskqueue> <task> <new-lease-seconds> -r <kv>... [-p <v>...] [-o <out>] + taskqueue1-beta2 [options] tasks update <project> <taskqueue> <task> <new-lease-seconds> -r <kv>... [-p <v>...] [-o <out>] taskqueue1-beta2 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_taskqueue1_beta2_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -97,6 +98,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -140,6 +144,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -181,6 +188,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -197,37 +207,24 @@ impl Engine { fn _tasks_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Task::default(); - let mut call = self.hub.tasks().insert(&request, &self.opt.arg_project, &self.opt.arg_taskqueue); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Task::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -253,15 +250,40 @@ impl Engine { request.enqueue_timestamp = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.tasks().insert(request, &self.opt.arg_project, &self.opt.arg_taskqueue); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -313,6 +335,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -356,6 +381,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -372,38 +400,24 @@ impl Engine { fn _tasks_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Task::default(); - let new_lease_seconds: i32 = arg_from_str(&self.opt.arg_new_lease_seconds, err, "<new-lease-seconds>", "integer"); - let mut call = self.hub.tasks().patch(&request, &self.opt.arg_project, &self.opt.arg_taskqueue, &self.opt.arg_task, new_lease_seconds); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Task::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -429,15 +443,41 @@ impl Engine { request.enqueue_timestamp = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let new_lease_seconds: i32 = arg_from_str(&self.opt.arg_new_lease_seconds, err, "<new-lease-seconds>", "integer"); + let mut call = self.hub.tasks().patch(request, &self.opt.arg_project, &self.opt.arg_taskqueue, &self.opt.arg_task, new_lease_seconds); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -454,38 +494,24 @@ impl Engine { fn _tasks_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Task::default(); - let new_lease_seconds: i32 = arg_from_str(&self.opt.arg_new_lease_seconds, err, "<new-lease-seconds>", "integer"); - let mut call = self.hub.tasks().update(&request, &self.opt.arg_project, &self.opt.arg_taskqueue, &self.opt.arg_task, new_lease_seconds); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Task::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -511,15 +537,41 @@ impl Engine { request.enqueue_timestamp = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let new_lease_seconds: i32 = arg_from_str(&self.opt.arg_new_lease_seconds, err, "<new-lease-seconds>", "integer"); + let mut call = self.hub.tasks().update(request, &self.opt.arg_project, &self.opt.arg_taskqueue, &self.opt.arg_task, new_lease_seconds); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -632,6 +684,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -639,8 +692,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/taskqueue1_beta2/Cargo.toml b/gen/taskqueue1_beta2/Cargo.toml index f64ecb67f4..228e9e8cf2 100644 --- a/gen/taskqueue1_beta2/Cargo.toml +++ b/gen/taskqueue1_beta2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-taskqueue1_beta2" -version = "0.1.5+20141111" +version = "0.1.6+20141111" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with taskqueue (protocol v1beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/taskqueue1_beta2" diff --git a/gen/taskqueue1_beta2/README.md b/gen/taskqueue1_beta2/README.md index 372b20669f..e8a851b2dc 100644 --- a/gen/taskqueue1_beta2/README.md +++ b/gen/taskqueue1_beta2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-taskqueue1_beta2` library allows access to all features of the *Google taskqueue* service. -This documentation was generated from *taskqueue* crate version *0.1.5+20141111*, where *20141111* is the exact revision of the *taskqueue:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *taskqueue* crate version *0.1.6+20141111*, where *20141111* is the exact revision of the *taskqueue:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *taskqueue* *v1_beta2* API can be found at the [official documentation site](https://developers.google.com/appengine/docs/python/taskqueue/rest). @@ -109,14 +109,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/taskqueue1_beta2/src/cmn.rs b/gen/taskqueue1_beta2/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/taskqueue1_beta2/src/cmn.rs +++ b/gen/taskqueue1_beta2/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/taskqueue1_beta2/src/lib.rs b/gen/taskqueue1_beta2/src/lib.rs index 821025782a..8a32519bdb 100644 --- a/gen/taskqueue1_beta2/src/lib.rs +++ b/gen/taskqueue1_beta2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *taskqueue* crate version *0.1.5+20141111*, where *20141111* is the exact revision of the *taskqueue:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *taskqueue* crate version *0.1.6+20141111*, where *20141111* is the exact revision of the *taskqueue:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *taskqueue* *v1_beta2* API can be found at the //! [official documentation site](https://developers.google.com/appengine/docs/python/taskqueue/rest). @@ -110,14 +110,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -205,7 +206,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -285,14 +286,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -313,7 +315,7 @@ impl<'a, C, A> Taskqueue<C, A> Taskqueue { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -325,7 +327,7 @@ impl<'a, C, A> Taskqueue<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -634,10 +636,10 @@ impl<'a, C, A> TaskMethods<'a, C, A> { /// * `request` - No description provided. /// * `project` - The project under which the queue lies /// * `taskqueue` - The taskqueue to insert the task into - pub fn insert(&self, request: &Task, project: &str, taskqueue: &str) -> TaskInsertCall<'a, C, A> { + pub fn insert(&self, request: Task, project: &str, taskqueue: &str) -> TaskInsertCall<'a, C, A> { TaskInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _taskqueue: taskqueue.to_string(), _delegate: Default::default(), @@ -678,10 +680,10 @@ impl<'a, C, A> TaskMethods<'a, C, A> { /// * `taskqueue` - No description provided. /// * `task` - No description provided. /// * `newLeaseSeconds` - The new lease in seconds. - pub fn patch(&self, request: &Task, project: &str, taskqueue: &str, task: &str, new_lease_seconds: i32) -> TaskPatchCall<'a, C, A> { + pub fn patch(&self, request: Task, project: &str, taskqueue: &str, task: &str, new_lease_seconds: i32) -> TaskPatchCall<'a, C, A> { TaskPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _taskqueue: taskqueue.to_string(), _task: task.to_string(), @@ -743,10 +745,10 @@ impl<'a, C, A> TaskMethods<'a, C, A> { /// * `taskqueue` - No description provided. /// * `task` - No description provided. /// * `newLeaseSeconds` - The new lease in seconds. - pub fn update(&self, request: &Task, project: &str, taskqueue: &str, task: &str, new_lease_seconds: i32) -> TaskUpdateCall<'a, C, A> { + pub fn update(&self, request: Task, project: &str, taskqueue: &str, task: &str, new_lease_seconds: i32) -> TaskUpdateCall<'a, C, A> { TaskUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _project: project.to_string(), _taskqueue: taskqueue.to_string(), _task: task.to_string(), @@ -918,12 +920,17 @@ impl<'a, C, A> TaskqueueGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -932,7 +939,7 @@ impl<'a, C, A> TaskqueueGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1185,12 +1192,17 @@ impl<'a, C, A> TaskLeaseCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1199,7 +1211,7 @@ impl<'a, C, A> TaskLeaseCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1350,7 +1362,7 @@ impl<'a, C, A> TaskLeaseCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.tasks().insert(&req, "project", "taskqueue") +/// let result = hub.tasks().insert(req, "project", "taskqueue") /// .doit(); /// # } /// ``` @@ -1480,12 +1492,17 @@ impl<'a, C, A> TaskInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1494,7 +1511,7 @@ impl<'a, C, A> TaskInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1512,8 +1529,8 @@ impl<'a, C, A> TaskInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Task) -> TaskInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Task) -> TaskInsertCall<'a, C, A> { + self._request = new_value; self } /// The project under which the queue lies @@ -1736,12 +1753,17 @@ impl<'a, C, A> TaskDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -1867,7 +1889,7 @@ impl<'a, C, A> TaskDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.tasks().patch(&req, "project", "taskqueue", "task", -95) +/// let result = hub.tasks().patch(req, "project", "taskqueue", "task", -95) /// .doit(); /// # } /// ``` @@ -2001,12 +2023,17 @@ impl<'a, C, A> TaskPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2015,7 +2042,7 @@ impl<'a, C, A> TaskPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2033,8 +2060,8 @@ impl<'a, C, A> TaskPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Task) -> TaskPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Task) -> TaskPatchCall<'a, C, A> { + self._request = new_value; self } /// The project under which the queue lies. @@ -2274,12 +2301,17 @@ impl<'a, C, A> TaskListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2288,7 +2320,7 @@ impl<'a, C, A> TaskListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2522,12 +2554,17 @@ impl<'a, C, A> TaskGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2536,7 +2573,7 @@ impl<'a, C, A> TaskGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2663,7 +2700,7 @@ impl<'a, C, A> TaskGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.tasks().update(&req, "project", "taskqueue", "task", -37) +/// let result = hub.tasks().update(req, "project", "taskqueue", "task", -37) /// .doit(); /// # } /// ``` @@ -2797,12 +2834,17 @@ impl<'a, C, A> TaskUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2811,7 +2853,7 @@ impl<'a, C, A> TaskUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2829,8 +2871,8 @@ impl<'a, C, A> TaskUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Task) -> TaskUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Task) -> TaskUpdateCall<'a, C, A> { + self._request = new_value; self } /// The project under which the queue lies. diff --git a/gen/tasks1-cli/Cargo.toml b/gen/tasks1-cli/Cargo.toml index 9ea5e282d0..244bc7da91 100644 --- a/gen/tasks1-cli/Cargo.toml +++ b/gen/tasks1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-tasks1-cli" -version = "0.0.1+20141121" +version = "0.1.0+20141121" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with tasks (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/tasks1-cli" diff --git a/gen/tasks1-cli/README.md b/gen/tasks1-cli/README.md index 52a45e5033..ab2a922f4f 100644 --- a/gen/tasks1-cli/README.md +++ b/gen/tasks1-cli/README.md @@ -1,4 +1,115 @@ -# HELLO TASKS:V1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `tasks1` command-line interface *(CLI)* allows to use most features of the *Google tasks* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *tasks* API at revision *20141121*. The CLI is at version *0.1.0*. + +```bash + tasks1 [options] tasklists delete <tasklist> [-p <v>...] + tasks1 [options] tasklists get <tasklist> [-p <v>...] [-o <out>] + tasks1 [options] tasklists insert -r <kv>... [-p <v>...] [-o <out>] + tasks1 [options] tasklists list [-p <v>...] [-o <out>] + tasks1 [options] tasklists patch <tasklist> -r <kv>... [-p <v>...] [-o <out>] + tasks1 [options] tasklists update <tasklist> -r <kv>... [-p <v>...] [-o <out>] + tasks1 [options] tasks clear <tasklist> [-p <v>...] + tasks1 [options] tasks delete <tasklist> <task> [-p <v>...] + tasks1 [options] tasks get <tasklist> <task> [-p <v>...] [-o <out>] + tasks1 [options] tasks insert <tasklist> -r <kv>... [-p <v>...] [-o <out>] + tasks1 [options] tasks list <tasklist> [-p <v>...] [-o <out>] + tasks1 [options] tasks move <tasklist> <task> [-p <v>...] [-o <out>] + tasks1 [options] tasks patch <tasklist> <task> -r <kv>... [-p <v>...] [-o <out>] + tasks1 [options] tasks update <tasklist> <task> -r <kv>... [-p <v>...] [-o <out>] + tasks1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_tasks1_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `tasks1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/tasks1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/tasks1-secret.json`, assuming that the required *tasks* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `tasks1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/tasks1-cli/mkdocs.yml b/gen/tasks1-cli/mkdocs.yml index d3f87e7d92..416927b3ce 100644 --- a/gen/tasks1-cli/mkdocs.yml +++ b/gen/tasks1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: tasks v0.0.1+20141121 +site_name: tasks v0.1.0+20141121 site_url: http://byron.github.io/google-apis-rs/google-tasks1-cli site_description: Write integrating applications with bcore diff --git a/gen/tasks1-cli/src/cmn.rs b/gen/tasks1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/tasks1-cli/src/cmn.rs +++ b/gen/tasks1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/tasks1-cli/src/main.rs b/gen/tasks1-cli/src/main.rs index 41be672588..2c767ed62e 100644 --- a/gen/tasks1-cli/src/main.rs +++ b/gen/tasks1-cli/src/main.rs @@ -19,39 +19,40 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - tasks1 [options] tasklists delete <tasklist> [-p <v>]... - tasks1 [options] tasklists get <tasklist> [-p <v>]... [-o <out>] - tasks1 [options] tasklists insert -r <kv>... [-p <v>]... [-o <out>] - tasks1 [options] tasklists list [-p <v>]... [-o <out>] - tasks1 [options] tasklists patch <tasklist> -r <kv>... [-p <v>]... [-o <out>] - tasks1 [options] tasklists update <tasklist> -r <kv>... [-p <v>]... [-o <out>] - tasks1 [options] tasks clear <tasklist> [-p <v>]... - tasks1 [options] tasks delete <tasklist> <task> [-p <v>]... - tasks1 [options] tasks get <tasklist> <task> [-p <v>]... [-o <out>] - tasks1 [options] tasks insert <tasklist> -r <kv>... [-p <v>]... [-o <out>] - tasks1 [options] tasks list <tasklist> [-p <v>]... [-o <out>] - tasks1 [options] tasks move <tasklist> <task> [-p <v>]... [-o <out>] - tasks1 [options] tasks patch <tasklist> <task> -r <kv>... [-p <v>]... [-o <out>] - tasks1 [options] tasks update <tasklist> <task> -r <kv>... [-p <v>]... [-o <out>] + tasks1 [options] tasklists delete <tasklist> [-p <v>...] + tasks1 [options] tasklists get <tasklist> [-p <v>...] [-o <out>] + tasks1 [options] tasklists insert -r <kv>... [-p <v>...] [-o <out>] + tasks1 [options] tasklists list [-p <v>...] [-o <out>] + tasks1 [options] tasklists patch <tasklist> -r <kv>... [-p <v>...] [-o <out>] + tasks1 [options] tasklists update <tasklist> -r <kv>... [-p <v>...] [-o <out>] + tasks1 [options] tasks clear <tasklist> [-p <v>...] + tasks1 [options] tasks delete <tasklist> <task> [-p <v>...] + tasks1 [options] tasks get <tasklist> <task> [-p <v>...] [-o <out>] + tasks1 [options] tasks insert <tasklist> -r <kv>... [-p <v>...] [-o <out>] + tasks1 [options] tasks list <tasklist> [-p <v>...] [-o <out>] + tasks1 [options] tasks move <tasklist> <task> [-p <v>...] [-o <out>] + tasks1 [options] tasks patch <tasklist> <task> -r <kv>... [-p <v>...] [-o <out>] + tasks1 [options] tasks update <tasklist> <task> -r <kv>... [-p <v>...] [-o <out>] tasks1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_tasks1_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -100,6 +101,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -141,6 +145,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -157,8 +164,48 @@ impl Engine { fn _tasklists_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::TaskList::default(); - let mut call = self.hub.tasklists().insert(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "title" => { + request.title = Some(value.unwrap_or("").to_string()); + }, + "updated" => { + request.updated = Some(value.unwrap_or("").to_string()); + }, + "etag" => { + request.etag = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "self-link" => { + request.self_link = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.tasklists().insert(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -180,42 +227,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "title" => { - request.title = Some(value.unwrap_or("").to_string()); - }, - "updated" => { - request.updated = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "self-link" => { - request.self_link = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -265,6 +284,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -281,8 +303,48 @@ impl Engine { fn _tasklists_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::TaskList::default(); - let mut call = self.hub.tasklists().patch(&request, &self.opt.arg_tasklist); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "title" => { + request.title = Some(value.unwrap_or("").to_string()); + }, + "updated" => { + request.updated = Some(value.unwrap_or("").to_string()); + }, + "etag" => { + request.etag = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "self-link" => { + request.self_link = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.tasklists().patch(request, &self.opt.arg_tasklist); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -304,42 +366,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "title" => { - request.title = Some(value.unwrap_or("").to_string()); - }, - "updated" => { - request.updated = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "self-link" => { - request.self_link = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -356,8 +390,48 @@ impl Engine { fn _tasklists_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::TaskList::default(); - let mut call = self.hub.tasklists().update(&request, &self.opt.arg_tasklist); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "title" => { + request.title = Some(value.unwrap_or("").to_string()); + }, + "updated" => { + request.updated = Some(value.unwrap_or("").to_string()); + }, + "etag" => { + request.etag = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request.id = Some(value.unwrap_or("").to_string()); + }, + "self-link" => { + request.self_link = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.tasklists().update(request, &self.opt.arg_tasklist); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -379,42 +453,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "title" => { - request.title = Some(value.unwrap_or("").to_string()); - }, - "updated" => { - request.updated = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "self-link" => { - request.self_link = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -458,6 +504,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -499,6 +548,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -540,6 +592,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -556,43 +611,24 @@ impl Engine { fn _tasks_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Task::default(); - let mut call = self.hub.tasks().insert(&request, &self.opt.arg_tasklist); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "previous" => { - call = call.previous(value.unwrap_or("")); - }, - "parent" => { - call = call.parent(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Task::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -636,15 +672,46 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.tasks().insert(request, &self.opt.arg_tasklist); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "previous" => { + call = call.previous(value.unwrap_or("")); + }, + "parent" => { + call = call.parent(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -718,6 +785,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -767,6 +837,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -783,37 +856,24 @@ impl Engine { fn _tasks_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Task::default(); - let mut call = self.hub.tasks().patch(&request, &self.opt.arg_tasklist, &self.opt.arg_task); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Task::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -857,15 +917,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.tasks().patch(request, &self.opt.arg_tasklist, &self.opt.arg_task); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -882,37 +967,24 @@ impl Engine { fn _tasks_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Task::default(); - let mut call = self.hub.tasks().update(&request, &self.opt.arg_tasklist, &self.opt.arg_task); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Task::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -956,15 +1028,40 @@ impl Engine { request.self_link = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.tasks().update(request, &self.opt.arg_tasklist, &self.opt.arg_task); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1089,6 +1186,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -1096,8 +1194,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/tasks1/Cargo.toml b/gen/tasks1/Cargo.toml index 08de7634f9..1488653e1b 100644 --- a/gen/tasks1/Cargo.toml +++ b/gen/tasks1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-tasks1" -version = "0.1.5+20141121" +version = "0.1.6+20141121" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with tasks (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/tasks1" diff --git a/gen/tasks1/README.md b/gen/tasks1/README.md index 3429553d99..448b71829c 100644 --- a/gen/tasks1/README.md +++ b/gen/tasks1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-tasks1` library allows access to all features of the *Google tasks* service. -This documentation was generated from *tasks* crate version *0.1.5+20141121*, where *20141121* is the exact revision of the *tasks:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *tasks* crate version *0.1.6+20141121*, where *20141121* is the exact revision of the *tasks:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *tasks* *v1* API can be found at the [official documentation site](https://developers.google.com/google-apps/tasks/firstapp). @@ -118,14 +118,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/tasks1/src/cmn.rs b/gen/tasks1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/tasks1/src/cmn.rs +++ b/gen/tasks1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/tasks1/src/lib.rs b/gen/tasks1/src/lib.rs index 322271d5e0..31636d7f72 100644 --- a/gen/tasks1/src/lib.rs +++ b/gen/tasks1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *tasks* crate version *0.1.5+20141121*, where *20141121* is the exact revision of the *tasks:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *tasks* crate version *0.1.6+20141121*, where *20141121* is the exact revision of the *tasks:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *tasks* *v1* API can be found at the //! [official documentation site](https://developers.google.com/google-apps/tasks/firstapp). @@ -119,14 +119,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -214,7 +215,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -302,14 +303,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -330,7 +332,7 @@ impl<'a, C, A> TasksHub<C, A> TasksHub { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -342,7 +344,7 @@ impl<'a, C, A> TasksHub<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -594,10 +596,10 @@ impl<'a, C, A> TaskMethods<'a, C, A> { /// * `request` - No description provided. /// * `tasklist` - Task list identifier. /// * `task` - Task identifier. - pub fn update(&self, request: &Task, tasklist: &str, task: &str) -> TaskUpdateCall<'a, C, A> { + pub fn update(&self, request: Task, tasklist: &str, task: &str) -> TaskUpdateCall<'a, C, A> { TaskUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _tasklist: tasklist.to_string(), _task: task.to_string(), _delegate: Default::default(), @@ -615,10 +617,10 @@ impl<'a, C, A> TaskMethods<'a, C, A> { /// * `request` - No description provided. /// * `tasklist` - Task list identifier. /// * `task` - Task identifier. - pub fn patch(&self, request: &Task, tasklist: &str, task: &str) -> TaskPatchCall<'a, C, A> { + pub fn patch(&self, request: Task, tasklist: &str, task: &str) -> TaskPatchCall<'a, C, A> { TaskPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _tasklist: tasklist.to_string(), _task: task.to_string(), _delegate: Default::default(), @@ -711,10 +713,10 @@ impl<'a, C, A> TaskMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `tasklist` - Task list identifier. - pub fn insert(&self, request: &Task, tasklist: &str) -> TaskInsertCall<'a, C, A> { + pub fn insert(&self, request: Task, tasklist: &str) -> TaskInsertCall<'a, C, A> { TaskInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _tasklist: tasklist.to_string(), _previous: Default::default(), _parent: Default::default(), @@ -787,10 +789,10 @@ impl<'a, C, A> TasklistMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `tasklist` - Task list identifier. - pub fn update(&self, request: &TaskList, tasklist: &str) -> TasklistUpdateCall<'a, C, A> { + pub fn update(&self, request: TaskList, tasklist: &str) -> TasklistUpdateCall<'a, C, A> { TasklistUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _tasklist: tasklist.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -823,10 +825,10 @@ impl<'a, C, A> TasklistMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `tasklist` - Task list identifier. - pub fn patch(&self, request: &TaskList, tasklist: &str) -> TasklistPatchCall<'a, C, A> { + pub fn patch(&self, request: TaskList, tasklist: &str) -> TasklistPatchCall<'a, C, A> { TasklistPatchCall { hub: self.hub, - _request: request.clone(), + _request: request, _tasklist: tasklist.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -841,10 +843,10 @@ impl<'a, C, A> TasklistMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &TaskList) -> TasklistInsertCall<'a, C, A> { + pub fn insert(&self, request: TaskList) -> TasklistInsertCall<'a, C, A> { TasklistInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1072,12 +1074,17 @@ impl<'a, C, A> TaskListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1086,7 +1093,7 @@ impl<'a, C, A> TaskListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1263,7 +1270,7 @@ impl<'a, C, A> TaskListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.tasks().update(&req, "tasklist", "task") +/// let result = hub.tasks().update(req, "tasklist", "task") /// .doit(); /// # } /// ``` @@ -1393,12 +1400,17 @@ impl<'a, C, A> TaskUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1407,7 +1419,7 @@ impl<'a, C, A> TaskUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1425,8 +1437,8 @@ impl<'a, C, A> TaskUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Task) -> TaskUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Task) -> TaskUpdateCall<'a, C, A> { + self._request = new_value; self } /// Task list identifier. @@ -1533,7 +1545,7 @@ impl<'a, C, A> TaskUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.tasks().patch(&req, "tasklist", "task") +/// let result = hub.tasks().patch(req, "tasklist", "task") /// .doit(); /// # } /// ``` @@ -1663,12 +1675,17 @@ impl<'a, C, A> TaskPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1677,7 +1694,7 @@ impl<'a, C, A> TaskPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1695,8 +1712,8 @@ impl<'a, C, A> TaskPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Task) -> TaskPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Task) -> TaskPatchCall<'a, C, A> { + self._request = new_value; self } /// Task list identifier. @@ -1915,12 +1932,17 @@ impl<'a, C, A> TaskClearCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -2151,12 +2173,17 @@ impl<'a, C, A> TaskMoveCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2165,7 +2192,7 @@ impl<'a, C, A> TaskMoveCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2410,12 +2437,17 @@ impl<'a, C, A> TaskDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -2646,12 +2678,17 @@ impl<'a, C, A> TaskGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2660,7 +2697,7 @@ impl<'a, C, A> TaskGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2777,7 +2814,7 @@ impl<'a, C, A> TaskGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.tasks().insert(&req, "tasklist") +/// let result = hub.tasks().insert(req, "tasklist") /// .previous("ut") /// .parent("ea") /// .doit(); @@ -2915,12 +2952,17 @@ impl<'a, C, A> TaskInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2929,7 +2971,7 @@ impl<'a, C, A> TaskInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2947,8 +2989,8 @@ impl<'a, C, A> TaskInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Task) -> TaskInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Task) -> TaskInsertCall<'a, C, A> { + self._request = new_value; self } /// Task list identifier. @@ -3156,12 +3198,17 @@ impl<'a, C, A> TasklistListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3170,7 +3217,7 @@ impl<'a, C, A> TasklistListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3281,7 +3328,7 @@ impl<'a, C, A> TasklistListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.tasklists().update(&req, "tasklist") +/// let result = hub.tasklists().update(req, "tasklist") /// .doit(); /// # } /// ``` @@ -3409,12 +3456,17 @@ impl<'a, C, A> TasklistUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3423,7 +3475,7 @@ impl<'a, C, A> TasklistUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3441,8 +3493,8 @@ impl<'a, C, A> TasklistUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &TaskList) -> TasklistUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: TaskList) -> TasklistUpdateCall<'a, C, A> { + self._request = new_value; self } /// Task list identifier. @@ -3651,12 +3703,17 @@ impl<'a, C, A> TasklistDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -3762,7 +3819,7 @@ impl<'a, C, A> TasklistDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.tasklists().patch(&req, "tasklist") +/// let result = hub.tasklists().patch(req, "tasklist") /// .doit(); /// # } /// ``` @@ -3890,12 +3947,17 @@ impl<'a, C, A> TasklistPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3904,7 +3966,7 @@ impl<'a, C, A> TasklistPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3922,8 +3984,8 @@ impl<'a, C, A> TasklistPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &TaskList) -> TasklistPatchCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: TaskList) -> TasklistPatchCall<'a, C, A> { + self._request = new_value; self } /// Task list identifier. @@ -4020,7 +4082,7 @@ impl<'a, C, A> TasklistPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.tasklists().insert(&req) +/// let result = hub.tasklists().insert(req) /// .doit(); /// # } /// ``` @@ -4122,12 +4184,17 @@ impl<'a, C, A> TasklistInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4136,7 +4203,7 @@ impl<'a, C, A> TasklistInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -4154,8 +4221,8 @@ impl<'a, C, A> TasklistInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &TaskList) -> TasklistInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: TaskList) -> TasklistInsertCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -4355,12 +4422,17 @@ impl<'a, C, A> TasklistGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -4369,7 +4441,7 @@ impl<'a, C, A> TasklistGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/translate2-cli/Cargo.toml b/gen/translate2-cli/Cargo.toml index ac8c9091fc..11297d359e 100644 --- a/gen/translate2-cli/Cargo.toml +++ b/gen/translate2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-translate2-cli" -version = "0.0.1+20141123" +version = "0.1.0+20141123" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with translate (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/translate2-cli" diff --git a/gen/translate2-cli/README.md b/gen/translate2-cli/README.md index 648e8e8fe7..a03562c420 100644 --- a/gen/translate2-cli/README.md +++ b/gen/translate2-cli/README.md @@ -1,4 +1,100 @@ -# HELLO TRANSLATE:V2 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `translate2` command-line interface *(CLI)* allows to use most features of the *Google translate* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *translate* API at revision *20141123*. The CLI is at version *0.1.0*. + +```bash + translate2 [options] detections list <q>... [-p <v>...] [-o <out>] + translate2 [options] languages list [-p <v>...] [-o <out>] + translate2 [options] translations list <q>... <target> [-p <v>...] [-o <out>] + translate2 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_translate2_cli/index.html + +Configuration: + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `translate2-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/translate2-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/translate2-secret.json`, assuming that the required *translate* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `translate2 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/translate2-cli/mkdocs.yml b/gen/translate2-cli/mkdocs.yml index 7bf15057d0..6892eb4424 100644 --- a/gen/translate2-cli/mkdocs.yml +++ b/gen/translate2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: translate v0.0.1+20141123 +site_name: translate v0.1.0+20141123 site_url: http://byron.github.io/google-apis-rs/google-translate2-cli site_description: Write integrating applications with bcore diff --git a/gen/translate2-cli/src/cmn.rs b/gen/translate2-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/translate2-cli/src/cmn.rs +++ b/gen/translate2-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/translate2-cli/src/main.rs b/gen/translate2-cli/src/main.rs index 18f49370ee..c1e8e995f3 100644 --- a/gen/translate2-cli/src/main.rs +++ b/gen/translate2-cli/src/main.rs @@ -19,24 +19,25 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - translate2 [options] detections list <q>... [-p <v>]... [-o <out>] - translate2 [options] languages list [-p <v>]... [-o <out>] - translate2 [options] translations list <q>... <target> [-p <v>]... [-o <out>] + translate2 [options] detections list <q>... [-p <v>...] [-o <out>] + translate2 [options] languages list [-p <v>...] [-o <out>] + translate2 [options] translations list <q>... <target> [-p <v>...] [-o <out>] translate2 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_translate2_cli/index.html Configuration: --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -290,6 +291,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -297,8 +299,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/translate2/Cargo.toml b/gen/translate2/Cargo.toml index 2059932bac..f7747801f2 100644 --- a/gen/translate2/Cargo.toml +++ b/gen/translate2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-translate2" -version = "0.1.5+20141123" +version = "0.1.6+20141123" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with translate (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/translate2" diff --git a/gen/translate2/README.md b/gen/translate2/README.md index 83f8dbf17e..9c33cf73ec 100644 --- a/gen/translate2/README.md +++ b/gen/translate2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-translate2` library allows access to all features of the *Google translate* service. -This documentation was generated from *translate* crate version *0.1.5+20141123*, where *20141123* is the exact revision of the *translate:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *translate* crate version *0.1.6+20141123*, where *20141123* is the exact revision of the *translate:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *translate* *v2* API can be found at the [official documentation site](https://developers.google.com/translate/v2/using_rest). @@ -103,14 +103,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/translate2/src/cmn.rs b/gen/translate2/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/translate2/src/cmn.rs +++ b/gen/translate2/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/translate2/src/lib.rs b/gen/translate2/src/lib.rs index 9986d7ff27..ef92eeb6e6 100644 --- a/gen/translate2/src/lib.rs +++ b/gen/translate2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *translate* crate version *0.1.5+20141123*, where *20141123* is the exact revision of the *translate:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *translate* crate version *0.1.6+20141123*, where *20141123* is the exact revision of the *translate:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *translate* *v2* API can be found at the //! [official documentation site](https://developers.google.com/translate/v2/using_rest). @@ -104,14 +104,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -199,7 +200,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -251,14 +252,15 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -279,7 +281,7 @@ impl<'a, C, A> Translate<C, A> Translate { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -294,7 +296,7 @@ impl<'a, C, A> Translate<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -733,12 +735,17 @@ impl<'a, C, A> LanguageListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -747,7 +754,7 @@ impl<'a, C, A> LanguageListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -923,12 +930,17 @@ impl<'a, C, A> DetectionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -937,7 +949,7 @@ impl<'a, C, A> DetectionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1138,12 +1150,17 @@ impl<'a, C, A> TranslationListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1152,7 +1169,7 @@ impl<'a, C, A> TranslationListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/urlshortener1-cli/Cargo.toml b/gen/urlshortener1-cli/Cargo.toml index 5166d4db8c..7ebbf1ab90 100644 --- a/gen/urlshortener1-cli/Cargo.toml +++ b/gen/urlshortener1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-urlshortener1-cli" -version = "0.0.1+20150319" +version = "0.1.0+20150319" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with urlshortener (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/urlshortener1-cli" diff --git a/gen/urlshortener1-cli/README.md b/gen/urlshortener1-cli/README.md index 90ebf7b465..4b00239289 100644 --- a/gen/urlshortener1-cli/README.md +++ b/gen/urlshortener1-cli/README.md @@ -1,4 +1,104 @@ -# HELLO URLSHORTENER:V1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `urlshortener1` command-line interface *(CLI)* allows to use most features of the *Google urlshortener* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *urlshortener* API at revision *20150319*. The CLI is at version *0.1.0*. + +```bash + urlshortener1 [options] url get <short-url> [-p <v>...] [-o <out>] + urlshortener1 [options] url insert -r <kv>... [-p <v>...] [-o <out>] + urlshortener1 [options] url list [-p <v>...] [-o <out>] + urlshortener1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_urlshortener1_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `urlshortener1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/urlshortener1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/urlshortener1-secret.json`, assuming that the required *urlshortener* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `urlshortener1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/urlshortener1-cli/mkdocs.yml b/gen/urlshortener1-cli/mkdocs.yml index d5f3db5303..164989dafb 100644 --- a/gen/urlshortener1-cli/mkdocs.yml +++ b/gen/urlshortener1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: urlshortener v0.0.1+20150319 +site_name: urlshortener v0.1.0+20150319 site_url: http://byron.github.io/google-apis-rs/google-urlshortener1-cli site_description: Write integrating applications with bcore diff --git a/gen/urlshortener1-cli/src/cmn.rs b/gen/urlshortener1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/urlshortener1-cli/src/cmn.rs +++ b/gen/urlshortener1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/urlshortener1-cli/src/main.rs b/gen/urlshortener1-cli/src/main.rs index e18855c576..c85f416222 100644 --- a/gen/urlshortener1-cli/src/main.rs +++ b/gen/urlshortener1-cli/src/main.rs @@ -19,28 +19,29 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - urlshortener1 [options] url get <short-url> [-p <v>]... [-o <out>] - urlshortener1 [options] url insert -r <kv>... [-p <v>]... [-o <out>] - urlshortener1 [options] url list [-p <v>]... [-o <out>] + urlshortener1 [options] url get <short-url> [-p <v>...] [-o <out>] + urlshortener1 [options] url insert -r <kv>... [-p <v>...] [-o <out>] + urlshortener1 [options] url list [-p <v>...] [-o <out>] urlshortener1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_urlshortener1_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -92,6 +93,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -108,36 +112,23 @@ impl Engine { fn _url_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Url::default(); - let mut call = self.hub.url().insert(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Url::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_analytics_all_time_init(request: &mut api::Url) { request_analytics_init(request); if request.analytics.as_mut().unwrap().all_time.is_none() { @@ -179,7 +170,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); }, @@ -238,15 +229,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.url().insert(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -296,6 +312,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -393,6 +412,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -400,8 +420,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/urlshortener1/Cargo.toml b/gen/urlshortener1/Cargo.toml index 0de65ad41d..a7df426000 100644 --- a/gen/urlshortener1/Cargo.toml +++ b/gen/urlshortener1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-urlshortener1" -version = "0.1.5+20150319" +version = "0.1.6+20150319" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with urlshortener (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/urlshortener1" diff --git a/gen/urlshortener1/README.md b/gen/urlshortener1/README.md index 503295e472..b841bbfb86 100644 --- a/gen/urlshortener1/README.md +++ b/gen/urlshortener1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-urlshortener1` library allows access to all features of the *Google urlshortener* service. -This documentation was generated from *urlshortener* crate version *0.1.5+20150319*, where *20150319* is the exact revision of the *urlshortener:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *urlshortener* crate version *0.1.6+20150319*, where *20150319* is the exact revision of the *urlshortener:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *urlshortener* *v1* API can be found at the [official documentation site](https://developers.google.com/url-shortener/v1/getting_started). @@ -101,14 +101,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/urlshortener1/src/cmn.rs b/gen/urlshortener1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/urlshortener1/src/cmn.rs +++ b/gen/urlshortener1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/urlshortener1/src/lib.rs b/gen/urlshortener1/src/lib.rs index 9f7ffcd2b9..c5de748143 100644 --- a/gen/urlshortener1/src/lib.rs +++ b/gen/urlshortener1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *urlshortener* crate version *0.1.5+20150319*, where *20150319* is the exact revision of the *urlshortener:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *urlshortener* crate version *0.1.6+20150319*, where *20150319* is the exact revision of the *urlshortener:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *urlshortener* *v1* API can be found at the //! [official documentation site](https://developers.google.com/url-shortener/v1/getting_started). @@ -102,14 +102,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -197,7 +198,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -272,14 +273,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -300,7 +302,7 @@ impl<'a, C, A> Urlshortener<C, A> Urlshortener { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -309,7 +311,7 @@ impl<'a, C, A> Urlshortener<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -496,10 +498,10 @@ impl<'a, C, A> UrlMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &Url) -> UrlInsertCall<'a, C, A> { + pub fn insert(&self, request: Url) -> UrlInsertCall<'a, C, A> { UrlInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -579,7 +581,7 @@ impl<'a, C, A> UrlMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.url().insert(&req) +/// let result = hub.url().insert(req) /// .doit(); /// # } /// ``` @@ -681,12 +683,17 @@ impl<'a, C, A> UrlInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -695,7 +702,7 @@ impl<'a, C, A> UrlInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -713,8 +720,8 @@ impl<'a, C, A> UrlInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Url) -> UrlInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Url) -> UrlInsertCall<'a, C, A> { + self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -895,12 +902,17 @@ impl<'a, C, A> UrlGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -909,7 +921,7 @@ impl<'a, C, A> UrlGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1120,12 +1132,17 @@ impl<'a, C, A> UrlListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1134,7 +1151,7 @@ impl<'a, C, A> UrlListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/webfonts1-cli/Cargo.toml b/gen/webfonts1-cli/Cargo.toml index 983f237653..69c03e8f27 100644 --- a/gen/webfonts1-cli/Cargo.toml +++ b/gen/webfonts1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-webfonts1-cli" -version = "0.0.1+20140210" +version = "0.1.0+20140210" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with webfonts (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/webfonts1-cli" diff --git a/gen/webfonts1-cli/README.md b/gen/webfonts1-cli/README.md index 5c37fe560e..b6ba14d77f 100644 --- a/gen/webfonts1-cli/README.md +++ b/gen/webfonts1-cli/README.md @@ -1,4 +1,98 @@ -# HELLO WEBFONTS:V1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `webfonts1` command-line interface *(CLI)* allows to use most features of the *Google webfonts* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *webfonts* API at revision *20140210*. The CLI is at version *0.1.0*. + +```bash + webfonts1 [options] webfonts list [-p <v>...] [-o <out>] + webfonts1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_webfonts1_cli/index.html + +Configuration: + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `webfonts1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/webfonts1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/webfonts1-secret.json`, assuming that the required *webfonts* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `webfonts1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/webfonts1-cli/mkdocs.yml b/gen/webfonts1-cli/mkdocs.yml index 924720343c..7ec4e39d12 100644 --- a/gen/webfonts1-cli/mkdocs.yml +++ b/gen/webfonts1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: webfonts v0.0.1+20140210 +site_name: webfonts v0.1.0+20140210 site_url: http://byron.github.io/google-apis-rs/google-webfonts1-cli site_description: Write integrating applications with bcore diff --git a/gen/webfonts1-cli/src/cmn.rs b/gen/webfonts1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/webfonts1-cli/src/cmn.rs +++ b/gen/webfonts1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/webfonts1-cli/src/main.rs b/gen/webfonts1-cli/src/main.rs index 6b9e60aeea..c3be446659 100644 --- a/gen/webfonts1-cli/src/main.rs +++ b/gen/webfonts1-cli/src/main.rs @@ -19,22 +19,23 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - webfonts1 [options] webfonts list [-p <v>]... [-o <out>] + webfonts1 [options] webfonts list [-p <v>...] [-o <out>] webfonts1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_webfonts1_cli/index.html Configuration: --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -179,6 +180,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -186,8 +188,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/webfonts1/Cargo.toml b/gen/webfonts1/Cargo.toml index 0d24829441..015c3cca46 100644 --- a/gen/webfonts1/Cargo.toml +++ b/gen/webfonts1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-webfonts1" -version = "0.1.5+20140210" +version = "0.1.6+20140210" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with webfonts (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/webfonts1" diff --git a/gen/webfonts1/README.md b/gen/webfonts1/README.md index 548e3c2012..85632c51c8 100644 --- a/gen/webfonts1/README.md +++ b/gen/webfonts1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-webfonts1` library allows access to all features of the *Google webfonts* service. -This documentation was generated from *webfonts* crate version *0.1.5+20140210*, where *20140210* is the exact revision of the *webfonts:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *webfonts* crate version *0.1.6+20140210*, where *20140210* is the exact revision of the *webfonts:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *webfonts* *v1* API can be found at the [official documentation site](https://developers.google.com/fonts/docs/developer_api). @@ -100,14 +100,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/webfonts1/src/cmn.rs b/gen/webfonts1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/webfonts1/src/cmn.rs +++ b/gen/webfonts1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/webfonts1/src/lib.rs b/gen/webfonts1/src/lib.rs index ec54241041..4905cb88f8 100644 --- a/gen/webfonts1/src/lib.rs +++ b/gen/webfonts1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *webfonts* crate version *0.1.5+20140210*, where *20140210* is the exact revision of the *webfonts:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *webfonts* crate version *0.1.6+20140210*, where *20140210* is the exact revision of the *webfonts:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *webfonts* *v1* API can be found at the //! [official documentation site](https://developers.google.com/fonts/docs/developer_api). @@ -101,14 +101,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -196,7 +197,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -249,14 +250,15 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -277,7 +279,7 @@ impl<'a, C, A> Webfonts<C, A> Webfonts { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -286,7 +288,7 @@ impl<'a, C, A> Webfonts<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -534,12 +536,17 @@ impl<'a, C, A> WebfontListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -548,7 +555,7 @@ impl<'a, C, A> WebfontListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; diff --git a/gen/webmasters3-cli/Cargo.toml b/gen/webmasters3-cli/Cargo.toml index e22feac9be..0851fd2030 100644 --- a/gen/webmasters3-cli/Cargo.toml +++ b/gen/webmasters3-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-webmasters3-cli" -version = "0.0.1+20140908" +version = "0.1.0+20140908" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with webmasters (protocol v3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/webmasters3-cli" diff --git a/gen/webmasters3-cli/README.md b/gen/webmasters3-cli/README.md index 4dd6d812ad..9dbd49e80e 100644 --- a/gen/webmasters3-cli/README.md +++ b/gen/webmasters3-cli/README.md @@ -1,4 +1,113 @@ -# HELLO WEBMASTERS:V3 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `webmasters3` command-line interface *(CLI)* allows to use most features of the *Google webmasters* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *webmasters* API at revision *20140908*. The CLI is at version *0.1.0*. + +```bash + webmasters3 [options] sitemaps delete <site-url> <feedpath> [-p <v>...] + webmasters3 [options] sitemaps get <site-url> <feedpath> [-p <v>...] [-o <out>] + webmasters3 [options] sitemaps list <site-url> [-p <v>...] [-o <out>] + webmasters3 [options] sitemaps submit <site-url> <feedpath> [-p <v>...] + webmasters3 [options] sites add <site-url> [-p <v>...] + webmasters3 [options] sites delete <site-url> [-p <v>...] + webmasters3 [options] sites get <site-url> [-p <v>...] [-o <out>] + webmasters3 [options] sites list [-p <v>...] [-o <out>] + webmasters3 [options] urlcrawlerrorscounts query <site-url> [-p <v>...] [-o <out>] + webmasters3 [options] urlcrawlerrorssamples get <site-url> <url> <category> <platform> [-p <v>...] [-o <out>] + webmasters3 [options] urlcrawlerrorssamples list <site-url> <category> <platform> [-p <v>...] [-o <out>] + webmasters3 [options] urlcrawlerrorssamples mark-as-fixed <site-url> <url> <category> <platform> [-p <v>...] + webmasters3 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_webmasters3_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `webmasters3-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/webmasters3-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/webmasters3-secret.json`, assuming that the required *webmasters* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `webmasters3 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/webmasters3-cli/mkdocs.yml b/gen/webmasters3-cli/mkdocs.yml index 37c5f7b19a..bc8e5aa82c 100644 --- a/gen/webmasters3-cli/mkdocs.yml +++ b/gen/webmasters3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: webmasters v0.0.1+20140908 +site_name: webmasters v0.1.0+20140908 site_url: http://byron.github.io/google-apis-rs/google-webmasters3-cli site_description: Write integrating applications with bcore diff --git a/gen/webmasters3-cli/src/cmn.rs b/gen/webmasters3-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/webmasters3-cli/src/cmn.rs +++ b/gen/webmasters3-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/webmasters3-cli/src/main.rs b/gen/webmasters3-cli/src/main.rs index 8d99c6e982..b6297ff616 100644 --- a/gen/webmasters3-cli/src/main.rs +++ b/gen/webmasters3-cli/src/main.rs @@ -19,37 +19,38 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - webmasters3 [options] sitemaps delete <site-url> <feedpath> [-p <v>]... - webmasters3 [options] sitemaps get <site-url> <feedpath> [-p <v>]... [-o <out>] - webmasters3 [options] sitemaps list <site-url> [-p <v>]... [-o <out>] - webmasters3 [options] sitemaps submit <site-url> <feedpath> [-p <v>]... - webmasters3 [options] sites add <site-url> [-p <v>]... - webmasters3 [options] sites delete <site-url> [-p <v>]... - webmasters3 [options] sites get <site-url> [-p <v>]... [-o <out>] - webmasters3 [options] sites list [-p <v>]... [-o <out>] - webmasters3 [options] urlcrawlerrorscounts query <site-url> [-p <v>]... [-o <out>] - webmasters3 [options] urlcrawlerrorssamples get <site-url> <url> <category> <platform> [-p <v>]... [-o <out>] - webmasters3 [options] urlcrawlerrorssamples list <site-url> <category> <platform> [-p <v>]... [-o <out>] - webmasters3 [options] urlcrawlerrorssamples mark-as-fixed <site-url> <url> <category> <platform> [-p <v>]... + webmasters3 [options] sitemaps delete <site-url> <feedpath> [-p <v>...] + webmasters3 [options] sitemaps get <site-url> <feedpath> [-p <v>...] [-o <out>] + webmasters3 [options] sitemaps list <site-url> [-p <v>...] [-o <out>] + webmasters3 [options] sitemaps submit <site-url> <feedpath> [-p <v>...] + webmasters3 [options] sites add <site-url> [-p <v>...] + webmasters3 [options] sites delete <site-url> [-p <v>...] + webmasters3 [options] sites get <site-url> [-p <v>...] [-o <out>] + webmasters3 [options] sites list [-p <v>...] [-o <out>] + webmasters3 [options] urlcrawlerrorscounts query <site-url> [-p <v>...] [-o <out>] + webmasters3 [options] urlcrawlerrorssamples get <site-url> <url> <category> <platform> [-p <v>...] [-o <out>] + webmasters3 [options] urlcrawlerrorssamples list <site-url> <category> <platform> [-p <v>...] [-o <out>] + webmasters3 [options] urlcrawlerrorssamples mark-as-fixed <site-url> <url> <category> <platform> [-p <v>...] webmasters3 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_webmasters3_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -98,6 +99,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -139,6 +143,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -185,6 +192,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -228,6 +238,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -269,6 +282,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -310,6 +326,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -351,6 +370,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -394,6 +416,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -446,6 +471,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -489,6 +517,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -532,6 +563,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -575,6 +609,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -703,6 +740,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -710,8 +748,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/webmasters3/Cargo.toml b/gen/webmasters3/Cargo.toml index f5fdc50a4d..86838f8148 100644 --- a/gen/webmasters3/Cargo.toml +++ b/gen/webmasters3/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-webmasters3" -version = "0.1.5+20140908" +version = "0.1.6+20140908" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with webmasters (protocol v3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/webmasters3" diff --git a/gen/webmasters3/README.md b/gen/webmasters3/README.md index 73c5b0eb88..2247c5f8b0 100644 --- a/gen/webmasters3/README.md +++ b/gen/webmasters3/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-webmasters3` library allows access to all features of the *Google webmasters* service. -This documentation was generated from *webmasters* crate version *0.1.5+20140908*, where *20140908* is the exact revision of the *webmasters:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *webmasters* crate version *0.1.6+20140908*, where *20140908* is the exact revision of the *webmasters:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *webmasters* *v3* API can be found at the [official documentation site](https://developers.google.com/webmaster-tools/v3/welcome). @@ -105,14 +105,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/webmasters3/src/cmn.rs b/gen/webmasters3/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/webmasters3/src/cmn.rs +++ b/gen/webmasters3/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/webmasters3/src/lib.rs b/gen/webmasters3/src/lib.rs index 1c53a9060b..574c0aa9f7 100644 --- a/gen/webmasters3/src/lib.rs +++ b/gen/webmasters3/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *webmasters* crate version *0.1.5+20140908*, where *20140908* is the exact revision of the *webmasters:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *webmasters* crate version *0.1.6+20140908*, where *20140908* is the exact revision of the *webmasters:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *webmasters* *v3* API can be found at the //! [official documentation site](https://developers.google.com/webmaster-tools/v3/welcome). @@ -106,14 +106,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -201,7 +202,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -279,14 +280,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -307,7 +309,7 @@ impl<'a, C, A> Webmasters<C, A> Webmasters { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -325,7 +327,7 @@ impl<'a, C, A> Webmasters<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -1118,12 +1120,17 @@ impl<'a, C, A> SitemapDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -1353,12 +1360,17 @@ impl<'a, C, A> SitemapSubmitCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -1589,12 +1601,17 @@ impl<'a, C, A> SitemapGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1603,7 +1620,7 @@ impl<'a, C, A> SitemapGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1838,12 +1855,17 @@ impl<'a, C, A> SitemapListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1852,7 +1874,7 @@ impl<'a, C, A> SitemapListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2079,12 +2101,17 @@ impl<'a, C, A> SiteGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2093,7 +2120,7 @@ impl<'a, C, A> SiteGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2312,12 +2339,17 @@ impl<'a, C, A> SiteAddCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -2510,12 +2542,17 @@ impl<'a, C, A> SiteListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2524,7 +2561,7 @@ impl<'a, C, A> SiteListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2733,12 +2770,17 @@ impl<'a, C, A> SiteDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -2972,12 +3014,17 @@ impl<'a, C, A> UrlcrawlerrorscountQueryCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2986,7 +3033,7 @@ impl<'a, C, A> UrlcrawlerrorscountQueryCall<'a, C, A> where C: BorrowMut<hyper:: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3233,12 +3280,17 @@ impl<'a, C, A> UrlcrawlerrorssampleGetCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3247,7 +3299,7 @@ impl<'a, C, A> UrlcrawlerrorssampleGetCall<'a, C, A> where C: BorrowMut<hyper::C Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3501,12 +3553,17 @@ impl<'a, C, A> UrlcrawlerrorssampleListCall<'a, C, A> where C: BorrowMut<hyper:: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3515,7 +3572,7 @@ impl<'a, C, A> UrlcrawlerrorssampleListCall<'a, C, A> where C: BorrowMut<hyper:: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3760,12 +3817,17 @@ impl<'a, C, A> UrlcrawlerrorssampleMarkAsFixedCall<'a, C, A> where C: BorrowMut< if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; diff --git a/gen/youtube3-cli/Cargo.toml b/gen/youtube3-cli/Cargo.toml index 39f8a690c8..7a09ca4983 100644 --- a/gen/youtube3-cli/Cargo.toml +++ b/gen/youtube3-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-youtube3-cli" -version = "0.0.1+20150414" +version = "0.1.0+20150414" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with YouTube (protocol v3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/youtube3-cli" diff --git a/gen/youtube3-cli/README.md b/gen/youtube3-cli/README.md index a7c7291d0d..75e71df54b 100644 --- a/gen/youtube3-cli/README.md +++ b/gen/youtube3-cli/README.md @@ -1,4 +1,162 @@ -# HELLO YOUTUBE:V3 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `youtube3` command-line interface *(CLI)* allows to use most features of the *Google YouTube* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *YouTube* API at revision *20150414*. The CLI is at version *0.1.0*. + +```bash + youtube3 [options] activities insert -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] activities list <part> [-p <v>...] [-o <out>] + youtube3 [options] captions delete <id> [-p <v>...] + youtube3 [options] captions download <id> [-p <v>...] [-o <out>] + youtube3 [options] captions insert -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + youtube3 [options] captions list <part> <video-id> [-p <v>...] [-o <out>] + youtube3 [options] captions update -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + youtube3 [options] channel-banners insert -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + youtube3 [options] channel-sections delete <id> [-p <v>...] + youtube3 [options] channel-sections insert -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] channel-sections list <part> [-p <v>...] [-o <out>] + youtube3 [options] channel-sections update -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] channels list <part> [-p <v>...] [-o <out>] + youtube3 [options] channels update -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] comment-threads insert -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] comment-threads list <part> [-p <v>...] [-o <out>] + youtube3 [options] comment-threads update -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] comments delete <id> [-p <v>...] + youtube3 [options] comments insert -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] comments list <part> [-p <v>...] [-o <out>] + youtube3 [options] comments mark-as-spam <id> [-p <v>...] + youtube3 [options] comments set-moderation-status <id> <moderation-status> [-p <v>...] + youtube3 [options] comments update -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] guide-categories list <part> [-p <v>...] [-o <out>] + youtube3 [options] i18n-languages list <part> [-p <v>...] [-o <out>] + youtube3 [options] i18n-regions list <part> [-p <v>...] [-o <out>] + youtube3 [options] live-broadcasts bind <id> <part> [-p <v>...] [-o <out>] + youtube3 [options] live-broadcasts control <id> <part> [-p <v>...] [-o <out>] + youtube3 [options] live-broadcasts delete <id> [-p <v>...] + youtube3 [options] live-broadcasts insert -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] live-broadcasts list <part> [-p <v>...] [-o <out>] + youtube3 [options] live-broadcasts transition <broadcast-status> <id> <part> [-p <v>...] [-o <out>] + youtube3 [options] live-broadcasts update -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] live-streams delete <id> [-p <v>...] + youtube3 [options] live-streams insert -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] live-streams list <part> [-p <v>...] [-o <out>] + youtube3 [options] live-streams update -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] playlist-items delete <id> [-p <v>...] + youtube3 [options] playlist-items insert -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] playlist-items list <part> [-p <v>...] [-o <out>] + youtube3 [options] playlist-items update -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] playlists delete <id> [-p <v>...] + youtube3 [options] playlists insert -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] playlists list <part> [-p <v>...] [-o <out>] + youtube3 [options] playlists update -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] search list <part> [-p <v>...] [-o <out>] + youtube3 [options] subscriptions delete <id> [-p <v>...] + youtube3 [options] subscriptions insert -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] subscriptions list <part> [-p <v>...] [-o <out>] + youtube3 [options] thumbnails set <video-id> -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + youtube3 [options] video-abuse-report-reasons list <part> [-p <v>...] [-o <out>] + youtube3 [options] video-categories list <part> [-p <v>...] [-o <out>] + youtube3 [options] videos delete <id> [-p <v>...] + youtube3 [options] videos get-rating <id> [-p <v>...] [-o <out>] + youtube3 [options] videos insert -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + youtube3 [options] videos list <part> [-p <v>...] [-o <out>] + youtube3 [options] videos rate <id> <rating> [-p <v>...] + youtube3 [options] videos report-abuse -r <kv>... [-p <v>...] + youtube3 [options] videos update -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] watermarks set <channel-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] + youtube3 [options] watermarks unset <channel-id> [-p <v>...] + youtube3 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_youtube3_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `youtube3-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/youtube3-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/youtube3-secret.json`, assuming that the required *youtube* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `youtube3 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/youtube3-cli/mkdocs.yml b/gen/youtube3-cli/mkdocs.yml index 44340c536a..8bd38a256e 100644 --- a/gen/youtube3-cli/mkdocs.yml +++ b/gen/youtube3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: YouTube v0.0.1+20150414 +site_name: YouTube v0.1.0+20150414 site_url: http://byron.github.io/google-apis-rs/google-youtube3-cli site_description: Write integrating applications with bcore diff --git a/gen/youtube3-cli/src/cmn.rs b/gen/youtube3-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/youtube3-cli/src/cmn.rs +++ b/gen/youtube3-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/youtube3-cli/src/main.rs b/gen/youtube3-cli/src/main.rs index a79573a9b6..0bbf6d0318 100644 --- a/gen/youtube3-cli/src/main.rs +++ b/gen/youtube3-cli/src/main.rs @@ -19,86 +19,87 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - youtube3 [options] activities insert -r <kv>... [-p <v>]... [-o <out>] - youtube3 [options] activities list <part> [-p <v>]... [-o <out>] - youtube3 [options] captions delete <id> [-p <v>]... - youtube3 [options] captions download <id> [-p <v>]... [-o <out>] - youtube3 [options] captions insert -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] - youtube3 [options] captions list <part> <video-id> [-p <v>]... [-o <out>] - youtube3 [options] captions update -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] - youtube3 [options] channel-banners insert -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] - youtube3 [options] channel-sections delete <id> [-p <v>]... - youtube3 [options] channel-sections insert -r <kv>... [-p <v>]... [-o <out>] - youtube3 [options] channel-sections list <part> [-p <v>]... [-o <out>] - youtube3 [options] channel-sections update -r <kv>... [-p <v>]... [-o <out>] - youtube3 [options] channels list <part> [-p <v>]... [-o <out>] - youtube3 [options] channels update -r <kv>... [-p <v>]... [-o <out>] - youtube3 [options] comment-threads insert -r <kv>... [-p <v>]... [-o <out>] - youtube3 [options] comment-threads list <part> [-p <v>]... [-o <out>] - youtube3 [options] comment-threads update -r <kv>... [-p <v>]... [-o <out>] - youtube3 [options] comments delete <id> [-p <v>]... - youtube3 [options] comments insert -r <kv>... [-p <v>]... [-o <out>] - youtube3 [options] comments list <part> [-p <v>]... [-o <out>] - youtube3 [options] comments mark-as-spam <id> [-p <v>]... - youtube3 [options] comments set-moderation-status <id> <moderation-status> [-p <v>]... - youtube3 [options] comments update -r <kv>... [-p <v>]... [-o <out>] - youtube3 [options] guide-categories list <part> [-p <v>]... [-o <out>] - youtube3 [options] i18n-languages list <part> [-p <v>]... [-o <out>] - youtube3 [options] i18n-regions list <part> [-p <v>]... [-o <out>] - youtube3 [options] live-broadcasts bind <id> <part> [-p <v>]... [-o <out>] - youtube3 [options] live-broadcasts control <id> <part> [-p <v>]... [-o <out>] - youtube3 [options] live-broadcasts delete <id> [-p <v>]... - youtube3 [options] live-broadcasts insert -r <kv>... [-p <v>]... [-o <out>] - youtube3 [options] live-broadcasts list <part> [-p <v>]... [-o <out>] - youtube3 [options] live-broadcasts transition <broadcast-status> <id> <part> [-p <v>]... [-o <out>] - youtube3 [options] live-broadcasts update -r <kv>... [-p <v>]... [-o <out>] - youtube3 [options] live-streams delete <id> [-p <v>]... - youtube3 [options] live-streams insert -r <kv>... [-p <v>]... [-o <out>] - youtube3 [options] live-streams list <part> [-p <v>]... [-o <out>] - youtube3 [options] live-streams update -r <kv>... [-p <v>]... [-o <out>] - youtube3 [options] playlist-items delete <id> [-p <v>]... - youtube3 [options] playlist-items insert -r <kv>... [-p <v>]... [-o <out>] - youtube3 [options] playlist-items list <part> [-p <v>]... [-o <out>] - youtube3 [options] playlist-items update -r <kv>... [-p <v>]... [-o <out>] - youtube3 [options] playlists delete <id> [-p <v>]... - youtube3 [options] playlists insert -r <kv>... [-p <v>]... [-o <out>] - youtube3 [options] playlists list <part> [-p <v>]... [-o <out>] - youtube3 [options] playlists update -r <kv>... [-p <v>]... [-o <out>] - youtube3 [options] search list <part> [-p <v>]... [-o <out>] - youtube3 [options] subscriptions delete <id> [-p <v>]... - youtube3 [options] subscriptions insert -r <kv>... [-p <v>]... [-o <out>] - youtube3 [options] subscriptions list <part> [-p <v>]... [-o <out>] - youtube3 [options] thumbnails set <video-id> -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] - youtube3 [options] video-abuse-report-reasons list <part> [-p <v>]... [-o <out>] - youtube3 [options] video-categories list <part> [-p <v>]... [-o <out>] - youtube3 [options] videos delete <id> [-p <v>]... - youtube3 [options] videos get-rating <id> [-p <v>]... [-o <out>] - youtube3 [options] videos insert -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] - youtube3 [options] videos list <part> [-p <v>]... [-o <out>] - youtube3 [options] videos rate <id> <rating> [-p <v>]... - youtube3 [options] videos report-abuse -r <kv>... [-p <v>]... - youtube3 [options] videos update -r <kv>... [-p <v>]... [-o <out>] - youtube3 [options] watermarks set <channel-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>]... - youtube3 [options] watermarks unset <channel-id> [-p <v>]... + youtube3 [options] activities insert -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] activities list <part> [-p <v>...] [-o <out>] + youtube3 [options] captions delete <id> [-p <v>...] + youtube3 [options] captions download <id> [-p <v>...] [-o <out>] + youtube3 [options] captions insert -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + youtube3 [options] captions list <part> <video-id> [-p <v>...] [-o <out>] + youtube3 [options] captions update -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + youtube3 [options] channel-banners insert -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + youtube3 [options] channel-sections delete <id> [-p <v>...] + youtube3 [options] channel-sections insert -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] channel-sections list <part> [-p <v>...] [-o <out>] + youtube3 [options] channel-sections update -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] channels list <part> [-p <v>...] [-o <out>] + youtube3 [options] channels update -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] comment-threads insert -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] comment-threads list <part> [-p <v>...] [-o <out>] + youtube3 [options] comment-threads update -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] comments delete <id> [-p <v>...] + youtube3 [options] comments insert -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] comments list <part> [-p <v>...] [-o <out>] + youtube3 [options] comments mark-as-spam <id> [-p <v>...] + youtube3 [options] comments set-moderation-status <id> <moderation-status> [-p <v>...] + youtube3 [options] comments update -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] guide-categories list <part> [-p <v>...] [-o <out>] + youtube3 [options] i18n-languages list <part> [-p <v>...] [-o <out>] + youtube3 [options] i18n-regions list <part> [-p <v>...] [-o <out>] + youtube3 [options] live-broadcasts bind <id> <part> [-p <v>...] [-o <out>] + youtube3 [options] live-broadcasts control <id> <part> [-p <v>...] [-o <out>] + youtube3 [options] live-broadcasts delete <id> [-p <v>...] + youtube3 [options] live-broadcasts insert -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] live-broadcasts list <part> [-p <v>...] [-o <out>] + youtube3 [options] live-broadcasts transition <broadcast-status> <id> <part> [-p <v>...] [-o <out>] + youtube3 [options] live-broadcasts update -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] live-streams delete <id> [-p <v>...] + youtube3 [options] live-streams insert -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] live-streams list <part> [-p <v>...] [-o <out>] + youtube3 [options] live-streams update -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] playlist-items delete <id> [-p <v>...] + youtube3 [options] playlist-items insert -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] playlist-items list <part> [-p <v>...] [-o <out>] + youtube3 [options] playlist-items update -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] playlists delete <id> [-p <v>...] + youtube3 [options] playlists insert -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] playlists list <part> [-p <v>...] [-o <out>] + youtube3 [options] playlists update -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] search list <part> [-p <v>...] [-o <out>] + youtube3 [options] subscriptions delete <id> [-p <v>...] + youtube3 [options] subscriptions insert -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] subscriptions list <part> [-p <v>...] [-o <out>] + youtube3 [options] thumbnails set <video-id> -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + youtube3 [options] video-abuse-report-reasons list <part> [-p <v>...] [-o <out>] + youtube3 [options] video-categories list <part> [-p <v>...] [-o <out>] + youtube3 [options] videos delete <id> [-p <v>...] + youtube3 [options] videos get-rating <id> [-p <v>...] [-o <out>] + youtube3 [options] videos insert -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] [-o <out>] + youtube3 [options] videos list <part> [-p <v>...] [-o <out>] + youtube3 [options] videos rate <id> <rating> [-p <v>...] + youtube3 [options] videos report-abuse -r <kv>... [-p <v>...] + youtube3 [options] videos update -r <kv>... [-p <v>...] [-o <out>] + youtube3 [options] watermarks set <channel-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>...] + youtube3 [options] watermarks unset <channel-id> [-p <v>...] youtube3 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_youtube3_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -120,36 +121,23 @@ struct Engine { impl Engine { fn _activities_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Activity::default(); - let mut call = self.hub.activities().insert(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Activity::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_content_details_bulletin_init(request: &mut api::Activity) { request_content_details_init(request); if request.content_details.as_mut().unwrap().bulletin.is_none() { @@ -351,7 +339,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "snippet.thumbnails.default.url" => { request_snippet_thumbnails_default_init(&mut request); request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); @@ -691,15 +679,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.activities().insert(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -767,6 +780,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -816,6 +832,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -873,6 +892,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -892,52 +914,30 @@ impl Engine { fn _captions_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Caption::default(); - let mut call = self.hub.captions().insert(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "sync" => { - call = call.sync(arg_from_str(value.unwrap_or("false"), err, "sync", "boolean")); - }, - "on-behalf-of" => { - call = call.on_behalf_of(value.unwrap_or("")); - }, - "debug-project-id-override" => { - call = call.debug_project_id_override(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Caption::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_snippet_init(request: &mut api::Caption) { if request.snippet.is_none() { request.snippet = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "snippet.status" => { request_snippet_init(&mut request); request.snippet.as_mut().unwrap().status = Some(value.unwrap_or("").to_string()); @@ -1003,10 +1003,41 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.captions().insert(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "sync" => { + call = call.sync(arg_from_str(value.unwrap_or("false"), err, "sync", "boolean")); + }, + "on-behalf-of" => { + call = call.on_behalf_of(value.unwrap_or("")); + }, + "debug-project-id-override" => { + call = call.debug_project_id_override(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = if self.opt.cmd_simple { "simple" @@ -1021,6 +1052,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -1074,6 +1108,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1090,52 +1127,30 @@ impl Engine { fn _captions_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Caption::default(); - let mut call = self.hub.captions().update(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "sync" => { - call = call.sync(arg_from_str(value.unwrap_or("false"), err, "sync", "boolean")); - }, - "on-behalf-of" => { - call = call.on_behalf_of(value.unwrap_or("")); - }, - "debug-project-id-override" => { - call = call.debug_project_id_override(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Caption::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_snippet_init(request: &mut api::Caption) { if request.snippet.is_none() { request.snippet = Some(Default::default()); } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "snippet.status" => { request_snippet_init(&mut request); request.snippet.as_mut().unwrap().status = Some(value.unwrap_or("").to_string()); @@ -1201,10 +1216,41 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.captions().update(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "sync" => { + call = call.sync(arg_from_str(value.unwrap_or("false"), err, "sync", "boolean")); + }, + "on-behalf-of" => { + call = call.on_behalf_of(value.unwrap_or("")); + }, + "debug-project-id-override" => { + call = call.debug_project_id_override(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = if self.opt.cmd_simple { "simple" @@ -1219,6 +1265,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -1236,8 +1285,39 @@ impl Engine { fn _channel_banners_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::ChannelBannerResource::default(); - let mut call = self.hub.channel_banners().insert(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + match &temp_cursor.to_string()[..] { + "url" => { + request.url = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "etag" => { + request.etag = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.channel_banners().insert(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -1262,28 +1342,6 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "url" => { - request.url = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = if self.opt.cmd_simple { "simple" @@ -1298,6 +1356,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -1345,6 +1406,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -1359,42 +1423,23 @@ impl Engine { fn _channel_sections_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::ChannelSection::default(); - let mut call = self.hub.channel_sections().insert(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "on-behalf-of-content-owner-channel" => { - call = call.on_behalf_of_content_owner_channel(value.unwrap_or("")); - }, - "on-behalf-of-content-owner" => { - call = call.on_behalf_of_content_owner(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ChannelSection::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_content_details_init(request: &mut api::ChannelSection) { if request.content_details.is_none() { request.content_details = Some(Default::default()); @@ -1420,7 +1465,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1496,15 +1541,46 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.channel_sections().insert(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "on-behalf-of-content-owner-channel" => { + call = call.on_behalf_of_content_owner_channel(value.unwrap_or("")); + }, + "on-behalf-of-content-owner" => { + call = call.on_behalf_of_content_owner(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1563,6 +1639,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1579,39 +1658,23 @@ impl Engine { fn _channel_sections_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::ChannelSection::default(); - let mut call = self.hub.channel_sections().update(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "on-behalf-of-content-owner" => { - call = call.on_behalf_of_content_owner(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::ChannelSection::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_content_details_init(request: &mut api::ChannelSection) { if request.content_details.is_none() { request.content_details = Some(Default::default()); @@ -1637,7 +1700,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -1713,15 +1776,43 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.channel_sections().update(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "on-behalf-of-content-owner" => { + call = call.on_behalf_of_content_owner(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1795,6 +1886,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -1811,39 +1905,23 @@ impl Engine { fn _channels_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Channel::default(); - let mut call = self.hub.channels().update(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "on-behalf-of-content-owner" => { - call = call.on_behalf_of_content_owner(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Channel::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_audit_details_init(request: &mut api::Channel) { if request.audit_details.is_none() { request.audit_details = Some(Default::default()); @@ -2059,7 +2137,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status.privacy-status" => { request_status_init(&mut request); request.status.as_mut().unwrap().privacy_status = Some(value.unwrap_or("").to_string()); @@ -2451,38 +2529,16 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _comment_threads_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::CommentThread::default(); - let mut call = self.hub.comment_threads().insert(&request); + let mut call = self.hub.channels().update(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { - "share-on-google-plus" => { - call = call.share_on_google_plus(arg_from_str(value.unwrap_or("false"), err, "share-on-google-plus", "boolean")); + "on-behalf-of-content-owner" => { + call = call.on_behalf_of_content_owner(value.unwrap_or("")); }, "alt" |"fields" @@ -2502,13 +2558,47 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _comment_threads_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::CommentThread::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_snippet_init(request: &mut api::CommentThread) { if request.snippet.is_none() { request.snippet = Some(Default::default()); @@ -2536,7 +2626,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "snippet.is-public" => { request_snippet_init(&mut request); request.snippet.as_mut().unwrap().is_public = Some(arg_from_str(value.unwrap_or("false"), err, "snippet.is-public", "boolean")); @@ -2646,15 +2736,43 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.comment_threads().insert(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "share-on-google-plus" => { + call = call.share_on_google_plus(arg_from_str(value.unwrap_or("false"), err, "share-on-google-plus", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2725,6 +2843,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2741,36 +2862,23 @@ impl Engine { fn _comment_threads_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::CommentThread::default(); - let mut call = self.hub.comment_threads().update(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::CommentThread::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_snippet_init(request: &mut api::CommentThread) { if request.snippet.is_none() { request.snippet = Some(Default::default()); @@ -2798,7 +2906,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "snippet.is-public" => { request_snippet_init(&mut request); request.snippet.as_mut().unwrap().is_public = Some(arg_from_str(value.unwrap_or("false"), err, "snippet.is-public", "boolean")); @@ -2908,15 +3016,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.comment_threads().update(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -2960,6 +3093,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -2974,36 +3110,23 @@ impl Engine { fn _comments_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Comment::default(); - let mut call = self.hub.comments().insert(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Comment::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_snippet_author_channel_id_init(request: &mut api::Comment) { request_snippet_init(request); if request.snippet.as_mut().unwrap().author_channel_id.is_none() { @@ -3017,7 +3140,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "snippet.author-channel-url" => { request_snippet_init(&mut request); request.snippet.as_mut().unwrap().author_channel_url = Some(value.unwrap_or("").to_string()); @@ -3095,15 +3218,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.comments().insert(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3162,6 +3310,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3205,6 +3356,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -3249,6 +3403,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -3263,36 +3420,23 @@ impl Engine { fn _comments_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Comment::default(); - let mut call = self.hub.comments().update(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Comment::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_snippet_author_channel_id_init(request: &mut api::Comment) { request_snippet_init(request); if request.snippet.as_mut().unwrap().author_channel_id.is_none() { @@ -3306,7 +3450,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "snippet.author-channel-url" => { request_snippet_init(&mut request); request.snippet.as_mut().unwrap().author_channel_url = Some(value.unwrap_or("").to_string()); @@ -3384,15 +3528,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.comments().update(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3445,6 +3614,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3491,6 +3663,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3537,6 +3712,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3589,6 +3767,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3647,6 +3828,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -3696,6 +3880,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -3710,42 +3897,23 @@ impl Engine { fn _live_broadcasts_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::LiveBroadcast::default(); - let mut call = self.hub.live_broadcasts().insert(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "on-behalf-of-content-owner-channel" => { - call = call.on_behalf_of_content_owner_channel(value.unwrap_or("")); - }, - "on-behalf-of-content-owner" => { - call = call.on_behalf_of_content_owner(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::LiveBroadcast::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_content_details_init(request: &mut api::LiveBroadcast) { if request.content_details.is_none() { request.content_details = Some(Default::default()); @@ -3813,7 +3981,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status.recording-status" => { request_status_init(&mut request); request.status.as_mut().unwrap().recording_status = Some(value.unwrap_or("").to_string()); @@ -3979,15 +4147,46 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.live_broadcasts().insert(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "on-behalf-of-content-owner-channel" => { + call = call.on_behalf_of_content_owner_channel(value.unwrap_or("")); + }, + "on-behalf-of-content-owner" => { + call = call.on_behalf_of_content_owner(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4052,6 +4251,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4101,6 +4303,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4117,42 +4322,23 @@ impl Engine { fn _live_broadcasts_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::LiveBroadcast::default(); - let mut call = self.hub.live_broadcasts().update(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "on-behalf-of-content-owner-channel" => { - call = call.on_behalf_of_content_owner_channel(value.unwrap_or("")); - }, - "on-behalf-of-content-owner" => { - call = call.on_behalf_of_content_owner(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::LiveBroadcast::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_content_details_init(request: &mut api::LiveBroadcast) { if request.content_details.is_none() { request.content_details = Some(Default::default()); @@ -4220,7 +4406,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status.recording-status" => { request_status_init(&mut request); request.status.as_mut().unwrap().recording_status = Some(value.unwrap_or("").to_string()); @@ -4386,15 +4572,46 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.live_broadcasts().update(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "on-behalf-of-content-owner-channel" => { + call = call.on_behalf_of_content_owner_channel(value.unwrap_or("")); + }, + "on-behalf-of-content-owner" => { + call = call.on_behalf_of_content_owner(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4444,6 +4661,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -4458,42 +4678,23 @@ impl Engine { fn _live_streams_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::LiveStream::default(); - let mut call = self.hub.live_streams().insert(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "on-behalf-of-content-owner-channel" => { - call = call.on_behalf_of_content_owner_channel(value.unwrap_or("")); - }, - "on-behalf-of-content-owner" => { - call = call.on_behalf_of_content_owner(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::LiveStream::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_cdn_ingestion_info_init(request: &mut api::LiveStream) { request_cdn_init(request); if request.cdn.as_mut().unwrap().ingestion_info.is_none() { @@ -4525,7 +4726,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status.is-default-stream" => { request_status_init(&mut request); request.status.as_mut().unwrap().is_default_stream = Some(arg_from_str(value.unwrap_or("false"), err, "status.is-default-stream", "boolean")); @@ -4591,15 +4792,46 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.live_streams().insert(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "on-behalf-of-content-owner-channel" => { + call = call.on_behalf_of_content_owner_channel(value.unwrap_or("")); + }, + "on-behalf-of-content-owner" => { + call = call.on_behalf_of_content_owner(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4661,6 +4893,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4677,42 +4912,23 @@ impl Engine { fn _live_streams_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::LiveStream::default(); - let mut call = self.hub.live_streams().update(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "on-behalf-of-content-owner-channel" => { - call = call.on_behalf_of_content_owner_channel(value.unwrap_or("")); - }, - "on-behalf-of-content-owner" => { - call = call.on_behalf_of_content_owner(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::LiveStream::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_cdn_ingestion_info_init(request: &mut api::LiveStream) { request_cdn_init(request); if request.cdn.as_mut().unwrap().ingestion_info.is_none() { @@ -4744,7 +4960,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status.is-default-stream" => { request_status_init(&mut request); request.status.as_mut().unwrap().is_default_stream = Some(arg_from_str(value.unwrap_or("false"), err, "status.is-default-stream", "boolean")); @@ -4810,15 +5026,46 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.live_streams().update(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "on-behalf-of-content-owner-channel" => { + call = call.on_behalf_of_content_owner_channel(value.unwrap_or("")); + }, + "on-behalf-of-content-owner" => { + call = call.on_behalf_of_content_owner(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -4862,6 +5109,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -4876,39 +5126,23 @@ impl Engine { fn _playlist_items_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::PlaylistItem::default(); - let mut call = self.hub.playlist_items().insert(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "on-behalf-of-content-owner" => { - call = call.on_behalf_of_content_owner(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::PlaylistItem::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_content_details_init(request: &mut api::PlaylistItem) { if request.content_details.is_none() { request.content_details = Some(Default::default()); @@ -4976,7 +5210,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status.privacy-status" => { request_status_init(&mut request); request.status.as_mut().unwrap().privacy_status = Some(value.unwrap_or("").to_string()); @@ -5114,15 +5348,43 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.playlist_items().insert(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "on-behalf-of-content-owner" => { + call = call.on_behalf_of_content_owner(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5184,6 +5446,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5200,36 +5465,23 @@ impl Engine { fn _playlist_items_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::PlaylistItem::default(); - let mut call = self.hub.playlist_items().update(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::PlaylistItem::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_content_details_init(request: &mut api::PlaylistItem) { if request.content_details.is_none() { request.content_details = Some(Default::default()); @@ -5297,7 +5549,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status.privacy-status" => { request_status_init(&mut request); request.status.as_mut().unwrap().privacy_status = Some(value.unwrap_or("").to_string()); @@ -5435,15 +5687,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.playlist_items().update(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5490,6 +5767,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -5504,42 +5784,23 @@ impl Engine { fn _playlists_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Playlist::default(); - let mut call = self.hub.playlists().insert(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "on-behalf-of-content-owner-channel" => { - call = call.on_behalf_of_content_owner_channel(value.unwrap_or("")); - }, - "on-behalf-of-content-owner" => { - call = call.on_behalf_of_content_owner(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Playlist::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_content_details_init(request: &mut api::Playlist) { if request.content_details.is_none() { request.content_details = Some(Default::default()); @@ -5613,7 +5874,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status.privacy-status" => { request_status_init(&mut request); request.status.as_mut().unwrap().privacy_status = Some(value.unwrap_or("").to_string()); @@ -5738,15 +5999,46 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.playlists().insert(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "on-behalf-of-content-owner-channel" => { + call = call.on_behalf_of_content_owner_channel(value.unwrap_or("")); + }, + "on-behalf-of-content-owner" => { + call = call.on_behalf_of_content_owner(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5814,6 +6106,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -5830,39 +6125,23 @@ impl Engine { fn _playlists_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Playlist::default(); - let mut call = self.hub.playlists().update(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "on-behalf-of-content-owner" => { - call = call.on_behalf_of_content_owner(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Playlist::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_content_details_init(request: &mut api::Playlist) { if request.content_details.is_none() { request.content_details = Some(Default::default()); @@ -5936,7 +6215,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status.privacy-status" => { request_status_init(&mut request); request.status.as_mut().unwrap().privacy_status = Some(value.unwrap_or("").to_string()); @@ -6061,15 +6340,43 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.playlists().update(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "on-behalf-of-content-owner" => { + call = call.on_behalf_of_content_owner(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6203,6 +6510,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6246,6 +6556,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -6260,36 +6573,23 @@ impl Engine { fn _subscriptions_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Subscription::default(); - let mut call = self.hub.subscriptions().insert(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Subscription::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_content_details_init(request: &mut api::Subscription) { if request.content_details.is_none() { request.content_details = Some(Default::default()); @@ -6399,7 +6699,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, @@ -6592,15 +6892,40 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.subscriptions().insert(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6674,6 +6999,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6729,6 +7057,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -6776,6 +7107,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6828,6 +7162,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6874,6 +7211,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -6918,6 +7258,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -6934,51 +7277,23 @@ impl Engine { fn _videos_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Video::default(); - let mut call = self.hub.videos().insert(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "stabilize" => { - call = call.stabilize(arg_from_str(value.unwrap_or("false"), err, "stabilize", "boolean")); - }, - "on-behalf-of-content-owner-channel" => { - call = call.on_behalf_of_content_owner_channel(value.unwrap_or("")); - }, - "on-behalf-of-content-owner" => { - call = call.on_behalf_of_content_owner(value.unwrap_or("")); - }, - "notify-subscribers" => { - call = call.notify_subscribers(arg_from_str(value.unwrap_or("false"), err, "notify-subscribers", "boolean")); - }, - "auto-levels" => { - call = call.auto_levels(arg_from_str(value.unwrap_or("false"), err, "auto-levels", "boolean")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Video::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_age_gating_init(request: &mut api::Video) { if request.age_gating.is_none() { request.age_gating = Some(Default::default()); @@ -7161,7 +7476,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status.license" => { request_status_init(&mut request); request.status.as_mut().unwrap().license = Some(value.unwrap_or("").to_string()); @@ -7834,10 +8149,47 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.videos().insert(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "stabilize" => { + call = call.stabilize(arg_from_str(value.unwrap_or("false"), err, "stabilize", "boolean")); + }, + "on-behalf-of-content-owner-channel" => { + call = call.on_behalf_of_content_owner_channel(value.unwrap_or("")); + }, + "on-behalf-of-content-owner" => { + call = call.on_behalf_of_content_owner(value.unwrap_or("")); + }, + "notify-subscribers" => { + call = call.notify_subscribers(arg_from_str(value.unwrap_or("false"), err, "notify-subscribers", "boolean")); + }, + "auto-levels" => { + call = call.auto_levels(arg_from_str(value.unwrap_or("false"), err, "auto-levels", "boolean")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = if self.opt.cmd_simple { "simple" @@ -7852,6 +8204,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), @@ -7926,6 +8281,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -7972,6 +8330,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -7986,40 +8347,24 @@ impl Engine { fn _videos_report_abuse(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::VideoAbuseReport::default(); - let mut call = self.hub.videos().report_abuse(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "on-behalf-of-content-owner" => { - call = call.on_behalf_of_content_owner(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::VideoAbuseReport::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + let mut temp_cursor = field_cursor.clone(); + if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } - match &field_name.to_string()[..] { + if value.is_none() { + field_cursor = temp_cursor.clone(); + if err.issues.len() > last_errc { + err.issues.remove(last_errc); + } + continue; + } + match &temp_cursor.to_string()[..] { "secondary-reason-id" => { request.secondary_reason_id = Some(value.unwrap_or("").to_string()); }, @@ -8036,31 +8381,11 @@ impl Engine { request.video_id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok(mut response) => { - None - } - } - } - } - - fn _videos_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::Video::default(); - let mut call = self.hub.videos().update(&request); + let mut call = self.hub.videos().report_abuse(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -8085,13 +8410,45 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok(mut response) => { + None + } + } + } + } + + fn _videos_update(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::Video::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_age_gating_init(request: &mut api::Video) { if request.age_gating.is_none() { request.age_gating = Some(Default::default()); @@ -8274,7 +8631,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "status.license" => { request_status_init(&mut request); request.status.as_mut().unwrap().license = Some(value.unwrap_or("").to_string()); @@ -8947,33 +9304,11 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } - let protocol = "standard-request"; - if dry_run { - None - } else { - assert!(err.issues.len() == 0); - let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok((mut response, output_schema)) => { - serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _watermarks_set(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request = api::InvideoBranding::default(); - let mut call = self.hub.watermarks().set(&request, &self.opt.arg_channel_id); + let mut call = self.hub.videos().update(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -8998,13 +9333,47 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } + let protocol = "standard-request"; + if dry_run { + None + } else { + assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } + let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok((mut response, output_schema)) => { + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _watermarks_set(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { - let mut field_name = FieldCursor::default(); + let mut request = api::InvideoBranding::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_position_init(request: &mut api::InvideoBranding) { if request.position.is_none() { request.position = Some(Default::default()); @@ -9017,7 +9386,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "target-channel-id" => { request.target_channel_id = Some(value.unwrap_or("").to_string()); }, @@ -9050,10 +9419,35 @@ impl Engine { request.image_bytes = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.watermarks().set(request, &self.opt.arg_channel_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "on-behalf-of-content-owner" => { + call = call.on_behalf_of_content_owner(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = if self.opt.cmd_simple { "simple" @@ -9068,6 +9462,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "simple" => call.upload(input_file.unwrap(), mime_type.unwrap()), "resumable" => call.upload_resumable(input_file.unwrap(), mime_type.unwrap()), @@ -9113,6 +9510,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -9377,7 +9777,21 @@ impl Engine { }; match cmn::application_secret_from_directory(&config_dir, "youtube3-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\"}}") { + "{ + \"installed\": { + \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\", + \"client_secret\": \"UqkDJd5RFwnHoiG5x5Rub8SI\", + \"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\": \"14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.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)) } @@ -9424,6 +9838,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -9431,8 +9846,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/youtube3/README.md b/gen/youtube3/README.md index 24df832a77..88570701b2 100644 --- a/gen/youtube3/README.md +++ b/gen/youtube3/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-youtube3` library allows access to all features of the *Google YouTube* service. -This documentation was generated from *YouTube* crate version *0.1.5+20150414*, where *20150414* is the exact revision of the *youtube:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *YouTube* crate version *0.1.6+20150414*, where *20150414* is the exact revision of the *youtube:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *YouTube* *v3* API can be found at the [official documentation site](https://developers.google.com/youtube/v3). @@ -172,14 +172,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/youtube3/cargo.toml b/gen/youtube3/cargo.toml index 8ada608335..e67d792cab 100644 --- a/gen/youtube3/cargo.toml +++ b/gen/youtube3/cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-youtube3" -version = "0.1.5+20150414" +version = "0.1.6+20150414" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with YouTube (protocol v3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/youtube3" diff --git a/gen/youtube3/src/cmn.rs b/gen/youtube3/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/youtube3/src/cmn.rs +++ b/gen/youtube3/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/youtube3/src/lib.rs b/gen/youtube3/src/lib.rs index ecf81a4bd7..33393c1066 100644 --- a/gen/youtube3/src/lib.rs +++ b/gen/youtube3/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *YouTube* crate version *0.1.5+20150414*, where *20150414* is the exact revision of the *youtube:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *YouTube* crate version *0.1.6+20150414*, where *20150414* is the exact revision of the *youtube:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *YouTube* *v3* API can be found at the //! [official documentation site](https://developers.google.com/youtube/v3). @@ -173,14 +173,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -268,7 +269,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -372,14 +373,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -400,7 +402,7 @@ impl<'a, C, A> YouTube<C, A> YouTube { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -469,7 +471,7 @@ impl<'a, C, A> YouTube<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -5059,10 +5061,10 @@ impl<'a, C, A> ChannelBannerMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &ChannelBannerResource) -> ChannelBannerInsertCall<'a, C, A> { + pub fn insert(&self, request: ChannelBannerResource) -> ChannelBannerInsertCall<'a, C, A> { ChannelBannerInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _on_behalf_of_content_owner: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -5141,11 +5143,12 @@ impl<'a, C, A> ChannelSectionMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &ChannelSection) -> ChannelSectionInsertCall<'a, C, A> { + pub fn insert(&self, request: ChannelSection) -> ChannelSectionInsertCall<'a, C, A> { + let parts = request.to_parts(); ChannelSectionInsertCall { hub: self.hub, - _request: request.clone(), - _part: request.to_parts(), + _request: request, + _part: parts, _on_behalf_of_content_owner_channel: Default::default(), _on_behalf_of_content_owner: Default::default(), _delegate: Default::default(), @@ -5179,11 +5182,12 @@ impl<'a, C, A> ChannelSectionMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn update(&self, request: &ChannelSection) -> ChannelSectionUpdateCall<'a, C, A> { + pub fn update(&self, request: ChannelSection) -> ChannelSectionUpdateCall<'a, C, A> { + let parts = request.to_parts(); ChannelSectionUpdateCall { hub: self.hub, - _request: request.clone(), - _part: request.to_parts(), + _request: request, + _part: parts, _on_behalf_of_content_owner: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -5301,11 +5305,12 @@ impl<'a, C, A> PlaylistMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &Playlist) -> PlaylistInsertCall<'a, C, A> { + pub fn insert(&self, request: Playlist) -> PlaylistInsertCall<'a, C, A> { + let parts = request.to_parts(); PlaylistInsertCall { hub: self.hub, - _request: request.clone(), - _part: request.to_parts(), + _request: request, + _part: parts, _on_behalf_of_content_owner_channel: Default::default(), _on_behalf_of_content_owner: Default::default(), _delegate: Default::default(), @@ -5365,11 +5370,12 @@ impl<'a, C, A> PlaylistMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn update(&self, request: &Playlist) -> PlaylistUpdateCall<'a, C, A> { + pub fn update(&self, request: Playlist) -> PlaylistUpdateCall<'a, C, A> { + let parts = request.to_parts(); PlaylistUpdateCall { hub: self.hub, - _request: request.clone(), - _part: request.to_parts(), + _request: request, + _part: parts, _on_behalf_of_content_owner: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -5484,10 +5490,10 @@ impl<'a, C, A> VideoMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn report_abuse(&self, request: &VideoAbuseReport) -> VideoReportAbuseCall<'a, C, A> { + pub fn report_abuse(&self, request: VideoAbuseReport) -> VideoReportAbuseCall<'a, C, A> { VideoReportAbuseCall { hub: self.hub, - _request: request.clone(), + _request: request, _on_behalf_of_content_owner: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -5586,11 +5592,12 @@ impl<'a, C, A> VideoMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn update(&self, request: &Video) -> VideoUpdateCall<'a, C, A> { + pub fn update(&self, request: Video) -> VideoUpdateCall<'a, C, A> { + let parts = request.to_parts(); VideoUpdateCall { hub: self.hub, - _request: request.clone(), - _part: request.to_parts(), + _request: request, + _part: parts, _on_behalf_of_content_owner: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -5605,11 +5612,12 @@ impl<'a, C, A> VideoMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &Video) -> VideoInsertCall<'a, C, A> { + pub fn insert(&self, request: Video) -> VideoInsertCall<'a, C, A> { + let parts = request.to_parts(); VideoInsertCall { hub: self.hub, - _request: request.clone(), - _part: request.to_parts(), + _request: request, + _part: parts, _stabilize: Default::default(), _on_behalf_of_content_owner_channel: Default::default(), _on_behalf_of_content_owner: Default::default(), @@ -5669,11 +5677,12 @@ impl<'a, C, A> SubscriptionMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &Subscription) -> SubscriptionInsertCall<'a, C, A> { + pub fn insert(&self, request: Subscription) -> SubscriptionInsertCall<'a, C, A> { + let parts = request.to_parts(); SubscriptionInsertCall { hub: self.hub, - _request: request.clone(), - _part: request.to_parts(), + _request: request, + _part: parts, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -5947,11 +5956,12 @@ impl<'a, C, A> CommentThreadMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn update(&self, request: &CommentThread) -> CommentThreadUpdateCall<'a, C, A> { + pub fn update(&self, request: CommentThread) -> CommentThreadUpdateCall<'a, C, A> { + let parts = request.to_parts(); CommentThreadUpdateCall { hub: self.hub, - _request: request.clone(), - _part: request.to_parts(), + _request: request, + _part: parts, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -5965,11 +5975,12 @@ impl<'a, C, A> CommentThreadMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &CommentThread) -> CommentThreadInsertCall<'a, C, A> { + pub fn insert(&self, request: CommentThread) -> CommentThreadInsertCall<'a, C, A> { + let parts = request.to_parts(); CommentThreadInsertCall { hub: self.hub, - _request: request.clone(), - _part: request.to_parts(), + _request: request, + _part: parts, _share_on_google_plus: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -6025,11 +6036,12 @@ impl<'a, C, A> LiveStreamMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn update(&self, request: &LiveStream) -> LiveStreamUpdateCall<'a, C, A> { + pub fn update(&self, request: LiveStream) -> LiveStreamUpdateCall<'a, C, A> { + let parts = request.to_parts(); LiveStreamUpdateCall { hub: self.hub, - _request: request.clone(), - _part: request.to_parts(), + _request: request, + _part: parts, _on_behalf_of_content_owner_channel: Default::default(), _on_behalf_of_content_owner: Default::default(), _delegate: Default::default(), @@ -6087,11 +6099,12 @@ impl<'a, C, A> LiveStreamMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &LiveStream) -> LiveStreamInsertCall<'a, C, A> { + pub fn insert(&self, request: LiveStream) -> LiveStreamInsertCall<'a, C, A> { + let parts = request.to_parts(); LiveStreamInsertCall { hub: self.hub, - _request: request.clone(), - _part: request.to_parts(), + _request: request, + _part: parts, _on_behalf_of_content_owner_channel: Default::default(), _on_behalf_of_content_owner: Default::default(), _delegate: Default::default(), @@ -6150,11 +6163,12 @@ impl<'a, C, A> CommentMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &Comment) -> CommentInsertCall<'a, C, A> { + pub fn insert(&self, request: Comment) -> CommentInsertCall<'a, C, A> { + let parts = request.to_parts(); CommentInsertCall { hub: self.hub, - _request: request.clone(), - _part: request.to_parts(), + _request: request, + _part: parts, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -6227,11 +6241,12 @@ impl<'a, C, A> CommentMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn update(&self, request: &Comment) -> CommentUpdateCall<'a, C, A> { + pub fn update(&self, request: Comment) -> CommentUpdateCall<'a, C, A> { + let parts = request.to_parts(); CommentUpdateCall { hub: self.hub, - _request: request.clone(), - _part: request.to_parts(), + _request: request, + _part: parts, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -6303,11 +6318,12 @@ impl<'a, C, A> ChannelMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn update(&self, request: &Channel) -> ChannelUpdateCall<'a, C, A> { + pub fn update(&self, request: Channel) -> ChannelUpdateCall<'a, C, A> { + let parts = request.to_parts(); ChannelUpdateCall { hub: self.hub, - _request: request.clone(), - _part: request.to_parts(), + _request: request, + _part: parts, _on_behalf_of_content_owner: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -6450,11 +6466,12 @@ impl<'a, C, A> PlaylistItemMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &PlaylistItem) -> PlaylistItemInsertCall<'a, C, A> { + pub fn insert(&self, request: PlaylistItem) -> PlaylistItemInsertCall<'a, C, A> { + let parts = request.to_parts(); PlaylistItemInsertCall { hub: self.hub, - _request: request.clone(), - _part: request.to_parts(), + _request: request, + _part: parts, _on_behalf_of_content_owner: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -6510,11 +6527,12 @@ impl<'a, C, A> PlaylistItemMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn update(&self, request: &PlaylistItem) -> PlaylistItemUpdateCall<'a, C, A> { + pub fn update(&self, request: PlaylistItem) -> PlaylistItemUpdateCall<'a, C, A> { + let parts = request.to_parts(); PlaylistItemUpdateCall { hub: self.hub, - _request: request.clone(), - _part: request.to_parts(), + _request: request, + _part: parts, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -6570,10 +6588,10 @@ impl<'a, C, A> WatermarkMethods<'a, C, A> { /// /// * `request` - No description provided. /// * `channelId` - The channelId parameter specifies a YouTube channel ID for which the watermark is being provided. - pub fn set(&self, request: &InvideoBranding, channel_id: &str) -> WatermarkSetCall<'a, C, A> { + pub fn set(&self, request: InvideoBranding, channel_id: &str) -> WatermarkSetCall<'a, C, A> { WatermarkSetCall { hub: self.hub, - _request: request.clone(), + _request: request, _channel_id: channel_id.to_string(), _on_behalf_of_content_owner: Default::default(), _delegate: Default::default(), @@ -6672,11 +6690,12 @@ impl<'a, C, A> LiveBroadcastMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn update(&self, request: &LiveBroadcast) -> LiveBroadcastUpdateCall<'a, C, A> { + pub fn update(&self, request: LiveBroadcast) -> LiveBroadcastUpdateCall<'a, C, A> { + let parts = request.to_parts(); LiveBroadcastUpdateCall { hub: self.hub, - _request: request.clone(), - _part: request.to_parts(), + _request: request, + _part: parts, _on_behalf_of_content_owner_channel: Default::default(), _on_behalf_of_content_owner: Default::default(), _delegate: Default::default(), @@ -6692,11 +6711,12 @@ impl<'a, C, A> LiveBroadcastMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &LiveBroadcast) -> LiveBroadcastInsertCall<'a, C, A> { + pub fn insert(&self, request: LiveBroadcast) -> LiveBroadcastInsertCall<'a, C, A> { + let parts = request.to_parts(); LiveBroadcastInsertCall { hub: self.hub, - _request: request.clone(), - _part: request.to_parts(), + _request: request, + _part: parts, _on_behalf_of_content_owner_channel: Default::default(), _on_behalf_of_content_owner: Default::default(), _delegate: Default::default(), @@ -6860,11 +6880,12 @@ impl<'a, C, A> CaptionMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &Caption) -> CaptionInsertCall<'a, C, A> { + pub fn insert(&self, request: Caption) -> CaptionInsertCall<'a, C, A> { + let parts = request.to_parts(); CaptionInsertCall { hub: self.hub, - _request: request.clone(), - _part: request.to_parts(), + _request: request, + _part: parts, _sync: Default::default(), _on_behalf_of: Default::default(), _debug_project_id_override: Default::default(), @@ -6924,11 +6945,12 @@ impl<'a, C, A> CaptionMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn update(&self, request: &Caption) -> CaptionUpdateCall<'a, C, A> { + pub fn update(&self, request: Caption) -> CaptionUpdateCall<'a, C, A> { + let parts = request.to_parts(); CaptionUpdateCall { hub: self.hub, - _request: request.clone(), - _part: request.to_parts(), + _request: request, + _part: parts, _sync: Default::default(), _on_behalf_of: Default::default(), _debug_project_id_override: Default::default(), @@ -7075,11 +7097,12 @@ impl<'a, C, A> ActivityMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &Activity) -> ActivityInsertCall<'a, C, A> { + pub fn insert(&self, request: Activity) -> ActivityInsertCall<'a, C, A> { + let parts = request.to_parts(); ActivityInsertCall { hub: self.hub, - _request: request.clone(), - _part: request.to_parts(), + _request: request, + _part: parts, _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -7237,12 +7260,17 @@ impl<'a, C, A> I18nLanguageListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7251,7 +7279,7 @@ impl<'a, C, A> I18nLanguageListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7375,7 +7403,7 @@ impl<'a, C, A> I18nLanguageListCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.channel_banners().insert(&req) +/// let result = hub.channel_banners().insert(req) /// .on_behalf_of_content_owner("sadipscing") /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } @@ -7424,14 +7452,15 @@ impl<'a, C, A> ChannelBannerInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/youtube/v3/channelBanners/insert".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/youtube/v3/channelBanners/insert".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/youtube/v3/channelBanners/insert".to_string() + ("https://www.googleapis.com/resumable/upload/youtube/v3/channelBanners/insert".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } @@ -7526,12 +7555,17 @@ impl<'a, C, A> ChannelBannerInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -7541,9 +7575,9 @@ impl<'a, C, A> ChannelBannerInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -7553,7 +7587,7 @@ impl<'a, C, A> ChannelBannerInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -7584,7 +7618,7 @@ impl<'a, C, A> ChannelBannerInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -7628,8 +7662,8 @@ impl<'a, C, A> ChannelBannerInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &ChannelBannerResource) -> ChannelBannerInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ChannelBannerResource) -> ChannelBannerInsertCall<'a, C, A> { + self._request = new_value; self } /// Note: This parameter is intended exclusively for YouTube content partners. @@ -7856,12 +7890,17 @@ impl<'a, C, A> ChannelSectionListCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -7870,7 +7909,7 @@ impl<'a, C, A> ChannelSectionListCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8039,7 +8078,7 @@ impl<'a, C, A> ChannelSectionListCall<'a, C, A> where C: BorrowMut<hyper::Client /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.channel_sections().insert(&req) +/// let result = hub.channel_sections().insert(req) /// .on_behalf_of_content_owner_channel("eirmod") /// .on_behalf_of_content_owner("dolore") /// .doit(); @@ -8156,12 +8195,17 @@ impl<'a, C, A> ChannelSectionInsertCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8170,7 +8214,7 @@ impl<'a, C, A> ChannelSectionInsertCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8193,8 +8237,8 @@ impl<'a, C, A> ChannelSectionInsertCall<'a, C, A> where C: BorrowMut<hyper::Clie /// /// * *snippet* /// * *contentDetails* - pub fn request(mut self, new_value: &ChannelSection) -> ChannelSectionInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ChannelSection) -> ChannelSectionInsertCall<'a, C, A> { + self._request = new_value; self } /// The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. @@ -8414,12 +8458,17 @@ impl<'a, C, A> ChannelSectionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -8551,7 +8600,7 @@ impl<'a, C, A> ChannelSectionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.channel_sections().update(&req) +/// let result = hub.channel_sections().update(req) /// .on_behalf_of_content_owner("accusam") /// .doit(); /// # } @@ -8663,12 +8712,17 @@ impl<'a, C, A> ChannelSectionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8677,7 +8731,7 @@ impl<'a, C, A> ChannelSectionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -8700,8 +8754,8 @@ impl<'a, C, A> ChannelSectionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clie /// /// * *snippet* /// * *contentDetails* - pub fn request(mut self, new_value: &ChannelSection) -> ChannelSectionUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: ChannelSection) -> ChannelSectionUpdateCall<'a, C, A> { + self._request = new_value; self } /// The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. @@ -8937,12 +8991,17 @@ impl<'a, C, A> GuideCategoryListCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -8951,7 +9010,7 @@ impl<'a, C, A> GuideCategoryListCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9103,7 +9162,7 @@ impl<'a, C, A> GuideCategoryListCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.playlists().insert(&req) +/// let result = hub.playlists().insert(req) /// .on_behalf_of_content_owner_channel("et") /// .on_behalf_of_content_owner("eirmod") /// .doit(); @@ -9220,12 +9279,17 @@ impl<'a, C, A> PlaylistInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9234,7 +9298,7 @@ impl<'a, C, A> PlaylistInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9257,8 +9321,8 @@ impl<'a, C, A> PlaylistInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// * *snippet* /// * *status* - pub fn request(mut self, new_value: &Playlist) -> PlaylistInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Playlist) -> PlaylistInsertCall<'a, C, A> { + self._request = new_value; self } /// The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. @@ -9532,12 +9596,17 @@ impl<'a, C, A> PlaylistListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -9546,7 +9615,7 @@ impl<'a, C, A> PlaylistListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -9817,12 +9886,17 @@ impl<'a, C, A> PlaylistDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -9954,7 +10028,7 @@ impl<'a, C, A> PlaylistDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.playlists().update(&req) +/// let result = hub.playlists().update(req) /// .on_behalf_of_content_owner("et") /// .doit(); /// # } @@ -10066,12 +10140,17 @@ impl<'a, C, A> PlaylistUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10080,7 +10159,7 @@ impl<'a, C, A> PlaylistUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10103,8 +10182,8 @@ impl<'a, C, A> PlaylistUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// * *snippet* /// * *status* - pub fn request(mut self, new_value: &Playlist) -> PlaylistUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Playlist) -> PlaylistUpdateCall<'a, C, A> { + self._request = new_value; self } /// The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. @@ -10267,14 +10346,15 @@ impl<'a, C, A> ThumbnailSetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/youtube/v3/thumbnails/set".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/youtube/v3/thumbnails/set".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/youtube/v3/thumbnails/set".to_string() + ("https://www.googleapis.com/resumable/upload/youtube/v3/thumbnails/set".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } @@ -10356,12 +10436,17 @@ impl<'a, C, A> ThumbnailSetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -10371,9 +10456,9 @@ impl<'a, C, A> ThumbnailSetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -10383,7 +10468,7 @@ impl<'a, C, A> ThumbnailSetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -10414,7 +10499,7 @@ impl<'a, C, A> ThumbnailSetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -10554,7 +10639,7 @@ impl<'a, C, A> ThumbnailSetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.videos().report_abuse(&req) +/// let result = hub.videos().report_abuse(req) /// .on_behalf_of_content_owner("voluptua.") /// .doit(); /// # } @@ -10660,12 +10745,17 @@ impl<'a, C, A> VideoReportAbuseCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -10682,8 +10772,8 @@ impl<'a, C, A> VideoReportAbuseCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &VideoAbuseReport) -> VideoReportAbuseCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: VideoAbuseReport) -> VideoReportAbuseCall<'a, C, A> { + self._request = new_value; self } /// Note: This parameter is intended exclusively for YouTube content partners. @@ -10945,12 +11035,17 @@ impl<'a, C, A> VideoListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -10959,7 +11054,7 @@ impl<'a, C, A> VideoListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11255,12 +11350,17 @@ impl<'a, C, A> VideoRateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -11479,12 +11579,17 @@ impl<'a, C, A> VideoGetRatingCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11493,7 +11598,7 @@ impl<'a, C, A> VideoGetRatingCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -11702,12 +11807,17 @@ impl<'a, C, A> VideoDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -11859,7 +11969,7 @@ impl<'a, C, A> VideoDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.videos().update(&req) +/// let result = hub.videos().update(req) /// .on_behalf_of_content_owner("clita") /// .doit(); /// # } @@ -11971,12 +12081,17 @@ impl<'a, C, A> VideoUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -11985,7 +12100,7 @@ impl<'a, C, A> VideoUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12018,8 +12133,8 @@ impl<'a, C, A> VideoUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// * *status* /// * *suggestions* /// * *topicDetails* - pub fn request(mut self, new_value: &Video) -> VideoUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Video) -> VideoUpdateCall<'a, C, A> { + self._request = new_value; self } /// The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. @@ -12188,7 +12303,7 @@ impl<'a, C, A> VideoUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload_resumable(...)`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.videos().insert(&req) +/// let result = hub.videos().insert(req) /// .stabilize(true) /// .on_behalf_of_content_owner_channel("takimata") /// .on_behalf_of_content_owner("nonumy") @@ -12262,14 +12377,15 @@ impl<'a, C, A> VideoInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/youtube/v3/videos".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/youtube/v3/videos".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/youtube/v3/videos".to_string() + ("https://www.googleapis.com/resumable/upload/youtube/v3/videos".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } @@ -12364,12 +12480,17 @@ impl<'a, C, A> VideoInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -12379,9 +12500,9 @@ impl<'a, C, A> VideoInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -12391,7 +12512,7 @@ impl<'a, C, A> VideoInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -12422,7 +12543,7 @@ impl<'a, C, A> VideoInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12481,8 +12602,8 @@ impl<'a, C, A> VideoInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// * *status* /// * *suggestions* /// * *topicDetails* - pub fn request(mut self, new_value: &Video) -> VideoInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Video) -> VideoInsertCall<'a, C, A> { + self._request = new_value; self } /// The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. @@ -12657,7 +12778,7 @@ impl<'a, C, A> VideoInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.subscriptions().insert(&req) +/// let result = hub.subscriptions().insert(req) /// .doit(); /// # } /// ``` @@ -12764,12 +12885,17 @@ impl<'a, C, A> SubscriptionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -12778,7 +12904,7 @@ impl<'a, C, A> SubscriptionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -12801,8 +12927,8 @@ impl<'a, C, A> SubscriptionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client /// /// * *snippet* /// * *contentDetails* - pub fn request(mut self, new_value: &Subscription) -> SubscriptionInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Subscription) -> SubscriptionInsertCall<'a, C, A> { + self._request = new_value; self } /// The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. @@ -13065,12 +13191,17 @@ impl<'a, C, A> SubscriptionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13079,7 +13210,7 @@ impl<'a, C, A> SubscriptionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -13358,12 +13489,17 @@ impl<'a, C, A> SubscriptionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -13724,12 +13860,17 @@ impl<'a, C, A> SearchListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -13738,7 +13879,7 @@ impl<'a, C, A> SearchListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14176,12 +14317,17 @@ impl<'a, C, A> I18nRegionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14190,7 +14336,7 @@ impl<'a, C, A> I18nRegionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14455,12 +14601,17 @@ impl<'a, C, A> CommentThreadListCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14469,7 +14620,7 @@ impl<'a, C, A> CommentThreadListCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14668,7 +14819,7 @@ impl<'a, C, A> CommentThreadListCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.comment_threads().update(&req) +/// let result = hub.comment_threads().update(req) /// .doit(); /// # } /// ``` @@ -14775,12 +14926,17 @@ impl<'a, C, A> CommentThreadUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -14789,7 +14945,7 @@ impl<'a, C, A> CommentThreadUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -14813,8 +14969,8 @@ impl<'a, C, A> CommentThreadUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien /// * *id* /// * *snippet* /// * *replies* - pub fn request(mut self, new_value: &CommentThread) -> CommentThreadUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CommentThread) -> CommentThreadUpdateCall<'a, C, A> { + self._request = new_value; self } /// The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. @@ -14935,7 +15091,7 @@ impl<'a, C, A> CommentThreadUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.comment_threads().insert(&req) +/// let result = hub.comment_threads().insert(req) /// .share_on_google_plus(false) /// .doit(); /// # } @@ -15047,12 +15203,17 @@ impl<'a, C, A> CommentThreadInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15061,7 +15222,7 @@ impl<'a, C, A> CommentThreadInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15084,8 +15245,8 @@ impl<'a, C, A> CommentThreadInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien /// /// * *id* /// * *snippet* - pub fn request(mut self, new_value: &CommentThread) -> CommentThreadInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: CommentThread) -> CommentThreadInsertCall<'a, C, A> { + self._request = new_value; self } /// The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. @@ -15219,7 +15380,7 @@ impl<'a, C, A> CommentThreadInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.live_streams().update(&req) +/// let result = hub.live_streams().update(req) /// .on_behalf_of_content_owner_channel("consetetur") /// .on_behalf_of_content_owner("et") /// .doit(); @@ -15336,12 +15497,17 @@ impl<'a, C, A> LiveStreamUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15350,7 +15516,7 @@ impl<'a, C, A> LiveStreamUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -15375,8 +15541,8 @@ impl<'a, C, A> LiveStreamUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// * *snippet* /// * *cdn* /// * *status* - pub fn request(mut self, new_value: &LiveStream) -> LiveStreamUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: LiveStream) -> LiveStreamUpdateCall<'a, C, A> { + self._request = new_value; self } /// The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. @@ -15605,12 +15771,17 @@ impl<'a, C, A> LiveStreamDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -15872,12 +16043,17 @@ impl<'a, C, A> LiveStreamListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -15886,7 +16062,7 @@ impl<'a, C, A> LiveStreamListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16068,7 +16244,7 @@ impl<'a, C, A> LiveStreamListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.live_streams().insert(&req) +/// let result = hub.live_streams().insert(req) /// .on_behalf_of_content_owner_channel("amet.") /// .on_behalf_of_content_owner("ipsum") /// .doit(); @@ -16185,12 +16361,17 @@ impl<'a, C, A> LiveStreamInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16199,7 +16380,7 @@ impl<'a, C, A> LiveStreamInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16224,8 +16405,8 @@ impl<'a, C, A> LiveStreamInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// * *snippet* /// * *cdn* /// * *status* - pub fn request(mut self, new_value: &LiveStream) -> LiveStreamInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: LiveStream) -> LiveStreamInsertCall<'a, C, A> { + self._request = new_value; self } /// The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. @@ -16369,7 +16550,7 @@ impl<'a, C, A> LiveStreamInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.comments().insert(&req) +/// let result = hub.comments().insert(req) /// .doit(); /// # } /// ``` @@ -16476,12 +16657,17 @@ impl<'a, C, A> CommentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -16490,7 +16676,7 @@ impl<'a, C, A> CommentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -16513,8 +16699,8 @@ impl<'a, C, A> CommentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// * *id* /// * *snippet* - pub fn request(mut self, new_value: &Comment) -> CommentInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Comment) -> CommentInsertCall<'a, C, A> { + self._request = new_value; self } /// The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. @@ -16716,12 +16902,17 @@ impl<'a, C, A> CommentSetModerationStatuCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -16934,12 +17125,17 @@ impl<'a, C, A> CommentDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -17170,12 +17366,17 @@ impl<'a, C, A> CommentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -17184,7 +17385,7 @@ impl<'a, C, A> CommentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -17350,7 +17551,7 @@ impl<'a, C, A> CommentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.comments().update(&req) +/// let result = hub.comments().update(req) /// .doit(); /// # } /// ``` @@ -17457,12 +17658,17 @@ impl<'a, C, A> CommentUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -17471,7 +17677,7 @@ impl<'a, C, A> CommentUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -17494,8 +17700,8 @@ impl<'a, C, A> CommentUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// * *id* /// * *snippet* - pub fn request(mut self, new_value: &Comment) -> CommentUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Comment) -> CommentUpdateCall<'a, C, A> { + self._request = new_value; self } /// The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. @@ -17690,12 +17896,17 @@ impl<'a, C, A> CommentMarkAsSpamCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -17818,7 +18029,7 @@ impl<'a, C, A> CommentMarkAsSpamCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.channels().update(&req) +/// let result = hub.channels().update(req) /// .on_behalf_of_content_owner("ipsum") /// .doit(); /// # } @@ -17930,12 +18141,17 @@ impl<'a, C, A> ChannelUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -17944,7 +18160,7 @@ impl<'a, C, A> ChannelUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -17967,8 +18183,8 @@ impl<'a, C, A> ChannelUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// * *id* /// * *invideoPromotion* - pub fn request(mut self, new_value: &Channel) -> ChannelUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Channel) -> ChannelUpdateCall<'a, C, A> { + self._request = new_value; self } /// The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. @@ -18244,12 +18460,17 @@ impl<'a, C, A> ChannelListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -18258,7 +18479,7 @@ impl<'a, C, A> ChannelListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -18555,12 +18776,17 @@ impl<'a, C, A> VideoAbuseReportReasonListCall<'a, C, A> where C: BorrowMut<hyper if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -18569,7 +18795,7 @@ impl<'a, C, A> VideoAbuseReportReasonListCall<'a, C, A> where C: BorrowMut<hyper Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -18707,7 +18933,7 @@ impl<'a, C, A> VideoAbuseReportReasonListCall<'a, C, A> where C: BorrowMut<hyper /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.playlist_items().insert(&req) +/// let result = hub.playlist_items().insert(req) /// .on_behalf_of_content_owner("aliquyam") /// .doit(); /// # } @@ -18819,12 +19045,17 @@ impl<'a, C, A> PlaylistItemInsertCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -18833,7 +19064,7 @@ impl<'a, C, A> PlaylistItemInsertCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -18857,8 +19088,8 @@ impl<'a, C, A> PlaylistItemInsertCall<'a, C, A> where C: BorrowMut<hyper::Client /// * *snippet* /// * *contentDetails* /// * *status* - pub fn request(mut self, new_value: &PlaylistItem) -> PlaylistItemInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PlaylistItem) -> PlaylistItemInsertCall<'a, C, A> { + self._request = new_value; self } /// The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. @@ -19063,12 +19294,17 @@ impl<'a, C, A> PlaylistItemDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -19311,12 +19547,17 @@ impl<'a, C, A> PlaylistItemListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -19325,7 +19566,7 @@ impl<'a, C, A> PlaylistItemListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -19504,7 +19745,7 @@ impl<'a, C, A> PlaylistItemListCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.playlist_items().update(&req) +/// let result = hub.playlist_items().update(req) /// .doit(); /// # } /// ``` @@ -19611,12 +19852,17 @@ impl<'a, C, A> PlaylistItemUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -19625,7 +19871,7 @@ impl<'a, C, A> PlaylistItemUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -19649,8 +19895,8 @@ impl<'a, C, A> PlaylistItemUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client /// * *snippet* /// * *contentDetails* /// * *status* - pub fn request(mut self, new_value: &PlaylistItem) -> PlaylistItemUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: PlaylistItem) -> PlaylistItemUpdateCall<'a, C, A> { + self._request = new_value; self } /// The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. @@ -19761,7 +20007,7 @@ impl<'a, C, A> PlaylistItemUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.watermarks().set(&req, "channelId") +/// let result = hub.watermarks().set(req, "channelId") /// .on_behalf_of_content_owner("dolores") /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } @@ -19811,14 +20057,15 @@ impl<'a, C, A> WatermarkSetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: } - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/youtube/v3/watermarks/set".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/youtube/v3/watermarks/set".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/youtube/v3/watermarks/set".to_string() + ("https://www.googleapis.com/resumable/upload/youtube/v3/watermarks/set".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } @@ -19913,12 +20160,17 @@ impl<'a, C, A> WatermarkSetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -19928,9 +20180,9 @@ impl<'a, C, A> WatermarkSetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -19940,7 +20192,7 @@ impl<'a, C, A> WatermarkSetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -20005,8 +20257,8 @@ impl<'a, C, A> WatermarkSetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &InvideoBranding) -> WatermarkSetCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: InvideoBranding) -> WatermarkSetCall<'a, C, A> { + self._request = new_value; self } /// The channelId parameter specifies a YouTube channel ID for which the watermark is being provided. @@ -20203,12 +20455,17 @@ impl<'a, C, A> WatermarkUnsetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -20453,12 +20710,17 @@ impl<'a, C, A> LiveBroadcastControlCall<'a, C, A> where C: BorrowMut<hyper::Clie if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -20467,7 +20729,7 @@ impl<'a, C, A> LiveBroadcastControlCall<'a, C, A> where C: BorrowMut<hyper::Clie Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -20656,7 +20918,7 @@ impl<'a, C, A> LiveBroadcastControlCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.live_broadcasts().update(&req) +/// let result = hub.live_broadcasts().update(req) /// .on_behalf_of_content_owner_channel("dolore") /// .on_behalf_of_content_owner("Lorem") /// .doit(); @@ -20773,12 +21035,17 @@ impl<'a, C, A> LiveBroadcastUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -20787,7 +21054,7 @@ impl<'a, C, A> LiveBroadcastUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -20812,8 +21079,8 @@ impl<'a, C, A> LiveBroadcastUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien /// * *snippet* /// * *contentDetails* /// * *status* - pub fn request(mut self, new_value: &LiveBroadcast) -> LiveBroadcastUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: LiveBroadcast) -> LiveBroadcastUpdateCall<'a, C, A> { + self._request = new_value; self } /// The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. @@ -20964,7 +21231,7 @@ impl<'a, C, A> LiveBroadcastUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.live_broadcasts().insert(&req) +/// let result = hub.live_broadcasts().insert(req) /// .on_behalf_of_content_owner_channel("consetetur") /// .on_behalf_of_content_owner("eirmod") /// .doit(); @@ -21081,12 +21348,17 @@ impl<'a, C, A> LiveBroadcastInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -21095,7 +21367,7 @@ impl<'a, C, A> LiveBroadcastInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -21120,8 +21392,8 @@ impl<'a, C, A> LiveBroadcastInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien /// * *snippet* /// * *contentDetails* /// * *status* - pub fn request(mut self, new_value: &LiveBroadcast) -> LiveBroadcastInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: LiveBroadcast) -> LiveBroadcastInsertCall<'a, C, A> { + self._request = new_value; self } /// The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. @@ -21391,12 +21663,17 @@ impl<'a, C, A> LiveBroadcastListCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -21405,7 +21682,7 @@ impl<'a, C, A> LiveBroadcastListCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -21672,12 +21949,17 @@ impl<'a, C, A> LiveBroadcastDeleteCall<'a, C, A> where C: BorrowMut<hyper::Clien if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -21922,12 +22204,17 @@ impl<'a, C, A> LiveBroadcastTransitionCall<'a, C, A> where C: BorrowMut<hyper::C if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -21936,7 +22223,7 @@ impl<'a, C, A> LiveBroadcastTransitionCall<'a, C, A> where C: BorrowMut<hyper::C Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -22212,12 +22499,17 @@ impl<'a, C, A> LiveBroadcastBindCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -22226,7 +22518,7 @@ impl<'a, C, A> LiveBroadcastBindCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -22475,12 +22767,17 @@ impl<'a, C, A> CaptionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -22601,7 +22898,7 @@ impl<'a, C, A> CaptionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload_resumable(...)`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.captions().insert(&req) +/// let result = hub.captions().insert(req) /// .sync(false) /// .on_behalf_of("magna") /// .debug_project_id_override("ipsum") @@ -22665,14 +22962,15 @@ impl<'a, C, A> CaptionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/youtube/v3/captions".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/youtube/v3/captions".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/youtube/v3/captions".to_string() + ("https://www.googleapis.com/resumable/upload/youtube/v3/captions".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::ForceSsl.as_ref().to_string(), ()); } @@ -22767,12 +23065,17 @@ impl<'a, C, A> CaptionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -22782,9 +23085,9 @@ impl<'a, C, A> CaptionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -22794,7 +23097,7 @@ impl<'a, C, A> CaptionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -22825,7 +23128,7 @@ impl<'a, C, A> CaptionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -22869,8 +23172,8 @@ impl<'a, C, A> CaptionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Caption) -> CaptionInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Caption) -> CaptionInsertCall<'a, C, A> { + self._request = new_value; self } /// The part parameter specifies the caption resource parts that the API response will include. Set the parameter value to snippet. @@ -23110,12 +23413,17 @@ impl<'a, C, A> CaptionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -23124,7 +23432,7 @@ impl<'a, C, A> CaptionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -23402,12 +23710,17 @@ impl<'a, C, A> CaptionDownloadCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -23542,7 +23855,7 @@ impl<'a, C, A> CaptionDownloadCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload_resumable(...)`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.captions().update(&req) +/// let result = hub.captions().update(req) /// .sync(true) /// .on_behalf_of("vero") /// .debug_project_id_override("nonumy") @@ -23606,14 +23919,15 @@ impl<'a, C, A> CaptionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: params.push(("alt", "json".to_string())); - let mut url = if protocol == "simple" { - "https://www.googleapis.com/upload/youtube/v3/captions".to_string() + let (mut url, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/youtube/v3/captions".to_string(), "multipart") } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/youtube/v3/captions".to_string() + ("https://www.googleapis.com/resumable/upload/youtube/v3/captions".to_string(), "resumable") } else { unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + }; + params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::ForceSsl.as_ref().to_string(), ()); } @@ -23708,12 +24022,17 @@ impl<'a, C, A> CaptionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); @@ -23723,9 +24042,9 @@ impl<'a, C, A> CaptionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: } let mut client = &mut *self.hub.client.borrow_mut(); let upload_result = { - let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0; + let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url); + dlg.store_upload_url(url_str); } cmn::ResumableUploadHelper { @@ -23735,7 +24054,7 @@ impl<'a, C, A> CaptionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: auth: &mut *self.hub.auth.borrow_mut(), user_agent: &self.hub._user_agent, auth_header: auth_header.clone(), - url: url, + url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size @@ -23766,7 +24085,7 @@ impl<'a, C, A> CaptionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -23810,8 +24129,8 @@ impl<'a, C, A> CaptionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Caption) -> CaptionUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Caption) -> CaptionUpdateCall<'a, C, A> { + self._request = new_value; self } /// The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. Set the property value to snippet if you are updating the track's draft status. Otherwise, set the property value to id. @@ -24054,12 +24373,17 @@ impl<'a, C, A> VideoCategoryListCall<'a, C, A> where C: BorrowMut<hyper::Client> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -24068,7 +24392,7 @@ impl<'a, C, A> VideoCategoryListCall<'a, C, A> where C: BorrowMut<hyper::Client> Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -24346,12 +24670,17 @@ impl<'a, C, A> ActivityListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -24360,7 +24689,7 @@ impl<'a, C, A> ActivityListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -24549,7 +24878,7 @@ impl<'a, C, A> ActivityListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.activities().insert(&req) +/// let result = hub.activities().insert(req) /// .doit(); /// # } /// ``` @@ -24656,12 +24985,17 @@ impl<'a, C, A> ActivityInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -24670,7 +25004,7 @@ impl<'a, C, A> ActivityInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -24693,8 +25027,8 @@ impl<'a, C, A> ActivityInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// /// * *snippet* /// * *contentDetails* - pub fn request(mut self, new_value: &Activity) -> ActivityInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Activity) -> ActivityInsertCall<'a, C, A> { + self._request = new_value; self } /// The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. diff --git a/gen/youtubeanalytics1-cli/Cargo.toml b/gen/youtubeanalytics1-cli/Cargo.toml index c57e24dec3..35cc0a4552 100644 --- a/gen/youtubeanalytics1-cli/Cargo.toml +++ b/gen/youtubeanalytics1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-youtubeanalytics1-cli" -version = "0.0.1+20150304" +version = "0.1.0+20150304" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with YouTube Analytics (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/youtubeanalytics1-cli" diff --git a/gen/youtubeanalytics1-cli/README.md b/gen/youtubeanalytics1-cli/README.md index 8ea2b9f5cc..f0b53a7892 100644 --- a/gen/youtubeanalytics1-cli/README.md +++ b/gen/youtubeanalytics1-cli/README.md @@ -1,4 +1,111 @@ -# HELLO YOUTUBEANALYTICS:V1 +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/cli/README.md.mako' +DO NOT EDIT ! +--> +The `youtubeanalytics1` command-line interface *(CLI)* allows to use most features of the *Google YouTube Analytics* service from the comfort of your terminal. + +By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's +capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. + +If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. + +# Usage + +This documentation was generated from the *YouTube Analytics* API at revision *20150304*. The CLI is at version *0.1.0*. + +```bash + youtubeanalytics1 [options] batch-report-definitions list <on-behalf-of-content-owner> [-p <v>...] [-o <out>] + youtubeanalytics1 [options] batch-reports list <batch-report-definition-id> <on-behalf-of-content-owner> [-p <v>...] [-o <out>] + youtubeanalytics1 [options] group-items delete <id> [-p <v>...] + youtubeanalytics1 [options] group-items insert -r <kv>... [-p <v>...] [-o <out>] + youtubeanalytics1 [options] group-items list <group-id> [-p <v>...] [-o <out>] + youtubeanalytics1 [options] groups delete <id> [-p <v>...] + youtubeanalytics1 [options] groups insert -r <kv>... [-p <v>...] [-o <out>] + youtubeanalytics1 [options] groups list [-p <v>...] [-o <out>] + youtubeanalytics1 [options] groups update -r <kv>... [-p <v>...] [-o <out>] + youtubeanalytics1 [options] reports query <ids> <start-date> <end-date> <metrics> [-p <v>...] [-o <out>] + youtubeanalytics1 --help + +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_youtubeanalytics1_cli/index.html + +Configuration: + --scope <url> + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. + If unset, it defaults to the shortest scope url for a particular method. + --config-dir <folder> + 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. + +``` + +# Configuration + +The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `youtubeanalytics1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. + +More information about the various kinds of persistent data are given in the following paragraphs. + +# Authentication + +Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the +set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. + +If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a +method that is read-only, it will ask only for a read-only scope. +You may use the `--scope` flag to specify a scope directly. +All applicable scopes are documented in the respective method's CLI documentation. + +The first time a scope is used, the user is asked for permission. Follow the instructions given +by the CLI to grant permissions, or to decline. + +If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration +directory, e.g. `~/.google-service-cli/youtubeanalytics1-token-<scope-hash>.json`. No manual management of these tokens +is necessary. + +To revoke granted authentication, please refer to the [official documentation][revoke-access]. + +# Application Secrets + +In order to allow any application to use Google services, it will need to be registered using the +[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it +one by one. Most APIs can be used for free and have a daily quota. + +To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI +comes with a default application secret that is configured accordingly. This also means that heavy usage +all around the world may deplete the daily quota. + +You can workaround this limitation by putting your own secrets file at this location: +`~/.google-service-cli/youtubeanalytics1-secret.json`, assuming that the required *youtubeAnalytics* API +was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at +*APIs & auth -> Credentials -> Download JSON* and used as is. + +Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file +# Debugging + +Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know +what exactly led to a particular issue. This is done by allowing all client-server communication to be +output to standard error *as-is*. + +The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag +will cause all communication related to authentication to standard error. +If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the +issue at hand. + +You may consider redirecting standard error into a file for ease of use, e.g. `youtubeanalytics1 --debug <resource> <method> [options] 2>debug.txt`. + + +[scopes]: https://developers.google.com/+/api/oauth#scopes +[revoke-access]: http://webapps.stackexchange.com/a/30849 +[google-dev-console]: https://console.developers.google.com/ +[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/youtubeanalytics1-cli/mkdocs.yml b/gen/youtubeanalytics1-cli/mkdocs.yml index 420207a5ab..b68009e409 100644 --- a/gen/youtubeanalytics1-cli/mkdocs.yml +++ b/gen/youtubeanalytics1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: YouTube Analytics v0.0.1+20150304 +site_name: YouTube Analytics v0.1.0+20150304 site_url: http://byron.github.io/google-apis-rs/google-youtubeanalytics1-cli site_description: Write integrating applications with bcore diff --git a/gen/youtubeanalytics1-cli/src/cmn.rs b/gen/youtubeanalytics1-cli/src/cmn.rs index a8d3f46368..4ba65df643 100644 --- a/gen/youtubeanalytics1-cli/src/cmn.rs +++ b/gen/youtubeanalytics1-cli/src/cmn.rs @@ -105,7 +105,7 @@ pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: let key = &kv[..pos]; if kv.len() <= pos + 1 { add_err(); - return (key, None) + return (key, Some("")) } (key, Some(&kv[pos+1..])) } diff --git a/gen/youtubeanalytics1-cli/src/main.rs b/gen/youtubeanalytics1-cli/src/main.rs index 6619dcaabc..424f8af2a6 100644 --- a/gen/youtubeanalytics1-cli/src/main.rs +++ b/gen/youtubeanalytics1-cli/src/main.rs @@ -19,35 +19,36 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - youtubeanalytics1 [options] batch-report-definitions list <on-behalf-of-content-owner> [-p <v>]... [-o <out>] - youtubeanalytics1 [options] batch-reports list <batch-report-definition-id> <on-behalf-of-content-owner> [-p <v>]... [-o <out>] - youtubeanalytics1 [options] group-items delete <id> [-p <v>]... - youtubeanalytics1 [options] group-items insert -r <kv>... [-p <v>]... [-o <out>] - youtubeanalytics1 [options] group-items list <group-id> [-p <v>]... [-o <out>] - youtubeanalytics1 [options] groups delete <id> [-p <v>]... - youtubeanalytics1 [options] groups insert -r <kv>... [-p <v>]... [-o <out>] - youtubeanalytics1 [options] groups list [-p <v>]... [-o <out>] - youtubeanalytics1 [options] groups update -r <kv>... [-p <v>]... [-o <out>] - youtubeanalytics1 [options] reports query <ids> <start-date> <end-date> <metrics> [-p <v>]... [-o <out>] + youtubeanalytics1 [options] batch-report-definitions list <on-behalf-of-content-owner> [-p <v>...] [-o <out>] + youtubeanalytics1 [options] batch-reports list <batch-report-definition-id> <on-behalf-of-content-owner> [-p <v>...] [-o <out>] + youtubeanalytics1 [options] group-items delete <id> [-p <v>...] + youtubeanalytics1 [options] group-items insert -r <kv>... [-p <v>...] [-o <out>] + youtubeanalytics1 [options] group-items list <group-id> [-p <v>...] [-o <out>] + youtubeanalytics1 [options] groups delete <id> [-p <v>...] + youtubeanalytics1 [options] groups insert -r <kv>... [-p <v>...] [-o <out>] + youtubeanalytics1 [options] groups list [-p <v>...] [-o <out>] + youtubeanalytics1 [options] groups update -r <kv>... [-p <v>...] [-o <out>] + youtubeanalytics1 [options] reports query <ids> <start-date> <end-date> <metrics> [-p <v>...] [-o <out>] youtubeanalytics1 --help -All documentation details can be found TODO: <URL to github.io docs here, see #51> +All documentation details can be found at +http://byron.github.io/google-apis-rs/google_youtubeanalytics1_cli/index.html Configuration: --scope <url> - Specify the authentication a method should be executed in. Each scope requires - the user to grant this application permission to use it. + Specify the authentication a method should be executed in. Each scope + requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir <folder> - A directory into which we will store our persistent data. Defaults to a user-writable - directory that we will create during the first invocation. + 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. + 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. + Output all communication related to authentication to standard error. `tx` + and `rx` are placed into the same stream. "); mod cmn; @@ -96,6 +97,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -139,6 +143,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -185,6 +192,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -199,8 +209,58 @@ impl Engine { fn _group_items_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { + let mut request = api::GroupItem::default(); - let mut call = self.hub.group_items().insert(&request); + let mut field_cursor = FieldCursor::default(); + for kvarg in self.opt.arg_kv.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; + } + fn request_resource_init(request: &mut api::GroupItem) { + if request.resource.is_none() { + request.resource = Some(Default::default()); + } + } + + match &temp_cursor.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "etag" => { + request.etag = Some(value.unwrap_or("").to_string()); + }, + "resource.kind" => { + request_resource_init(&mut request); + request.resource.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); + }, + "resource.id" => { + request_resource_init(&mut request); + request.resource.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); + }, + "group-id" => { + request_resource_init(&mut request); + request.group_id = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request_resource_init(&mut request); + request.id = Some(value.unwrap_or("").to_string()); + }, + _ => { + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); + } + } + } + let mut call = self.hub.group_items().insert(request); for parg in self.opt.arg_v.iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -225,52 +285,14 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - - let mut field_name = FieldCursor::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_resource_init(request: &mut api::GroupItem) { - if request.resource.is_none() { - request.resource = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "resource.kind" => { - request_resource_init(&mut request); - request.resource.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); - }, - "resource.id" => { - request_resource_init(&mut request); - request.resource.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); - }, - "group-id" => { - request_resource_init(&mut request); - request.group_id = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request_resource_init(&mut request); - request.id = Some(value.unwrap_or("").to_string()); - }, - _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); - } - } - } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -317,6 +339,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -363,6 +388,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } match match protocol { "standard-request" => call.doit(), _ => unreachable!(), @@ -377,39 +405,23 @@ impl Engine { fn _groups_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Group::default(); - let mut call = self.hub.groups().insert(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "on-behalf-of-content-owner" => { - call = call.on_behalf_of_content_owner(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Group::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_content_details_init(request: &mut api::Group) { if request.content_details.is_none() { request.content_details = Some(Default::default()); @@ -422,7 +434,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "snippet.published-at" => { request_snippet_init(&mut request); request.snippet.as_mut().unwrap().published_at = Some(value.unwrap_or("").to_string()); @@ -452,15 +464,43 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.groups().insert(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "on-behalf-of-content-owner" => { + call = call.on_behalf_of_content_owner(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -513,6 +553,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -529,39 +572,23 @@ impl Engine { fn _groups_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request = api::Group::default(); - let mut call = self.hub.groups().update(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "on-behalf-of-content-owner" => { - call = call.on_behalf_of_content_owner(value.unwrap_or("")); - }, - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name = FieldCursor::default(); + let mut request = api::Group::default(); + let mut field_cursor = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { + let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); - if let Err(field_err) = field_name.set(&*key) { + 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; + } fn request_content_details_init(request: &mut api::Group) { if request.content_details.is_none() { request.content_details = Some(Default::default()); @@ -574,7 +601,7 @@ impl Engine { } } - match &field_name.to_string()[..] { + match &temp_cursor.to_string()[..] { "snippet.published-at" => { request_snippet_init(&mut request); request.snippet.as_mut().unwrap().published_at = Some(value.unwrap_or("").to_string()); @@ -604,15 +631,43 @@ impl Engine { request.id = Some(value.unwrap_or("").to_string()); }, _ => { - err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); + err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string()))); } } } + let mut call = self.hub.groups().update(request); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "on-behalf-of-content-owner" => { + call = call.on_behalf_of_content_owner(value.unwrap_or("")); + }, + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), + } + } let protocol = "standard-request"; if dry_run { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -674,6 +729,9 @@ impl Engine { None } else { assert!(err.issues.len() == 0); + if self.opt.flag_scope.len() > 0 { + call = call.add_scope(&self.opt.flag_scope); + } let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out); match match protocol { "standard-request" => call.doit(), @@ -805,6 +863,7 @@ impl Engine { fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); + let debug = opts.flag_debug; match Engine::new(opts) { Err(err) => { writeln!(io::stderr(), "{}", err).ok(); @@ -812,8 +871,11 @@ fn main() { }, Ok(engine) => { if let Some(err) = engine.doit() { - writeln!(io::stderr(), "{:?}", err).ok(); - writeln!(io::stderr(), "{}", err).ok(); + if debug { + writeln!(io::stderr(), "{:?}", err).ok(); + } else { + writeln!(io::stderr(), "{}", err).ok(); + } env::set_exit_status(1); } } diff --git a/gen/youtubeanalytics1/Cargo.toml b/gen/youtubeanalytics1/Cargo.toml index aa39a3c660..1a1443f4d1 100644 --- a/gen/youtubeanalytics1/Cargo.toml +++ b/gen/youtubeanalytics1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-youtubeanalytics1" -version = "0.1.5+20150304" +version = "0.1.6+20150304" authors = ["Sebastian Thiel <byronimo@gmail.com>"] description = "A complete library to interact with YouTube Analytics (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/youtubeanalytics1" diff --git a/gen/youtubeanalytics1/README.md b/gen/youtubeanalytics1/README.md index f76aab1bab..4fa155c3aa 100644 --- a/gen/youtubeanalytics1/README.md +++ b/gen/youtubeanalytics1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-youtubeanalytics1` library allows access to all features of the *Google YouTube Analytics* service. -This documentation was generated from *YouTube Analytics* crate version *0.1.5+20150304*, where *20150304* is the exact revision of the *youtubeAnalytics:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +This documentation was generated from *YouTube Analytics* crate version *0.1.6+20150304*, where *20150304* is the exact revision of the *youtubeAnalytics:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. Everything else about the *YouTube Analytics* *v1* API can be found at the [official documentation site](http://developers.google.com/youtube/analytics/). @@ -113,14 +113,15 @@ match result { Err(e) => match e { // The Error enum provides details about what exactly happened. // You can also just use its `Debug`, `Display` or `Error` traits - Error::HttpError(_) + Error::HttpError(_) |Error::MissingAPIKey - |Error::MissingToken + |Error::MissingToken(_) |Error::Cancelled |Error::UploadSizeLimitExceeded(_, _) |Error::Failure(_) + |Error::BadRequest(_) |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), + |Error::JsonDecodeError(_, _) => println!("{}", e), }, Ok(res) => println!("Success: {:?}", res), } diff --git a/gen/youtubeanalytics1/src/cmn.rs b/gen/youtubeanalytics1/src/cmn.rs index aee3fb3f4b..b7665b194b 100644 --- a/gen/youtubeanalytics1/src/cmn.rs +++ b/gen/youtubeanalytics1/src/cmn.rs @@ -60,7 +60,6 @@ pub trait ToParts { fn to_parts(&self) -> String; } - /// A utility type which can decode a server response that indicates error #[derive(Deserialize)] pub struct JsonServerError { @@ -68,6 +67,30 @@ pub struct JsonServerError { pub error_description: Option<String> } +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + errors: Vec<ServerMessage>, + code: u16, + message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + domain: String, + reason: String, + message: String, + #[serde(rename="locationType")] + location_type: Option<String>, + location: Option<String> +} + #[derive(Copy, Clone)] pub struct DummyNetworkStream; @@ -175,7 +198,7 @@ pub trait Delegate { /// /// If you choose to retry after a duration, the duration should be chosen using the /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). - fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry { + fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry { Retry::Abort } @@ -230,6 +253,10 @@ pub enum Error { /// even though the maximum upload size is what is stored in field `.1`. UploadSizeLimitExceeded(u64, u64), + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey, @@ -245,7 +272,7 @@ pub enum Error { /// Shows that we failed to decode the server response. /// This can happen if the protocol changes in conjunction with strict json decoding. - JsonDecodeError(serde::json::Error), + JsonDecodeError(String, serde::json::Error), /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::client::Response), @@ -263,13 +290,16 @@ impl Display for Error { writeln!(f, "The application's API key was not found in the configuration").ok(); writeln!(f, "It is used as there are no Scopes defined for this method.") }, + Error::BadRequest(ref err) + => writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message), Error::MissingToken(ref err) => writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field), - Error::JsonDecodeError(ref err) => err.fmt(f), + Error::JsonDecodeError(ref json_str, ref err) + => writeln!(f, "{}: {}", err, json_str), Error::Failure(ref response) => writeln!(f, "Http status indicates failure: {:?}", response), } @@ -280,7 +310,7 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), + Error::JsonDecodeError(_, ref err) => err.description(), _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" } } @@ -288,7 +318,7 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), + Error::JsonDecodeError(_, ref err) => err.cause(), _ => None } } @@ -401,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> { // before clearing the last part, we will add the boundary that // will be written last self.last_part_boundary = Some(Cursor::new( - format!("{}--{}", LINE_ENDING, BOUNDARY).into_bytes())) + format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes())) } // We are depleted - this can trigger the next part to come in self.current_part = None; @@ -489,7 +519,7 @@ impl Header for ContentRange { impl HeaderFormat for ContentRange { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); + try!(fmt.write_str("bytes ")); match self.range { Some(ref c) => try!(c.fmt(fmt)), None => try!(fmt.write_str("*")) @@ -510,7 +540,7 @@ impl Header for RangeResponseHeader { fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> { if let [ref v] = raw { if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes="; + const PREFIX: &'static str = "bytes "; if s.starts_with(PREFIX) { if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { return Some(RangeResponseHeader(c)) @@ -559,7 +589,7 @@ impl<'a, A> ResumableUploadHelper<'a, A> let h: &RangeResponseHeader = match headers.get() { Some(hh) if r.status == StatusCode::PermanentRedirect => hh, None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None) { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { sleep_ms(d.num_milliseconds() as u32); continue; } @@ -626,7 +656,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, serde::json::from_str(&json_err).ok()) { + if let Retry::After(d) = self.delegate.http_failure(&res, + serde::json::from_str(&json_err).ok(), + serde::json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } diff --git a/gen/youtubeanalytics1/src/lib.rs b/gen/youtubeanalytics1/src/lib.rs index 32610dd308..8bb4816340 100644 --- a/gen/youtubeanalytics1/src/lib.rs +++ b/gen/youtubeanalytics1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *YouTube Analytics* crate version *0.1.5+20150304*, where *20150304* is the exact revision of the *youtubeAnalytics:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! This documentation was generated from *YouTube Analytics* crate version *0.1.6+20150304*, where *20150304* is the exact revision of the *youtubeAnalytics:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.6*. //! //! Everything else about the *YouTube Analytics* *v1* API can be found at the //! [official documentation site](http://developers.google.com/youtube/analytics/). @@ -114,14 +114,15 @@ //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits -//! Error::HttpError(_) +//! Error::HttpError(_) //! |Error::MissingAPIKey -//! |Error::MissingToken +//! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) +//! |Error::BadRequest(_) //! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), +//! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } @@ -209,7 +210,7 @@ use std::io; use std::fs; use std::thread::sleep_ms; -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError}; +pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse}; // ############## @@ -302,14 +303,15 @@ impl Default for Scope { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits -/// Error::HttpError(_) +/// Error::HttpError(_) /// |Error::MissingAPIKey -/// |Error::MissingToken +/// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) +/// |Error::BadRequest(_) /// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), +/// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } @@ -330,7 +332,7 @@ impl<'a, C, A> YouTubeAnalytics<C, A> YouTubeAnalytics { client: RefCell::new(client), auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".to_string(), + _user_agent: "google-api-rust-client/0.1.6".to_string(), } } @@ -351,7 +353,7 @@ impl<'a, C, A> YouTubeAnalytics<C, A> } /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.5`. + /// It defaults to `google-api-rust-client/0.1.6`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { @@ -882,10 +884,10 @@ impl<'a, C, A> GroupItemMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &GroupItem) -> GroupItemInsertCall<'a, C, A> { + pub fn insert(&self, request: GroupItem) -> GroupItemInsertCall<'a, C, A> { GroupItemInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _on_behalf_of_content_owner: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -995,10 +997,10 @@ impl<'a, C, A> GroupMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn insert(&self, request: &Group) -> GroupInsertCall<'a, C, A> { + pub fn insert(&self, request: Group) -> GroupInsertCall<'a, C, A> { GroupInsertCall { hub: self.hub, - _request: request.clone(), + _request: request, _on_behalf_of_content_owner: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -1028,10 +1030,10 @@ impl<'a, C, A> GroupMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - pub fn update(&self, request: &Group) -> GroupUpdateCall<'a, C, A> { + pub fn update(&self, request: Group) -> GroupUpdateCall<'a, C, A> { GroupUpdateCall { hub: self.hub, - _request: request.clone(), + _request: request, _on_behalf_of_content_owner: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -1265,12 +1267,17 @@ impl<'a, C, A> ReportQueryCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1279,7 +1286,7 @@ impl<'a, C, A> ReportQueryCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1549,12 +1556,17 @@ impl<'a, C, A> BatchReportDefinitionListCall<'a, C, A> where C: BorrowMut<hyper: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1563,7 +1575,7 @@ impl<'a, C, A> BatchReportDefinitionListCall<'a, C, A> where C: BorrowMut<hyper: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1670,7 +1682,7 @@ impl<'a, C, A> BatchReportDefinitionListCall<'a, C, A> where C: BorrowMut<hyper: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.group_items().insert(&req) +/// let result = hub.group_items().insert(req) /// .on_behalf_of_content_owner("no") /// .doit(); /// # } @@ -1777,12 +1789,17 @@ impl<'a, C, A> GroupItemInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -1791,7 +1808,7 @@ impl<'a, C, A> GroupItemInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -1809,8 +1826,8 @@ impl<'a, C, A> GroupItemInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &GroupItem) -> GroupItemInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: GroupItem) -> GroupItemInsertCall<'a, C, A> { + self._request = new_value; self } /// Note: This parameter is intended exclusively for YouTube content partners. @@ -2000,12 +2017,17 @@ impl<'a, C, A> GroupItemListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2014,7 +2036,7 @@ impl<'a, C, A> GroupItemListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2223,12 +2245,17 @@ impl<'a, C, A> GroupItemDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -2436,12 +2463,17 @@ impl<'a, C, A> GroupDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = res; @@ -2556,7 +2588,7 @@ impl<'a, C, A> GroupDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.groups().insert(&req) +/// let result = hub.groups().insert(req) /// .on_behalf_of_content_owner("Lorem") /// .doit(); /// # } @@ -2663,12 +2695,17 @@ impl<'a, C, A> GroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2677,7 +2714,7 @@ impl<'a, C, A> GroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -2695,8 +2732,8 @@ impl<'a, C, A> GroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Group) -> GroupInsertCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Group) -> GroupInsertCall<'a, C, A> { + self._request = new_value; self } /// Note: This parameter is intended exclusively for YouTube content partners. @@ -2894,12 +2931,17 @@ impl<'a, C, A> GroupListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -2908,7 +2950,7 @@ impl<'a, C, A> GroupListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3028,7 +3070,7 @@ impl<'a, C, A> GroupListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.groups().update(&req) +/// let result = hub.groups().update(req) /// .on_behalf_of_content_owner("sea") /// .doit(); /// # } @@ -3135,12 +3177,17 @@ impl<'a, C, A> GroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3149,7 +3196,7 @@ impl<'a, C, A> GroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } }; @@ -3167,8 +3214,8 @@ impl<'a, C, A> GroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Group) -> GroupUpdateCall<'a, C, A> { - self._request = new_value.clone(); + pub fn request(mut self, new_value: Group) -> GroupUpdateCall<'a, C, A> { + self._request = new_value; self } /// Note: This parameter is intended exclusively for YouTube content partners. @@ -3355,12 +3402,17 @@ impl<'a, C, A> BatchReportListCall<'a, C, A> where C: BorrowMut<hyper::Client>, if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { sleep_ms(d.num_milliseconds() as u32); continue; } dlg.finished(false); - return Err(Error::Failure(res)) + return match json::from_str::<ErrorResponse>(&json_err){ + Err(_) => Err(Error::Failure(res)), + Ok(serr) => Err(Error::BadRequest(serr)) + } } let result_value = { let mut json_response = String::new(); @@ -3369,7 +3421,7 @@ impl<'a, C, A> BatchReportListCall<'a, C, A> where C: BorrowMut<hyper::Client>, Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); + return Err(Error::JsonDecodeError(json_response, err)); } } };